How to use the rospkg.common function in rospkg

To help you get started, we’ve selected a few rospkg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github corot / thorp / thorp_perception / scripts / populate_database.py View on Github external
['diamond', 'Untextured 2.6 cm side diamond', 'diamond.stl'],
               ['cross', 'Untextured 3.7 x 3.7 cm cross', 'cross.stl'],
               ['clover', 'Untextured 3.7 x 3.7 cm clover', 'clover.stl']]

    for object in objects:
        if os.path.exists(rospack.get_path('thorp_perception') + "/meshes/" + object[2]):
            print subprocess.check_output(['cp', rospack.get_path('thorp_perception') + "/meshes/" + object[2], 'tmp.ascii.stl'])
        else:
            print subprocess.check_output(['openscad', '-DOBJ="' + object[2][:-4] + '"', '-o', 'tmp.ascii.stl', 'gen_meshes.scad'])
        print subprocess.check_output(['admesh', '-b', 'tmp.bin.stl', 'tmp.ascii.stl'])
        out = subprocess.check_output(['rosrun', 'object_recognition_core', 'object_add.py', '-n', object[0], '-d', object[1], '--commit'])
        id = re.split(' ', out)[-1][:-1]
        print out
        print subprocess.check_output(['rosrun', 'object_recognition_core', 'mesh_add.py', id, 'tmp.bin.stl', '--commit'])
        print subprocess.check_output(['rm', 'tmp.ascii.stl', 'tmp.bin.stl'])
except rospkg.common.ResourceNotFound as err:
    print "get package path failed: " + str(err)
except subprocess.CalledProcessError as err:
    print "execute command failed: " + str(err)
github ros / ros_comm / tools / rosgraph / src / rosgraph / roslogging.py View on Github external
success = renew_latest_logdir(logfile_dir)
                if not success:
                    sys.stderr.write("INFO: cannot create a symlink to latest log directory\n")
            except OSError as e:
                sys.stderr.write("INFO: cannot create a symlink to latest log directory: %s\n" % e)

    config_file = os.environ.get('ROS_PYTHON_LOG_CONFIG_FILE')
    if not config_file:
        # search for logging config file in ROS_HOME, ROS_ETC_DIR or relative
        # to the rosgraph package directory.
        config_dirs = [os.path.join(rospkg.get_ros_home(), 'config'),
                       rospkg.get_etc_ros_dir()]
        try:
            config_dirs.append(os.path.join(
                rospkg.RosPack().get_path('rosgraph'), 'conf'))
        except rospkg.common.ResourceNotFound:
            pass
        for config_dir in config_dirs:
            for extension in ('conf', 'yaml'):
                f = os.path.join(config_dir,
                                 'python_logging{}{}'.format(os.path.extsep,
                                                             extension))
                if os.path.isfile(f):
                    config_file = f
                    break
            if config_file is not None:
                break

    if config_file is None or not os.path.isfile(config_file):
        # logging is considered soft-fail
        sys.stderr.write("WARNING: cannot load logging configuration file, logging is disabled\n")
        logging.getLogger(logname).setLevel(logging.CRITICAL)
github alexlee-gk / visual_dynamics / visual_dynamics / gui / action_panel.py View on Github external
from visual_dynamics.gui.config import config

LOGGER = logging.getLogger(__name__)
ROS_ENABLED = False
try:
    import rospkg
    import roslib
    import rospy
    from sensor_msgs.msg import Joy

    roslib.load_manifest('gps_agent_pkg')
    ROS_ENABLED = True
except ImportError as e:
    LOGGER.debug('Import ROS failed: %s', e)
except rospkg.common.ResourceNotFound as e:
    LOGGER.debug('No gps_agent_pkg: %s', e)


class Action:
    """
    An action is defined by a key (used to identify it), a name, and a function.
    It is called by placing it on an matplotlib Axis object (as specified by
    axis_pos), giving it a keyboard_binding, or giving it a ps3_binding.
    """
    def __init__(self, key, name, func, axis_pos=None, keyboard_binding=None, ps3_binding=None):
        self.key = key
        self.name = name
        self.func = func
        self.axis_pos = axis_pos
        self.kb = keyboard_binding
        self.pb = ps3_binding
github CopterExpress / clever-show / drone / client.py View on Github external
def check_clover_dir(self):
        rospack = rospkg.RosPack()
        try:
            path = rospack.get_path('clever')
        except rospkg.common.ResourceNotFound:
            try:
                path = rospack.get_path('clover')
            except rospkg.common.ResourceNotFound:
                path = 'error'
        self.config.set('', 'clover_dir', path, write=True)
        if path.count("/pi/"):
            self.server_connection.whoami = "pi"
github CopterExpress / clever-show / drone / client.py View on Github external
def check_clover_dir(self):
        rospack = rospkg.RosPack()
        try:
            path = rospack.get_path('clever')
        except rospkg.common.ResourceNotFound:
            try:
                path = rospack.get_path('clover')
            except rospkg.common.ResourceNotFound:
                path = 'error'
        self.config.set('', 'clover_dir', path, write=True)
github ros / ros_comm / tools / roslaunch / src / roslaunch / rlutil.py View on Github external
:param f: roslaunch file name, ``str``
    :param use_test_depends: Consider test_depends, ``Bool``
    :returns: error message or ``None``
    """
    try:
        rl_config = roslaunch.config.load_config_default([f], DEFAULT_MASTER_PORT, verbose=False)
    except roslaunch.core.RLException as e:
        return str(e)
    
    rospack = rospkg.RosPack()
    errors = []
    # check for missing deps
    try:
        base_pkg, file_deps, missing = roslaunch.depends.roslaunch_deps([f], use_test_depends=use_test_depends)
    except rospkg.common.ResourceNotFound as r:
        errors.append("Could not find package [%s] included from [%s]"%(str(r), f))
        missing = {}
        file_deps = {}
    except roslaunch.substitution_args.ArgException as e:
        errors.append("Could not resolve arg [%s] in [%s]"%(str(e), f))
        missing = {}
        file_deps = {}
    for pkg, miss in missing.items():
        # even if the pkgs is not found in packges.xml, if other package.xml provdes that pkgs, then it will be ok
        all_pkgs = []
        try:
            for file_dep in file_deps.keys():
                file_pkg = rospkg.get_package_name(file_dep)
                all_pkgs.extend(rospack.get_depends(file_pkg,implicit=False))
                miss_all = list(set(miss) - set(all_pkgs))
        except Exception as e:
github cbfinn / gps / python / gps / agent / config.py View on Github external
#TODO: Actually pass in low gains and high gains and use both
        #      for the position controller.
        'pid_params': np.array([
            2400.0, 0.0, 18.0, 4.0,
            1200.0, 0.0, 20.0, 4.0,
            1000.0, 0.0, 6.0, 4.0,
            700.0, 0.0, 4.0, 4.0,
            300.0, 0.0, 6.0, 2.0,
            300.0, 0.0, 4.0, 2.0,
            300.0, 0.0, 2.0, 2.0
        ]),
    }
except ImportError as e:
    AGENT_ROS = {}
    LOGGER.debug('No ROS enabled: %s', e)
except rospkg.common.ResourceNotFound as e:
    AGENT_ROS = {}
    LOGGER.debug('No gps_agent_pkg: %s', e)


# AgentMuJoCo
AGENT_MUJOCO = {
    'substeps': 1,
    'camera_pos': np.array([2., 3., 2., 0., 0., 0.]),
    'image_width': 640,
    'image_height': 480,
    'image_channels': 3,
    'meta_include': []
}

AGENT_BOX2D = {
    'render': True,