Esempio n. 1
0
def generate_launch_description():
    # Launch folder
    launch_file_dir = os.path.join(get_package_share_directory(pkg_name), dir_model)
    #rviz
    rviz_file = os.path.join(get_package_share_directory(pkg_name2),
                        dir_rviz,
                        rviz_config)

    return LaunchDescription([

        ExecuteProcess(
            name='START-SIM',
            cmd=['ros2', 'launch', 'rastreator_bringup', 'start_sim.launch.py'],
            output = 'screen',
            shell='True'
        ),
        Node(
            package='rviz2',
            node_executable='rviz2',
            node_name='rviz2',
            output='screen',
            arguments=['-d', rviz_file]
            ),
        ExecuteProcess(
            name='START-NAV2',
            cmd=['ros2', 'launch', 'rastreator_navigation2', 'start_localization.launch.py'],
            output = 'screen',
            shell='True'
        )
    ])
Esempio n. 2
0
def generate_launch_description():

    # Parameters
    params_dir = LaunchConfiguration('params_dir',
                                     default=os.path.join(
                                         get_package_share_directory(pkg_name),
                                         param_folder, param_file))
    # Description folder (to get world)
    world = os.path.join(get_package_share_directory(pkg_name2), dir_world,
                         world_file_name)

    return LaunchDescription([
        Node(package='rastreator_simulation',
             node_executable='ekf',
             parameters=[params_dir],
             output='screen'),
        ExecuteProcess(name='START-PLOT',
                       cmd=[
                           'rqt', '-s', 'rqt_plot', '--args',
                           '/ekf/estimated_state/x', '/ekf/estimated_state/y',
                           '/ekf/true_state/x', '/ekf/true_state/y'
                       ],
                       output='screen',
                       shell='True'),
        ExecuteProcess(
            cmd=['gazebo', '--verbose', world, '-s', 'libgazebo_ros_init.so'],
            output='screen'),
    ])
Esempio n. 3
0
def generate_launch_description():
    # Sim
    use_sim_time = LaunchConfiguration('use_sim_time', default='true')
    # Launch folder
    launch_file_dir = os.path.join(get_package_share_directory(pkg_name), dir_model)
    # Description folder (to get world)
    world = os.path.join(get_package_share_directory(pkg_name2), 
                     dir_world, 
                     world_file_name)

    return LaunchDescription([

        IncludeLaunchDescription(
            PythonLaunchDescriptionSource([launch_file_dir, '/state_publisher.launch.py']),
            launch_arguments={'use_sim_time': use_sim_time}.items(),
        ),
        ExecuteProcess(
            name='START-JOYSTICK',
            cmd=['ros2', 'launch', 'rastreator_joystick', 'start.launch.py'],
            output = 'screen',
            shell='True'
        ),
        ExecuteProcess(
            cmd=['gazebo', '--verbose', world, '-s', 'libgazebo_ros_init.so'],
            output='screen')
    ])
Esempio n. 4
0
def generate_launch_description():
    # Sim
    use_sim_time = LaunchConfiguration('use_sim_time', default='false')
    # Launch folder
    launch_file_dir = os.path.join(get_package_share_directory(pkg_name),
                                   dir_model)

    return LaunchDescription([
        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(
                [launch_file_dir, '/state_publisher.launch.py']),
            launch_arguments={'use_sim_time': use_sim_time}.items(),
        ),
        ExecuteProcess(
            name='START-RASTREATOR',
            cmd=['ros2', 'launch', 'rastreator_wheelmotor', 'start.launch.py'],
            output='screen',
            shell='True'),
        ExecuteProcess(
            name='START-JOYSTICK',
            cmd=['ros2', 'launch', 'rastreator_joystick', 'start.launch.py'],
            output='screen',
            shell='True'),
        ExecuteProcess(name='START-INTELrealsense',
                       cmd=[
                           'ros2', 'launch', 'rastreator_camera',
                           'intel_multicam.launch.py'
                       ],
                       output='screen',
                       shell='True')
    ])
Esempio n. 5
0
def test_execute_process_prefix_filter_no_match():
    lc = LaunchContext()
    lc._set_asyncio_loop(asyncio.get_event_loop())
    SetLaunchConfiguration('launch-prefix', 'time').visit(lc)
    assert len(lc.launch_configurations) == 1
    SetLaunchConfiguration('launch-prefix-filter', 'no-match').visit(lc)
    assert len(lc.launch_configurations) == 2

    test_process = ExecuteProcess(
        cmd=[sys.executable, '-c', "print('action')"], output='screen')

    test_process.execute(lc)
    assert 'time' not in test_process.process_details['cmd']
Esempio n. 6
0
def generate_launch_description():
    # Sim
    use_sim_time = LaunchConfiguration('use_sim_time', default='true')
    # Launch folder
    launch_file_dir = os.path.join(get_package_share_directory(pkg_name), dir_model)
    # Description folder (to get world)
    world = os.path.join(get_package_share_directory(pkg_name2), 
                     dir_world, 
                     world_file_name)
    #rviz
    rviz_file = os.path.join(get_package_share_directory(pkg_name2),
                        dir_rviz,
                        rviz_config)

    return LaunchDescription([

        IncludeLaunchDescription(
            PythonLaunchDescriptionSource([launch_file_dir, '/state_publisher.launch.py']),
            launch_arguments={'use_sim_time': use_sim_time}.items(),
        ),
        ExecuteProcess(
            name='START-SIM',
            cmd=['ros2', 'launch', 'rastreator_bringup', 'start_sim.launch.py'],
            output = 'screen',
            shell='True'
        ),
        ExecuteProcess(
            name='START-NAV2',
            cmd=['ros2', 'launch', 'rastreator_navigation2', 'start_navigation.launch.py'],
            output = 'screen',
            shell='True'
        ),
        Node(
        parameters=[get_package_share_directory("rastreator_navigation2") + '/param/mapper_stbox.yaml',
          {'use_sim_time': use_sim_time}],
        package='slam_toolbox',
        node_executable='async_slam_toolbox_node',
        name='slam_toolbox',
        output='screen'),

        Node(
            package='rviz2',
            node_executable='rviz2',
            node_name='rviz2',
            output='screen',
            arguments=['-d', rviz_file]
            )
    ])
Esempio n. 7
0
def generate_test_description():
    # Necessary to get real-time stdout from python processes:
    proc_env = os.environ.copy()
    proc_env['PYTHONUNBUFFERED'] = '1'

    dir_path = os.path.dirname(os.path.realpath(__file__))

    parameters_file = os.path.join(
        dir_path, 'system_config.yaml'
    )

    twist_mux = launch_ros.actions.Node(
        package='twist_mux', executable='twist_mux',
        parameters=[parameters_file], env=proc_env)

    publisher = ExecuteProcess(
        cmd=['ros2 topic pub /lock_1 std_msgs/Bool "data: False" -r 20'],
        shell=True, env=proc_env
    )

    # system_blackbox = launch_ros.actions.Node(
    # package='twist_mux', node_executable='system_blackbox.py', env=proc_env)

    return launch.LaunchDescription([
        twist_mux,
        publisher,
        # system_blackbox,
        # Start tests right away - no need to wait for anything
        launch_testing.actions.ReadyToTest(),
    ])
Esempio n. 8
0
def generate_launch_description():
    urdf = os.path.join(get_package_share_directory('robotiq_hande_gripper_description'), 'urdf', 'robotiq_140.urdf')
    install_dir = get_package_prefix('robotiq_hande_gripper_description')

    if 'GAZEBO_MODEL_PATH' in os.environ:
        os.environ['GAZEBO_MODEL_PATH'] =  os.environ['GAZEBO_MODEL_PATH'] + ':' + install_dir + '/share'
    else:
        os.environ['GAZEBO_MODEL_PATH'] =  install_dir + "/share"

    if 'GAZEBO_PLUGIN_PATH' in os.environ:
        os.environ['GAZEBO_PLUGIN_PATH'] = os.environ['GAZEBO_PLUGIN_PATH'] + ':' + install_dir + '/lib'
    else:
        os.environ['GAZEBO_PLUGIN_PATH'] = install_dir + '/lib'

    try:
        envs = {}
        for key in os.environ.__dict__["_data"]:
            key = key.decode("utf-8")
            if (key.isupper()):
                envs[key] = os.environ[key]
    except Exception as e:
        print("Error with Envs: " + str(e))
        return None

    ld = LaunchDescription([
        ExecuteProcess(
            cmd=['gazebo', '--verbose', '-s', 'libgazebo_ros_factory.so'], output='screen',
            env=envs
        ),
        Node(package='robot_state_publisher', node_executable='robot_state_publisher', output='screen', arguments=[urdf]),
        Node(package='robotiq_gazebo', node_executable='spawn_robotiq140.py', output='screen'),
    ])
    return ld
Esempio n. 9
0
def generate_launch_description():

    args = sys.argv[1:]
    if "--urdf" in args:
        urdfName = args[args.index("--urdf") + 1]
        if ("train" in urdfName) or ("run" in urdfName):
            urdfName = "reinforcement_learning/" + urdfName
    else:
        urdfName = 'mara_robot'

    urdf = os.path.join(get_package_share_directory('mara_description'),
                        'urdf/', urdfName + '.urdf')
    assert os.path.exists(urdf)

    install_dir = get_package_prefix('mara_gazebo_plugins')

    if 'GAZEBO_MODEL_PATH' in os.environ:
        os.environ['GAZEBO_MODEL_PATH'] = os.environ[
            'GAZEBO_MODEL_PATH'] + ':' + install_dir + '/share'
    else:
        os.environ['GAZEBO_MODEL_PATH'] = install_dir + "/share"

    if 'GAZEBO_PLUGIN_PATH' in os.environ:
        os.environ['GAZEBO_PLUGIN_PATH'] = os.environ[
            'GAZEBO_PLUGIN_PATH'] + ':' + install_dir + '/lib'
    else:
        os.environ['GAZEBO_PLUGIN_PATH'] = install_dir + '/lib'

    try:
        envs = {}
        for key in os.environ.__dict__["_data"]:
            key = key.decode("utf-8")
            if (key.isupper()):
                envs[key] = os.environ[key]
    except Exception as e:
        print("Error with Envs: " + str(e))
        return None

    ld = LaunchDescription([
        ExecuteProcess(
            cmd=['gazebo', '--verbose', '-s', 'libgazebo_ros_factory.so'],
            output='screen',
            env=envs),
        Node(package='robot_state_publisher',
             node_executable='robot_state_publisher',
             output='screen',
             arguments=[urdf]),
        Node(package='mara_utils_scripts',
             node_executable='spawn_mara.py',
             arguments=[urdf],
             output='screen'),
        Node(package='hros_cognition_mara_components',
             node_executable='hros_cognition_mara_components',
             output='screen',
             arguments=[
                 "-motors", install_dir +
                 "/share/hros_cognition_mara_components/motors.yaml", "sim"
             ])
    ])
    return ld
Esempio n. 10
0
def generate_launch_description():
    urdf = os.path.join(get_package_share_directory('mara_description'),
                        'urdf', 'mara_robot_camera_top.urdf')
    mara = get_package_share_directory('mara_gazebo_plugins')
    install_dir = get_package_prefix('mara_gazebo_plugins')
    print("plugins", install_dir)
    print("mara", mara)

    if 'GAZEBO_MODEL_PATH' in os.environ:
        os.environ['GAZEBO_MODEL_PATH'] = os.environ[
            'GAZEBO_MODEL_PATH'] + ':' + install_dir + 'share'
    else:
        os.environ['GAZEBO_MODEL_PATH'] = install_dir + "/share"

    if 'GAZEBO_PLUGIN_PATH' in os.environ:
        os.environ['GAZEBO_PLUGIN_PATH'] = os.environ[
            'GAZEBO_PLUGIN_PATH'] + ':' + install_dir + '/lib'
    else:
        os.environ['GAZEBO_PLUGIN_PATH'] = install_dir + '/lib'

    try:
        envs = {}
        for key in os.environ.__dict__["_data"]:
            key = key.decode("utf-8")
            if (key.isupper()):
                envs[key] = os.environ[key]
    except Exception as e:
        print("Error with Envs: " + str(e))
        return None

    ld = LaunchDescription([
        ExecuteProcess(
            cmd=['gazebo', '--verbose', '-s', 'libgazebo_ros_factory.so'],
            output='screen',
            env=envs),
        Node(package='robot_state_publisher',
             node_executable='robot_state_publisher',
             output='screen',
             arguments=[urdf]),
        Node(package='mara_utils_scripts',
             node_executable='spawn_entity.py',
             output='screen'),
        Node(package='hros_cognition_mara_components',
             node_executable='hros_cognition_mara_components',
             output='screen',
             arguments=[
                 "-motors", install_dir +
                 "/share/hros_cognition_mara_components/link_order.yaml"
             ]),
        Node(package='individual_trajectories_bridge',
             node_executable='individual_trajectories_bridge',
             output='screen',
             arguments=[
                 "-motors", install_dir +
                 "/share/individual_trajectories_bridge/motors.yaml"
             ])
    ])
    return ld
Esempio n. 11
0
 def generate_launch_description():
     return LaunchDescription([
         ExecuteProcess(cmd=[sys.executable, '-c', "print('action')"],
                        respawn=True,
                        respawn_delay=respawn_delay,
                        on_exit=on_exit_callback),
         TimerAction(period=shutdown_time,
                     actions=[Shutdown(reason='Timer expired')])
     ])
Esempio n. 12
0
def test_execute_process_with_env():
    """Test launching a process with an environment variable."""
    ld = LaunchDescription([
        ExecuteProcess(
            cmd=[sys.executable, 'TEST_PROCESS_WITH_ENV'],
            output='screen',
            env={'TEST_PROCESS_WITH_ENV': 'Hello World'},
        )
    ])
    ls = LaunchService()
    ls.include_launch_description(ld)
    assert 0 == ls.run()
Esempio n. 13
0
def test_execute_process_with_on_exit_behavior():
    """Test a process' on_exit callback and actions are processed."""
    def on_exit_callback(event, context):
        on_exit_callback.called = True

    on_exit_callback.called = False

    executable_with_on_exit_callback = ExecuteProcess(
        cmd=[sys.executable, '-c', "print('callback')"],
        output='screen',
        on_exit=on_exit_callback)
    assert len(executable_with_on_exit_callback.get_sub_entities()) == 0

    def on_exit_function(context):
        on_exit_function.called = True

    on_exit_function.called = False
    on_exit_action = OpaqueFunction(function=on_exit_function)
    executable_with_on_exit_action = ExecuteProcess(
        cmd=[sys.executable, '-c', "print('action')"],
        output='screen',
        on_exit=[on_exit_action])
    assert executable_with_on_exit_action.get_sub_entities() == [
        on_exit_action
    ]

    ld = LaunchDescription(
        [executable_with_on_exit_callback, executable_with_on_exit_action])
    ls = LaunchService()
    ls.include_launch_description(ld)
    assert 0 == ls.run()
    assert on_exit_callback.called
    assert on_exit_function.called
Esempio n. 14
0
def generate_launch_description():
    """Generate launch description."""
    test_params = os.path.join(
        get_package_share_directory('canopen_chain_node'),
        'test/config/chain_node_params.yaml'
    )

    chain_node = LifecycleNode(
        node_name='canopen_chain',
        package='canopen_chain_node',
        node_executable='manual_composition',
        output='screen',
        parameters=[
            test_params
        ]
    )

    ros2_web_bridge = ExecuteProcess(
        cmd=['node', '/opt/ros2-web-bridge/bin/rosbridge.js'],
        output='screen'
    )


    # Make the node take the 'configure' transition.
    emit_event_request_that_chain_node_does_configure_transition = EmitEvent(
        event=launch_ros.events.lifecycle.ChangeState(
            lifecycle_node_matcher=launch.events.matches_action(chain_node),
            transition_id=lifecycle_msgs.msg.Transition.TRANSITION_CONFIGURE,
        )
    )

    # When the node reaches the 'inactive' state, make it 'activate'
    register_event_handler_for_chain_node_reaches_inactive_state = launch.actions.RegisterEventHandler(  # noqa
      launch_ros.event_handlers.OnStateTransition(
        target_lifecycle_node=chain_node, goal_state='inactive',
        entities=[
         EmitEvent(event=launch_ros.events.lifecycle.ChangeState(
           lifecycle_node_matcher=launch.events.matches_action(chain_node),
           transition_id=lifecycle_msgs.msg.Transition.TRANSITION_ACTIVATE,
         )),
        ],
      )
    )
    
    ld = launch.LaunchDescription()
    # Register nodes and event handlers before starting 'configure' transition
    ld.add_action(register_event_handler_for_chain_node_reaches_inactive_state)
    ld.add_action(chain_node)
    ld.add_action(ros2_web_bridge)
    ld.add_action(emit_event_request_that_chain_node_does_configure_transition)

    return ld
Esempio n. 15
0
 def generate_launch_description():
     process_action = ExecuteProcess(
         cmd=[sys.executable, '-c', 'import signal; signal.pause()'],
         sigterm_timeout='1',  # shorten timeouts
         on_exit=on_exit)
     # Launch process and emit shutdown event as if
     # launch had received a SIGINT
     return LaunchDescription([
         process_action,
         RegisterEventHandler(event_handler=OnProcessStart(
             target_action=process_action,
             on_start=[
                 EmitEvent(
                     event=ShutdownEvent(reason='none', due_to_sigint=True))
             ]))
     ])
Esempio n. 16
0
def generate_launch_description():

    args = sys.argv[1:]

    # sdf_robobo = os.path.join(get_package_share_directory('robobo_gazebo'), 'models/robobo/model.sdf')
    # assert os.path.exists(sdf_robobo)

    install_dir = get_package_prefix('ros2_env')

    model_dir = os.path.join(get_package_share_directory('ros2_env'), 'models')

    world_path = os.path.join(get_package_share_directory('ros2_env'), 'worlds', 'my_world.world')

    if 'GAZEBO_MODEL_PATH' in os.environ:
        os.environ['GAZEBO_MODEL_PATH'] =  os.environ['GAZEBO_MODEL_PATH'] + ':' + model_dir
    else:
        os.environ['GAZEBO_MODEL_PATH'] = model_dir

    lib_dir = os.path.join(install_dir, 'lib')

    if 'GAZEBO_PLUGIN_PATH' in os.environ:
        os.environ['GAZEBO_PLUGIN_PATH'] = os.environ['GAZEBO_PLUGIN_PATH'] + ':' + lib_dir
    else:
        os.environ['GAZEBO_PLUGIN_PATH'] = os.path.join(install_dir, '/lib')

    # try:
    #     envs = {}
    #     for key in os.environ.__dict__["_data"]:
    #         key = key.decode("utf-8")
    #         if (key.isupper()):
    #             envs[key] = os.environ[key]
    # except Exception as e:
    #     print("Error with Envs: " + str(e))
    #     return None

    # robot_name = 'robobo'
    # robot_namespace = 'robobo'
    ld = LaunchDescription([
        ExecuteProcess(
            cmd=['gazebo', '--verbose', world_path], output='screen',
            # env=envs
        ),
        # Node(package='robobo_gazebo', node_executable='spawn_robobo.py', 
        #     arguments=[robot_name, robot_namespace, '0.0', '0.0', '2.0'], output='screen')
    ])
    return ld
Esempio n. 17
0
def generate_launch_description():
    urdf = os.path.join(get_package_share_directory('mara_description'),
                        'urdf', 'mara_robot_gripper_140.urdf')
    install_dir = get_package_prefix('mara_description')

    print("install_dir ", install_dir)

    if 'GAZEBO_MODEL_PATH' in os.environ:
        os.environ['GAZEBO_MODEL_PATH'] = os.environ[
            'GAZEBO_MODEL_PATH'] + ':' + install_dir + '/share'
    else:
        os.environ['GAZEBO_MODEL_PATH'] = install_dir + "/share"

    if 'GAZEBO_PLUGIN_PATH' in os.environ:
        os.environ['GAZEBO_PLUGIN_PATH'] = os.environ[
            'GAZEBO_PLUGIN_PATH'] + ':' + install_dir + '/lib'
    else:
        os.environ['GAZEBO_PLUGIN_PATH'] = install_dir + '/lib'

    try:
        envs = {}
        for key in os.environ.__dict__["_data"]:
            key = key.decode("utf-8")
            if (key.isupper()):
                envs[key] = os.environ[key]
    except Exception as e:
        print("Error with Envs: " + str(e))
        return None

    rviz_config_path = os.path.join(
        get_package_share_directory('mara_description'), 'rviz',
        'visualization.rviz')
    ld = LaunchDescription([
        ExecuteProcess(cmd=['rviz2', '-d', rviz_config_path],
                       output='screen',
                       env=envs),
        Node(package='robot_state_publisher',
             node_executable='robot_state_publisher',
             output='screen',
             arguments=[urdf]),
        Node(package='mara_description',
             node_executable='mara_state_publisher.py',
             output='screen'),
    ])
    return ld
Esempio n. 18
0
def test_execute_process_with_env(test_input, expected):
    """Test launching a process with an environment variable."""
    os.environ['TEST_CHANGE_CURRENT_ENV'] = '1'
    additional_env = {'TEST_PROCESS_WITH_ENV': 'Hello World'}
    executable = ExecuteProcess(cmd=[sys.executable, 'TEST_PROCESS_WITH_ENV'],
                                output='screen',
                                env=test_input,
                                additional_env=additional_env)
    ld = LaunchDescription([executable])
    ls = LaunchService()
    ls.include_launch_description(ld)
    assert 0 == ls.run()
    env = executable.process_details['env']
    assert env['TEST_PROCESS_WITH_ENV'] == 'Hello World'
    assert ('TEST_CHANGE_CURRENT_ENV' in env) is expected[0]
    if expected[0]:
        assert env['TEST_CHANGE_CURRENT_ENV'] == '1'
    assert ('TEST_NEW_ENV' in env) is expected[1]
    if expected[1]:
        assert env['TEST_NEW_ENV'] == '2'
Esempio n. 19
0
def generate_launch_description():
    #urdfName = 'robot_hand'
    urdfName = 'robot_hand_gazebo_plugin'
    urdf = os.path.join(get_package_share_directory('tm_grasp_description'),
                        'urdf/', urdfName + '.urdf')
    print("urdf is ")
    print(urdf)
    #assert os.path.exists(urdf)

    tm_grasp_description_install_dir = get_package_prefix(
        'tm_grasp_description')
    gripper_install_dir = get_package_prefix(
        'robotiq_2f_140_gripper_visualization')
    install_dir = get_package_prefix('tm_gazebo_plugin')
    add_gazebo_path(tm_grasp_description_install_dir)
    add_gazebo_path(gripper_install_dir)
    add_gazebo_path(install_dir)

    envs = {}
    print("a")
    for key in os.environ.__dict__["_data"]:
        key = key.decode("utf-8")
        if (key.isupper()):
            envs[key] = os.environ[key]
    print("b")
    ld = LaunchDescription([
        ExecuteProcess(
            cmd=['gazebo', '--verbose', '-s', 'libgazebo_ros_factory.so'],
            output='screen',
            env=envs),
        Node(package='robot_state_publisher',
             node_executable='robot_state_publisher',
             output='screen',
             arguments=[urdf]),
        Node(package='techman_robot_utility_scripts',
             node_executable='spawn_techman.py',
             arguments=[urdf],
             output='screen')
    ])
    return ld
Esempio n. 20
0
def generateLaunchDescription(gzclient, multiInstance, port):
    """
        Returns ROS2 LaunchDescription object.
    """
    try:
        envs = {}
        for key in os.environ.__dict__["_data"]:
            key = key.decode("utf-8")
            if key.isupper():
                envs[key] = os.environ[key]
    except BaseException as exception:
        print("Error with Envs: " + str(exception))
        return None

    # Gazebo visual interfaze. GUI/no GUI options.
    if gzclient:
        gazeboCmd = "gazebo"
    else:
        gazeboCmd = "gzserver"

    # Creation of ROS2 LaunchDescription obj.

    worldPath = os.path.join(os.path.dirname(gazeborlenv.__file__), 'worlds',
                             'test8.world')
    '''
    worldPath = os.path.join(os.path.dirname(gazeborlenv.__file__), 'worlds',
                             'empty.world')
                             '''

    launchDesc = LaunchDescription([
        ExecuteProcess(
            cmd=[gazeboCmd, '--verbose', '-s', 'libgazebo_ros_factory.so', '-s',
                 'libgazebo_ros_init.so', worldPath], output='screen', env=envs),
        Node(package='travel', node_executable='spawn_agent',
             output='screen'),
        Node(package='travel', node_executable='agent',
             output='screen')
    ])
    return launchDesc
Esempio n. 21
0
def generate_launch_description():
    """Generate launch description."""
    test_params = os.path.join(
        get_package_share_directory('canopen_chain_node'),
        'test/config/chain_node_params.yaml')

    chain_node = LifecycleNode(node_name='canopen_chain',
                               package='canopen_chain_node',
                               node_executable='manual_composition',
                               output='screen',
                               parameters=[test_params])

    ros2_web_bridge = ExecuteProcess(
        cmd=['node', '/opt/ros2-web-bridge/bin/rosbridge.js'], output='screen')

    ld = launch.LaunchDescription()
    ld.add_action(
        SetEnvironmentVariable('RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1'))
    ld.add_action(chain_node)
    ld.add_action(ros2_web_bridge)

    return ld
def generate_launch_description():
    use_sim_time = LaunchConfiguration('use_sim_time', default='true')
    realsense_prefix = get_package_share_directory('rastreator_navigation2')
    cartographer_config_dir = LaunchConfiguration('cartographer_config_dir',
                                                  default=os.path.join(
                                                      realsense_prefix,
                                                      'param'))
    configuration_basename = LaunchConfiguration(
        'configuration_basename', default='mapper_cartographer_lidar.lua')

    resolution = LaunchConfiguration('resolution', default='0.05')
    publish_period_sec = LaunchConfiguration('publish_period_sec',
                                             default='1.0')

    #rviz
    rviz_file = os.path.join(get_package_share_directory(pkg_name), dir_rviz,
                             rviz_config)

    return LaunchDescription([
        DeclareLaunchArgument('cartographer_config_dir',
                              default_value=cartographer_config_dir,
                              description='Full path to config file to load'),
        DeclareLaunchArgument('configuration_basename',
                              default_value=configuration_basename,
                              description='Name of lua file for cartographer'),
        DeclareLaunchArgument(
            'use_sim_time',
            default_value='false',
            description='Use simulation (Gazebo) clock if true'),
        Node(package='cartographer_ros',
             node_executable='cartographer_node',
             output='log',
             parameters=[{
                 'use_sim_time': use_sim_time
             }],
             arguments=[
                 '-configuration_directory', cartographer_config_dir,
                 '-configuration_basename', configuration_basename
             ]),
        DeclareLaunchArgument(
            'resolution',
            default_value=resolution,
            description=
            'Resolution of a grid cell in the published occupancy grid'),
        DeclareLaunchArgument('publish_period_sec',
                              default_value=publish_period_sec,
                              description='OccupancyGrid publishing period'),
        ExecuteProcess(name='START-SIM',
                       cmd=[
                           'ros2', 'launch', 'rastreator_bringup',
                           'start_sim.launch.py'
                       ],
                       output='screen',
                       shell='True'),
        Node(package='cartographer_ros',
             node_executable='occupancy_grid_node',
             node_name='occupancy_grid_node',
             parameters=[{
                 'use_sim_time': use_sim_time
             }],
             arguments=[
                 '-resolution', resolution, '-publish_period_sec',
                 publish_period_sec
             ]),
        Node(package='rviz2',
             node_executable='rviz2',
             node_name='rviz2',
             output='screen',
             arguments=['-d', rviz_file])
    ])
Esempio n. 23
0
def generateLaunchDescriptionMara(gzclient, realSpeed, multiInstance, port,
                                  urdf):
    """
        Returns ROS2 LaunchDescription object.
        Args:
            realSpeed: bool   True if RTF must be set to 1, False if RTF must be set to maximum.
    """
    installDir = get_package_prefix('mara_gazebo_plugins')

    if 'GAZEBO_MODEL_PATH' in os.environ:
        os.environ['GAZEBO_MODEL_PATH'] = os.environ['GAZEBO_MODEL_PATH'] + ':' + installDir \
        + '/share'
    else:
        os.environ['GAZEBO_MODEL_PATH'] = installDir + "/share"

    if 'GAZEBO_PLUGIN_PATH' in os.environ:
        os.environ['GAZEBO_PLUGIN_PATH'] = os.environ['GAZEBO_PLUGIN_PATH'] + ':' + installDir \
        + '/lib'
    else:
        os.environ['GAZEBO_PLUGIN_PATH'] = installDir + '/lib'

    if port != 11345:  # Default gazebo port
        os.environ["ROS_DOMAIN_ID"] = str(port)
        os.environ["GAZEBO_MASTER_URI"] = "http://localhost:" + str(port)
        print("******* Manual network segmentation *******")
        print("ROS_DOMAIN_ID=" + os.environ['ROS_DOMAIN_ID'])
        print("GAZEBO_MASTER_URI=" + os.environ['GAZEBO_MASTER_URI'])
        print("")
    elif multiInstance:
        # Exclusive network segmentation, which allows to launch multiple instances of ROS2+Gazebo
        networkParams = getExclusiveNetworkParameters()
        os.environ["ROS_DOMAIN_ID"] = networkParams.get('ros_domain_id')
        os.environ["GAZEBO_MASTER_URI"] = networkParams.get(
            'gazebo_master_uri')
        print("******* Exclusive network segmentation *******")
        print("ROS_DOMAIN_ID=" + networkParams.get('ros_domain_id'))
        print("GAZEBO_MASTER_URI=" + networkParams.get('gazebo_master_uri'))
        print("")

    try:
        envs = {}
        for key in os.environ.__dict__["_data"]:
            key = key.decode("utf-8")
            if key.isupper():
                envs[key] = os.environ[key]
    except BaseException as exception:
        print("Error with Envs: " + str(exception))
        return None

    # Gazebo visual interfaze. GUI/no GUI options.
    if gzclient:
        gazeboCmd = "gazebo"
    else:
        gazeboCmd = "gzserver"

    # Creation of ROS2 LaunchDescription obj.

    if realSpeed:
        worldPath = os.path.join(os.path.dirname(gym_gazebo2.__file__),
                                 'worlds', 'empty.world')
    else:
        worldPath = os.path.join(os.path.dirname(gym_gazebo2.__file__),
                                 'worlds', 'empty_speed_up.world')

    launchDesc = LaunchDescription([
        ExecuteProcess(
            cmd=[gazeboCmd, '-s', 'libgazebo_ros_factory.so', '-s',
                 'libgazebo_ros_init.so', worldPath], output='screen', env=envs),
        Node(package='mara_utils_scripts', node_executable='spawn_mara.py',
             arguments=[urdf],
             output='screen'),
        Node(package='hros_cognition_mara_components',
             node_executable='hros_cognition_mara_components', output='screen',
             arguments=["-motors", installDir \
             + "/share/hros_cognition_mara_components/motors.yaml", "sim"]),
        Node(package='mara_contact_publisher', node_executable='mara_contact_publisher',
             output='screen')
    ])
    return launchDesc