Exemplo n.º 1
0
    def run_launch(self, data):
        launch_commands = utils.list_launch_commands()
        if data.get('command') in launch_commands:
            cmd = 'PYTHONUNBUFFERED=false roslaunch ' + data.get('command')
            process = Popen(cmd, shell=True, stdout=PIPE)

            # Note: The launched rosnode-name does not appear the soon after roslaunch is executed.
            # Therefore, sleep is neccessary to wait it finishes to launch.
            time.sleep(2)
            msg = {
                    'uuid': self.id,
                    'rosnodes': rosnode.get_node_names(),
                    'rostopics': utils.list_rostopics()
                    }
            self.sio.emit('update_rosnodes', json.dumps(msg), namespace=self.nms)

            while True:
                output = process.stdout.readline()
                if output == '' and process.poll() is not None:
                    break
                if output:
                    msg = {
                            "cmd": data.get('command').replace(" ", "-"),
                            "robotUuid": self.id,
                            "log": output.strip(),
                            }
                    self.sio.emit('roslaunch_log', json.dumps(msg), namespace=self.nms)
                    print(output.strip())
            process.poll()
Exemplo n.º 2
0
    def connect(self):
        ros_root = rospkg.get_ros_root()
        r = rospkg.RosPack()
        manifest = r.get_manifest('rowma_ros')
        rowma_ros_version = manifest.version

        launch_commands = utils.list_launch_commands()
        rosrun_commands = utils.list_rosorun_commands()
        rostopics = utils.list_rostopics()
        uuid = os.environ.get('UUID', self.id)
        msg = {
                'uuid': uuid,
                'launch_commands': launch_commands,
                'rosnodes': rosnode.get_node_names(),
                'rosrun_commands': rosrun_commands,
                'rowma_ros_version': rowma_ros_version,
                'rostopics': rostopics,
                'reconnection': self.reconnecting
                }

        api_key = os.environ.get('API_KEY')
        if api_key:
            msg['api_key'] = api_key

        self.sio.emit('register_robot', json.dumps(msg), namespace=self.nms)
        utils.print_success('connection established')
Exemplo n.º 3
0
def test_list_launch_commands():
    launch_commands = utils.list_launch_commands()
    expected = [
        'ros_package_template ros_package_template.launch',
        'ros_package_template ros_package_template_overlying_params.launch'
    ]
    assert launch_commands.sort() == expected.sort()
Exemplo n.º 4
0
    def connect(self):
        print('connection established')
        launch_commands = utils.list_launch_commands()
        rosrun_commands = utils.list_rosorun_commands()
        uuid = os.environ.get('UUID') or self.id
        msg = {
            'uuid': uuid,
            'launch_commands': launch_commands,
            'rosnodes': rosnode.get_node_names(),
            'rosrun_commands': rosrun_commands
        }

        api_key = os.environ.get('API_KEY')
        if api_key:
            msg['api_key'] = api_key

        self.sio.emit('register_robot', json.dumps(msg), namespace=self.nms)
Exemplo n.º 5
0
    def run_launch(self, data):
        launch_commands = utils.list_launch_commands()
        print(launch_commands)
        if data.get('command') in launch_commands:
            cmd = 'roslaunch ' + data.get('command')
            if self.launched_nodes == None:
                self.launched_nodes = []
            self.launched_nodes = self.launched_nodes.append(Popen(
                cmd.split()))

            # Note: The launched rosnode-name does not appear the soon after roslaunch is executed.
            # Therefore, sleep is neccessary to wait it finishes to launch.
            time.sleep(2)
            msg = {'uuid': self.id, 'rosnodes': rosnode.get_node_names()}
            self.sio.emit('update_rosnodes',
                          json.dumps(msg),
                          namespace=self.nms)
            print('run_launch')
            print(data)