Skip to main content

Toolsuite for running ROS environments directly from python code, without any specific requirements outside of usual python

Project description

https://travis-ci.org/asmodehn/pyros-setup.svg?branch=indigo

Toolsuite for running ROS environments directly from python code, without any specific requirements outside of usual python.

This WILL BE a pure python package, to be installed in your system, in order to allow easy ROS access from your python environment.

To install it:

sudo pip install -i https://testpypi.python.org/pypi pyros_setup

However it is usable from source for ease of development and compatibility testing. Just use the branch matching your rosdistro.

Basically it allows you to do this:

try:
    import rospy
    import roslaunch
    import rosgraph
    import rosnode
except ImportError:  # if ROS environment is not setup, we emulate it.
    import pyros_setup
    pyros_setup = pyros_setup.delayed_import_auto(base_path=os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', '..', '..'))
    import rospy
    import roslaunch
    import rosgraph
    import rosnode

A ROS package WILL BE also provided ( should BECOME a Third Party Release to minimize changes between the two versions ) This package is only useful if you use the extra functionnalities ( like get_master ) even if your ROS system is already loaded:

import pyros_setup

try:
    import rospy
    import rosgraph
except ImportError:  # if ROS environment is not setup, we emulate it.
    import sys
    sys.modules["pyros_setup"] = pyros_setup.delayed_import_auto(base_path=os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', '..', '..'))
    import rospy
    import rosgraph


roscore_process = None
master = None
launch = None


def setup_module():
    global master
    global roscore_process
    master, roscore_process = pyros_setup.get_master()
    assert master.is_online()

Note: If you know any easier / less tricky / more pythonic way of handling dynamic imports, let me know!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyros_setup-0.0.12.tar.gz (9.5 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page