Exemplo n.º 1
0
def test_make_caller_id():
    from rosgraph.names import make_caller_id
    if 'ROS_NAMESPACE' is os.environ:
        rosns = os.environ['ROS_NAMESPACE']
        del os.environ['ROS_NAMESPACE']
    else:
        rosns = None

    for n in ['~name']:
        try:
            make_caller_id('~name')  # illegal
            assert False, "make_caller_id should fail on %s" % n
        except ValueError:
            pass

    assert '/node/' == make_caller_id('node')
    assert '/bar/node/' == make_caller_id('bar/node')
    assert '/bar/node/' == make_caller_id('/bar/node')

    os.environ['ROS_NAMESPACE'] = '/test/'
    assert '/test/node/' == make_caller_id('node')
    assert '/test/bar/node/' == make_caller_id('bar/node')
    assert '/bar/node/' == make_caller_id('/bar/node')

    # restore
    if rosns:
        os.environ['ROS_NAMESPACE'] = rosns
Exemplo n.º 2
0
def test_make_caller_id():
    from rosgraph.names import make_caller_id
    if 'ROS_NAMESPACE' is os.environ:
        rosns = os.environ['ROS_NAMESPACE']
        del os.environ['ROS_NAMESPACE']
    else:
        rosns = None

    for n in ['~name']:
        try:
            make_caller_id('~name') # illegal
            assert False, "make_caller_id should fail on %s"%n
        except ValueError:
            pass
    
    assert '/node/' == make_caller_id('node')
    assert '/bar/node/' == make_caller_id('bar/node')
    assert '/bar/node/' == make_caller_id('/bar/node')

    os.environ['ROS_NAMESPACE'] = '/test/'
    assert '/test/node/' == make_caller_id('node')
    assert '/test/bar/node/' == make_caller_id('bar/node')
    assert '/bar/node/' == make_caller_id('/bar/node')
    
    # restore
    if rosns:
        os.environ['ROS_NAMESPACE'] = rosns
Exemplo n.º 3
0
    def start(self):
        self.__logger.info('##### start ' + self.__module_name)
        roslaunch.rlutil._wait_for_master()
        rosmaster = masterapi.Master(
            names.make_caller_id('rosparam-%s' % os.getpid()))
        while not rosmaster.hasParam('run_id'):
            time.sleep(1)
        while rosmaster.getParam('run_id') is '':
            time.sleep(1)

        time.sleep(10)

        self.send_msg_dispatcher(self.msg_id.mode_start_status, {
            'index': setting.start_ros,
            'status': True
        })

        self.uuid = roslaunch.rlutil.get_or_generate_uuid(None, False)
        print('uuid' + self.uuid)

        self.launch_under_pan = roslaunch.parent.ROSLaunchParent(
            self.uuid, [self.launch_under_pan_path])

        try:
            time.sleep(1)

            self.__logger.info('begin to start launch_under_pan!')
            self.launch_under_pan.start()
            self.__logger.info('launch_under_pan started!')

            time.sleep(5)

            self.send_msg_dispatcher(self.msg_id.mode_start_status, {
                'index': setting.start_launch,
                'status': True
            })

            while True:
                # self.__logger.info('######### launch still alive')
                time.sleep(10)

        except roslaunch.RLException as e:
            print('I am except')
            self.__logger.fatal(str(e))

        finally:
            print('I am finally')
            if self.launch_other is not None:
                self.launch_other.shutdown()
            if self.launch_running is not None:
                self.launch_running.shutdown()
        pass
Exemplo n.º 4
0
def _get_caller_id():
    """
    :returns: caller ID for rosparam ROS client calls, ``str``
    """
    return make_caller_id('rosparam-%s' % os.getpid())
Exemplo n.º 5
0
def _get_caller_id():
    """
    :returns: caller ID for rosparam ROS client calls, ``str``
    """
    return make_caller_id('rosparam-%s'%os.getpid())