Exemplo n.º 1
0
def test_set_and_unset_environment_variable_execute():
    """Test the execute() of the SetEnvironmentVariable and UnsetEnvironmentVariable classes."""
    lc1 = LaunchContext()

    # can set and overwrite environment variables
    if 'NONEXISTENT_KEY' in os.environ:
        del os.environ['NONEXISTENT_KEY']
    assert os.environ.get('NONEXISTENT_KEY') is None
    SetEnvironmentVariable('NONEXISTENT_KEY', 'value').visit(lc1)
    assert os.environ.get('NONEXISTENT_KEY') == 'value'
    SetEnvironmentVariable('NONEXISTENT_KEY', 'ANOTHER_NONEXISTENT_KEY').visit(lc1)
    assert os.environ.get('NONEXISTENT_KEY') == 'ANOTHER_NONEXISTENT_KEY'

    # can unset environment variables
    if 'ANOTHER_NONEXISTENT_KEY' in os.environ:
        del os.environ['ANOTHER_NONEXISTENT_KEY']
    assert os.environ.get('ANOTHER_NONEXISTENT_KEY') is None
    SetEnvironmentVariable('ANOTHER_NONEXISTENT_KEY', 'some value').visit(lc1)
    assert os.environ.get('ANOTHER_NONEXISTENT_KEY') == 'some value'
    UnsetEnvironmentVariable('ANOTHER_NONEXISTENT_KEY').visit(lc1)
    assert os.environ.get('ANOTHER_NONEXISTENT_KEY') is None

    # set and unset with substitutions
    assert os.environ.get('ANOTHER_NONEXISTENT_KEY') is None
    SetEnvironmentVariable(
        'ANOTHER_NONEXISTENT_KEY',
        EnvironmentVariable('NONEXISTENT_KEY')).visit(lc1)
    assert os.environ.get('ANOTHER_NONEXISTENT_KEY') == 'ANOTHER_NONEXISTENT_KEY'
    UnsetEnvironmentVariable(EnvironmentVariable('NONEXISTENT_KEY')).visit(lc1)
    assert os.environ.get('ANOTHER_NONEXISTENT_KEY') is None

    # cleanup environment variables
    if 'NONEXISTENT_KEY' in os.environ:
        del os.environ['NONEXISTENT_KEY']
def generate_launch_description():
    parameters_file_dir = pathlib.Path(__file__).resolve().parent
    parameters_file_path = parameters_file_dir /'test_ukf_localization_node_bag3.yaml'    
    os.environ['FILE_PATH'] = str(parameters_file_dir)
    return LaunchDescription([
       launch.actions.DeclareLaunchArgument(
            'output_final_position',
            default_value='false'),
        launch.actions.DeclareLaunchArgument(
            'output_location',
	    default_value='ukf3.txt'),
		
	#*****test_ukf_localization_node_bag3.test***** 
	launch_ros.actions.Node(
            package='robot_localization', node_executable='ukf_node', node_name='test_ukf_localization_node_bag3_ukf',
	    output='screen',
	    parameters=[
                parameters_file_path,
                str(parameters_file_path),
                [EnvironmentVariable(name='FILE_PATH'), os.sep, 'test_ukf_localization_node_bag3.yaml'],
           ],
           ),
        launch_ros.actions.Node(
            package='robot_localization', node_executable='test_ukf_localization_node_bag3', node_name='test_ukf_localization_node_bag3_pose',
            output='screen',
	parameters=[
                parameters_file_path,
                str(parameters_file_path),
                [EnvironmentVariable(name='FILE_PATH'), os.sep, 'test_ukf_localization_node_bag3.yaml'],
        ],
	),
])
Exemplo n.º 3
0
    def test_launch_node_with_parameter_dict(self):
        """Test launching a node with parameters specified in a dictionary."""
        os.environ['PARAM1_VALUE'] = 'param1_value'
        os.environ['PARAM2'] = 'param2'
        node_action = self._create_node(
            parameters=[{
                'param1': EnvironmentVariable(name='PARAM1_VALUE'),
                EnvironmentVariable(name='PARAM2'): (EnvironmentVariable(name='PARAM2'), '_value'),
                'param_group1': {
                    'list_params': [1.2, 3.4],
                    'param_group2': {
                        (EnvironmentVariable('PARAM2'), '_values'): ['param2_value'],
                    }
                }
            }],
        )
        self._assert_launch_no_errors([node_action])

        # Check the expanded parameters (will be written to a file).
        expanded_parameter_files = node_action._Node__expanded_parameter_files
        assert len(expanded_parameter_files) == 1
        with open(expanded_parameter_files[0], 'r') as h:
            expanded_parameters_dict = yaml.load(h)
            assert expanded_parameters_dict == {
                '/my_ns': {
                    'my_node': {
                        'ros__parameters': {
                            'param1': 'param1_value',
                            'param2': 'param2_value',
                            'param_group1.list_params': (1.2, 3.4),
                            'param_group1.param_group2.param2_values': ('param2_value',),
                        }
                    }
                }
            }
def test_append_environment_variable_execute():
    """Test the execute() of the AppendEnvironmentVariable class."""
    lc1 = LaunchContext()

    # Sets environment variable if it does not exist
    if 'NONEXISTENT_KEY' in os.environ:
        del os.environ['NONEXISTENT_KEY']
    assert os.environ.get('NONEXISTENT_KEY') is None
    AppendEnvironmentVariable('NONEXISTENT_KEY', 'value').visit(lc1)
    assert os.environ.get('NONEXISTENT_KEY') == 'value'
    # Same result if prepending is enabled
    del os.environ['NONEXISTENT_KEY']
    AppendEnvironmentVariable('NONEXISTENT_KEY', 'value', prepend=True).visit(lc1)
    assert os.environ.get('NONEXISTENT_KEY') == 'value'

    # Appends to environment variable if it does exist
    AppendEnvironmentVariable('NONEXISTENT_KEY', 'another value').visit(lc1)
    assert os.environ.get('NONEXISTENT_KEY') == 'value' + os.pathsep + 'another value'

    # Prepends to environment variable if it does exist and option is enabled
    AppendEnvironmentVariable('NONEXISTENT_KEY', 'some value', prepend=True).visit(lc1)
    assert os.environ.get('NONEXISTENT_KEY') == \
        'some value' + os.pathsep + 'value' + os.pathsep + 'another value'

    # Can use an optional separator
    AppendEnvironmentVariable('NONEXISTENT_KEY', 'other value', separator='|').visit(lc1)
    assert os.environ.get('NONEXISTENT_KEY') == \
        'some value' + os.pathsep + 'value' + os.pathsep + 'another value' + '|' + 'other value'

    # Appends/prepends with substitutions
    assert os.environ.get('ANOTHER_NONEXISTENT_KEY') is None
    AppendEnvironmentVariable(
        'ANOTHER_NONEXISTENT_KEY',
        EnvironmentVariable('NONEXISTENT_KEY'),
        prepend=TextSubstitution(text='false')).visit(lc1)
    assert os.environ.get('ANOTHER_NONEXISTENT_KEY') == \
        'some value' + os.pathsep + 'value' + os.pathsep + 'another value' + '|' + 'other value'

    os.environ['ANOTHER_NONEXISTENT_KEY'] = 'abc'
    os.environ['SOME_SEPARATOR'] = '//'
    AppendEnvironmentVariable(
        'ANOTHER_NONEXISTENT_KEY',
        TextSubstitution(text='def'),
        separator=EnvironmentVariable('SOME_SEPARATOR'),
        prepend=TextSubstitution(text='yes')).visit(lc1)
    assert os.environ.get('ANOTHER_NONEXISTENT_KEY') == 'def' + '//' + 'abc'

    # Cleanup environment variables
    del os.environ['NONEXISTENT_KEY']
    del os.environ['ANOTHER_NONEXISTENT_KEY']
    del os.environ['SOME_SEPARATOR']
Exemplo n.º 5
0
    def test_launch_node_with_parameter_dict(self):
        """Test launching a node with parameters specified in a dictionary."""
        os.environ['PARAM1_VALUE'] = 'param1_value'
        os.environ['PARAM2'] = 'param2'
        os.environ['PARAM4_INT'] = '100'
        node_action = self._create_node(parameters=[{
            'param1':
            EnvironmentVariable(name='PARAM1_VALUE'),
            EnvironmentVariable(name='PARAM2'):
            (EnvironmentVariable(name='PARAM2'), '_value'),
            'param_group1': {
                'list_params': [1.2, 3.4],
                'param_group2': {
                    (EnvironmentVariable('PARAM2'), '_values'):
                    ['param2_value'],
                }
            },
            'param3':
            '',
            'param4':
            ParameterValue(EnvironmentVariable(name='PARAM4_INT'),
                           value_type=int),
        }], )
        self._assert_launch_no_errors([node_action])

        # Check the expanded parameters (will be written to a file).
        expanded_parameter_arguments = node_action._Node__expanded_parameter_arguments
        assert len(expanded_parameter_arguments) == 1
        file_path, is_file = expanded_parameter_arguments[0]
        assert is_file
        with open(file_path, 'r') as h:
            expanded_parameters_dict = yaml.load(h, Loader=yaml.FullLoader)
            assert expanded_parameters_dict == {
                '/my_ns/my_node': {
                    'ros__parameters': {
                        'param1':
                        'param1_value',
                        'param2':
                        'param2_value',
                        'param3':
                        '',
                        'param4':
                        100,
                        'param_group1.list_params': (1.2, 3.4),
                        'param_group1.param_group2.param2_values':
                        ('param2_value', ),
                    }
                }
            }
def generate_launch_description():

    parameters_file_dir = pathlib.Path(__file__).resolve().parent
    parameters_file_path = parameters_file_dir / 'test_ekf_localization_node_bag2.yaml'
    os.environ['FILE_PATH'] = str(parameters_file_dir)

    ekf_node = launch_ros.actions.Node(
        package='robot_localization',
        node_executable='ekf_node',
        node_name='test_ekf_localization_node_bag2_ekf',
        output='screen',
        parameters=[
            parameters_file_path,
            str(parameters_file_path),
            [
                EnvironmentVariable(name='FILE_PATH'), os.sep,
                'test_ekf_localization_node_bag2.yaml'
            ],
        ],
    )

    test_ekf_localization_node_bag2 = launch_ros.actions.Node(
        package='robot_localization',
        node_executable='test_ekf_localization_node_bag2',
        node_name='test_ekf_localization_node_bag2_pose',
        output='screen',
        parameters=[
            parameters_file_path,
            str(parameters_file_path),
            [
                EnvironmentVariable(name='FILE_PATH'), os.sep,
                'test_ekf_localization_node_bag2.yaml'
            ],
        ],
    )

    return LaunchDescription([
        launch.actions.DeclareLaunchArgument('output_final_position',
                                             default_value='False'),
        launch.actions.DeclareLaunchArgument('output_location',
                                             default_value='ekf2.txt'),
        ekf_node,
        test_ekf_localization_node_bag2,
        launch.actions.
        RegisterEventHandler(event_handler=launch.event_handlers.OnProcessExit(
            target_action=test_ekf_localization_node_bag2,
            on_exit=[launch.actions.EmitEvent(event=launch.events.Shutdown())],
        )),
    ])
def test_unset_nonexistent_key():
    """Test that the UnsetEnvironmentVariable class doesn't raise an exception."""
    lc1 = LaunchContext()

    assert os.environ.get('ANOTHER_NONEXISTENT_KEY') is None
    UnsetEnvironmentVariable(EnvironmentVariable('NONEXISTENT_KEY')).visit(lc1)
    assert os.environ.get('ANOTHER_NONEXISTENT_KEY') is None
Exemplo n.º 8
0
def generate_launch_description():

    # Currently the output flag doesn't append argument as prefix, but uses the argument as the full path instead
    # The workaround is copied from the rosbag2 source code whereby we give the user the ability to put a directory
    # as the prefix path to the timestamped folder
    output_dir = datetime.now().strftime('rosbag2_%Y_%m_%d-%H_%M_%S')

    # Launch arguments
    launch_arg_rosbag_topics = DeclareLaunchArgument('topics',
                                                     default_value='-a')
    launch_arg_rosbag_output = DeclareLaunchArgument(
        'output_prefix',
        default_value=[EnvironmentVariable('HOME'), '/rosbags/'])

    # rosbag2 can only be run as an executable, not node action
    process_rosbag_record = ExecuteProcess(
        cmd=[
            'ros2', 'bag', 'record',
            LaunchConfiguration('topics'), '-o',
            [LaunchConfiguration('output_prefix'), output_dir]
        ],
        # cmd=['ros2', 'bag', 'record', LaunchConfiguration('topics')],
        output='screen')

    return LaunchDescription([
        launch_arg_rosbag_topics, launch_arg_rosbag_output,
        process_rosbag_record
    ])
Exemplo n.º 9
0
    def test_launch_node_with_parameter_descriptions(self):
        """Test launching a node with parameters specified in a dictionary."""
        os.environ['PARAM1_VALUE'] = 'param1_value'
        os.environ['PARAM2'] = 'param2'
        node_action = self._create_node(parameters=[
            Parameter(
                name='param1',
                value=EnvironmentVariable(name='PARAM1_VALUE'),
                value_type=str,
            ),
            Parameter(
                name=EnvironmentVariable(name='PARAM2'),
                value=[[EnvironmentVariable(name='PARAM2')], '_value'],
                value_type=List[str],
            ),
            Parameter(
                name='param_group1.list_params',
                value=[1.2, 3.4],
            ),
            Parameter(
                name=[
                    'param_group1.param_group2.',
                    EnvironmentVariable('PARAM2'), '_values'
                ],
                value=['param2_value'],
            ),
            Parameter(
                name='param3',
                value='',
            ),
        ], )
        self._assert_launch_no_errors([node_action])

        expanded_parameter_arguments = node_action._Node__expanded_parameter_arguments
        assert len(expanded_parameter_arguments) == 5
        parameters = []
        for item, is_file in expanded_parameter_arguments:
            assert not is_file
            name, value = item.split(':=')
            parameters.append((name, yaml.safe_load(value)))
        assert parameters == [
            ('param1', 'param1_value'),
            ('param2', ['param2', '_value']),
            ('param_group1.list_params', [1.2, 3.4]),
            ('param_group1.param_group2.param2_values', ['param2_value']),
            ('param3', ''),
        ]
Exemplo n.º 10
0
    def test_action_substitutions(self) -> None:
        self.assertIsNone(os.environ.get('LD_PRELOAD'))
        tmpdir = tempfile.mkdtemp(
            prefix='TestTraceAction__test_action_substitutions')

        self.assertIsNone(os.environ.get('TestTraceAction__event_ust', None))
        os.environ['TestTraceAction__event_ust'] = 'ros2:*'
        self.assertIsNone(
            os.environ.get('TestTraceAction__context_field', None))
        os.environ['TestTraceAction__context_field'] = 'vpid'

        session_name_arg = DeclareLaunchArgument(
            'session-name',
            default_value='my-session-name',
            description='the session name',
        )
        action = Trace(
            session_name=LaunchConfiguration(session_name_arg.name),
            base_path=TextSubstitution(text=tmpdir),
            events_kernel=[],
            events_ust=[
                EnvironmentVariable(name='TestTraceAction__event_ust'),
                TextSubstitution(text='*'),
            ],
            context_fields={
                'kernel': [],
                'userspace': [
                    EnvironmentVariable(name='TestTraceAction__context_field'),
                    TextSubstitution(text='vtid'),
                ],
            },
        )
        self._assert_launch_no_errors([session_name_arg, action])
        self._check_trace_action(action, tmpdir)

        self.assertDictEqual(
            action.context_fields,
            {
                'kernel': [],
                'userspace': ['vpid', 'vtid'],
            },
        )

        shutil.rmtree(tmpdir)
        del os.environ['TestTraceAction__event_ust']
        del os.environ['TestTraceAction__context_field']
        del os.environ['LD_PRELOAD']
Exemplo n.º 11
0
def generate_launch_description():
    parameters_file_dir = pathlib.Path(__file__).resolve().parent
    parameters_file_path = parameters_file_dir / 'test_ekf_localization_node_bag1.yaml'
    os.environ['FILE_PATH'] = str(parameters_file_dir)
    return LaunchDescription([
        launch.actions.DeclareLaunchArgument('output_final_position',
                                             default_value='false'),
        launch.actions.DeclareLaunchArgument('output_location',
                                             default_value='ekf1.txt'),

        #launch_ros.actions.Node(
        #   package='tf2_ros', node_executable='static_transform_publisher',node_name='bl_imu', output='screen',
        #  arguments=['0', '-0.3', '0.52', '-1.570796327', '0', '1.570796327', 'base_link', 'imu_link']
        #),
        launch_ros.actions.Node(
            package='robot_localization',
            executable='ekf_node',
            name='test_ekf_localization_node_bag1_ekf',
            output='screen',
            parameters=[
                parameters_file_path,
                str(parameters_file_path),
                [
                    EnvironmentVariable(name='FILE_PATH'), os.sep,
                    'test_ekf_localization_node_bag1.yaml'
                ],
            ],
        ),
        launch_ros.actions.Node(
            package='robot_localization',
            executable='test_ekf_localization_node_bag1',
            name='test_ekf_localization_node_bag1_pose',
            output='screen',
            arguments=['--time-limit', '10'],
            parameters=[
                parameters_file_path,
                str(parameters_file_path),
                [
                    EnvironmentVariable(name='FILE_PATH'), os.sep,
                    'test_ekf_localization_node_bag1.yaml'
                ],
            ],
        ),
    ])
def generate_launch_description():
    parameters_file_dir = pathlib.Path(__file__).resolve().parent
    parameters_file_path = parameters_file_dir / 'test_filter_base_diagnostics_timestamps.yaml'
    os.environ['FILE_PATH'] = str(parameters_file_dir)

    #*****test_filter_base_diagnostics_timestamps.test*****
    se_node = launch_ros.actions.Node(
        package='robot_localization',
        node_executable='se_node',
        node_name='ekf_localization',
        output='screen',
        parameters=[
            parameters_file_path,
            str(parameters_file_path),
            [
                EnvironmentVariable(name='FILE_PATH'), os.sep,
                'test_filter_base_diagnostics_timestamps.yaml'
            ],
        ],
    )

    test_filter_base_diagnostics_timestamps = launch_ros.actions.Node(
        package='robot_localization',
        node_executable='test_filter_base_diagnostics_timestamps',
        node_name='test_filter_base_diagnostics',
        output='screen',
        parameters=[
            parameters_file_path,
            str(parameters_file_path),
            [
                EnvironmentVariable(name='FILE_PATH'), os.sep,
                'test_filter_base_diagnostics_timestamps.yaml'
            ],
        ],
    )
    return LaunchDescription([
        se_node,
        test_filter_base_diagnostics_timestamps,
        launch.actions.
        RegisterEventHandler(event_handler=launch.event_handlers.OnProcessExit(
            target_action=test_filter_base_diagnostics_timestamps,
            on_exit=[launch.actions.EmitEvent(event=launch.events.Shutdown())],
        )),
    ])
Exemplo n.º 13
0
    def test_launch_node_with_remappings(self):
        """Test launching a node with remappings."""
        # Pass remapping rules to node in a variety of forms.
        # It is redundant to pass the same rule, but the goal is to test different parameter types.
        os.environ['TOPIC_NAME'] = 'chatter'
        topic_prefix = 'new_'
        node_action = self._create_node(remappings=[
            ('chatter', 'new_chatter'),
            (EnvironmentVariable(name='TOPIC_NAME'),
             [topic_prefix,
              EnvironmentVariable(name='TOPIC_NAME')])
        ], )
        self._assert_launch_no_errors([node_action])

        # Check the expanded parameters.
        expanded_remappings = node_action._Node__expanded_remappings
        assert len(expanded_remappings) == 2
        for i in range(2):
            assert expanded_remappings[i] == ('chatter', 'new_chatter')
Exemplo n.º 14
0
def generate_launch_description() -> launch.LaunchDescription:
    """
    Launch file to launch rqt input device.
    :argument: use_sim_time, whether the node should use the simulation time as published on the /clock topic.
    :argument: ping_safety_node, whether the node should regularly send an Alive message for the safety node.
    """
    layout_file = [
        PathJoinSubstitution([
            get_package_share_directory("march_rqt_input_device"),
            "config",
            LaunchConfiguration("layout"),
        ]),
        ".json",
    ]
    return launch.LaunchDescription([
        DeclareLaunchArgument(
            name="node_prefix",
            default_value=[EnvironmentVariable("USER"), "_"],
            description="Prefix for node names",
        ),
        DeclareLaunchArgument(
            name="ping_safety_node",
            default_value="True",
            description="Whether to ping the safety node",
        ),
        DeclareLaunchArgument(
            name="use_sim_time",
            default_value="False",
            description="Whether to use simulation time",
        ),
        DeclareLaunchArgument(
            name="layout",
            default_value="training",
            description=
            "Layout .json file to use. Must be in the config directory.",
        ),
        Node(
            package="march_rqt_input_device",
            executable="input_device",
            output="screen",
            name="input_device",
            namespace="march",
            parameters=[
                {
                    "use_sim_time": LaunchConfiguration("use_sim_time")
                },
                {
                    "ping_safety_node": LaunchConfiguration("ping_safety_node")
                },
                {
                    "layout_file": layout_file
                },
            ],
        ),
    ])
def generate_launch_description():
    parameters_file_dir = pathlib.Path(__file__).resolve().parent
    parameters_file_path = parameters_file_dir / 'test_laser_assembler.yaml'
    os.environ['FILE_PATH'] = str(parameters_file_dir)
    os.environ['TOPIC_NAME'] = 'scan'
    topic_prefix = 'dummy_'

    dummy_scan_producer = launch_ros.actions.Node(
        package='laser_assembler', node_executable='dummy_scan_producer', output='screen')

    laser_scan_assembler = launch_ros.actions.Node(
        package='laser_assembler', node_executable='laser_scan_assembler',
        output='screen',
        remappings=[
            ('scan', 'dummy_scan'),
            (EnvironmentVariable(name='TOPIC_NAME'), [
                topic_prefix, EnvironmentVariable(name='TOPIC_NAME')])
        ],
        parameters=[
            parameters_file_path,
            str(parameters_file_path),
            [EnvironmentVariable(name='FILE_PATH'), os.sep, 'test_laser_assembler.yaml'],
        ])

    test_laser_assembler = launch_ros.actions.Node(
        package='laser_assembler', node_executable='test_assembler',
        output='screen'
    )

    return LaunchDescription([
        launch.actions.DeclareLaunchArgument(
            'output_final_position',
            default_value='false'),
        dummy_scan_producer,
        laser_scan_assembler,
        test_laser_assembler,
        launch.actions.RegisterEventHandler(
            event_handler=launch.event_handlers.OnProcessExit(
                target_action=test_laser_assembler,
                on_exit=[launch.actions.EmitEvent(event=launch.events.Shutdown())],
            )),
    ])
Exemplo n.º 16
0
def test_substituted_properties():
    os.environ['EXECUTABLE_NAME'] = 'name'
    os.environ['EXECUTABLE_CWD'] = 'cwd'
    os.environ['EXECUTABLE_ENVVAR'] = 'var'
    os.environ['EXECUTABLE_ENVVAL'] = 'value'
    name = EnvironmentVariable('EXECUTABLE_NAME')
    cwd = EnvironmentVariable('EXECUTABLE_CWD')
    env = {
        EnvironmentVariable('EXECUTABLE_ENVVAR'):
        EnvironmentVariable('EXECUTABLE_ENVVAL')
    }
    exe = Executable(cmd=['test'], name=name, cwd=cwd, env=env)
    exe.prepare(LaunchContext(), None)
    assert exe.final_name.startswith('name')
    assert exe.final_cwd == 'cwd'
    assert exe.final_env == {'var': 'value'}
    del os.environ['EXECUTABLE_NAME']
    del os.environ['EXECUTABLE_CWD']
    del os.environ['EXECUTABLE_ENVVAR']
    del os.environ['EXECUTABLE_ENVVAL']
Exemplo n.º 17
0
def generate_launch_description():
    #TODO: modify the path and finish .yaml .rviz file
    para_dir = os.path.join(get_package_share_directory('object_tracker'),
                            'config', 'para_track.yaml')
    rviz_config_dir = os.path.join(
        get_package_share_directory('object_tracker'), 'config',
        'default.rviz')

    return LaunchDescription([
        DeclareLaunchArgument('node_prefix',
                              default_value=[EnvironmentVariable("USER"), '_'],
                              description='Prefix for node names'),
        Node(
            package='ibeo_8l_client',
            node_namespace='ibeo_8l_client',
            node_executable='ibeo_live',
            node_name='ibeo_live',
            parameters=[para_dir],
            remappings=None,
            arguments=None,
            output='screen',
        ),
        Node(
            package='ibeo_8l_client',
            node_namespace='ibeo_8l_client',
            node_executable='obj_visualization',
            node_name='obj_visualization',
            parameters=[para_dir],
            remappings=None,
            arguments=None,
            output='screen',
        ),
        Node(
            package='rviz2',
            node_namespace='rviz2',
            node_executable='rviz2',
            node_name=[LaunchConfiguration("node_prefix"), 'rviz2'],
            parameters=None,
            remappings=None,
            arguments=['-d', rviz_config_dir],
            output='screen',
        ),
        Node(
            package='object_tracker',
            node_namespace='object_tracker',
            node_executable='object_tracker',
            node_name='object_tracker',
            parameters=[para_dir],
            remappings=None,
            arguments=None,
            output='screen',
        )
    ])
Exemplo n.º 18
0
def generate_launch_description():
    para_dir = os.path.join(get_package_share_directory('ibeo_8l_client'),
                            'config', 'para_file_sim.yaml')
    rviz_config_dir = os.path.join(
        get_package_share_directory('ibeo_8l_client'), 'config',
        'default.rviz')

    return LaunchDescription([
        DeclareLaunchArgument('node_prefix',
                              default_value=[EnvironmentVariable("USER"), '_'],
                              description='Prefix for node names'),
        Node(
            package='ibeo_8l_client',
            node_namespace='ibeo_8l_client',
            node_executable='ibeo_file_sim',
            # node_name=[launch.substitutions.LaunchConfiguration('node_prefix'), 'ibeo_file_sim'],
            node_name='ibeo_file_sim',
            parameters=[para_dir],
            remappings=None,
            arguments=None,
            output='screen',
        ),
        Node(
            package='ibeo_8l_client',
            node_namespace='ibeo_8l_client',
            node_executable='obj_visualization',
            # node_name=[LaunchConfiguration("node_prefix"), 'obj_visualization'],
            node_name='obj_visualization',
            parameters=[para_dir],
            # parameters=None,
            remappings=None,
            arguments=None,
            output='screen',
        ),
        Node(
            package='rviz2',
            node_namespace='rviz2',
            node_executable='rviz2',
            node_name=[LaunchConfiguration("node_prefix"), 'rviz2'],
            parameters=None,
            remappings=None,
            arguments=['-d', rviz_config_dir],
            output='screen',
        )
    ])
def generate_launch_description():
    parameters_file_dir = pathlib.Path(__file__).resolve().parent
    parameters_file_path = parameters_file_dir / 'test_filter_base_diagnostics_timestamps.yaml'    
    os.environ['FILE_PATH'] = str(parameters_file_dir)

    ekf_node = launch_ros.actions.Node(
        package='robot_localization',
        node_executable='ekf_node',
        node_name='test_filter_base_diagnostics_timestamps',
        output='screen',
        parameters=[
        parameters_file_path,
        str(parameters_file_path),
        [EnvironmentVariable(name='FILE_PATH'), os.sep, 'test_filter_base_diagnostics_timestamps.yaml'],
       ],)

    return LaunchDescription([
        ekf_node,
    ])
Exemplo n.º 20
0
    def test_launch_node_with_parameter_files(self):
        """Test launching a node with parameters specified in yaml files."""
        parameters_file_dir = pathlib.Path(__file__).resolve().parent
        parameters_file_path = parameters_file_dir / 'example_parameters.yaml'
        # Pass parameter files to node in a variety of forms.
        # It is redundant to pass the same file, but the goal is to test different parameter types.
        os.environ['FILE_PATH'] = str(parameters_file_dir)
        node_action = self._create_node(
            parameters=[
                parameters_file_path,
                str(parameters_file_path),
                [EnvironmentVariable(name='FILE_PATH'), os.sep, 'example_parameters.yaml'],
            ],
        )
        self._assert_launch_no_errors([node_action])

        # Check the expanded parameters.
        expanded_parameter_files = node_action._Node__expanded_parameter_files
        assert len(expanded_parameter_files) == 3
        for i in range(3):
            assert expanded_parameter_files[i] == str(parameters_file_path)
def generate_launch_description():
    parameters_file_dir = pathlib.Path(__file__).resolve().parent
    parameters_file_path = parameters_file_dir / 'test_ukf_localization_node_interfaces.yaml'
    os.environ['FILE_PATH'] = str(parameters_file_dir)

    #*****test_ukf_localization_node_interfaces.test*****
    ukf_node = launch_ros.actions.Node(
        package='robot_localization',
        node_executable='ukf_node',
        node_name='test_ukf_localization_node_interfaces_ukf',
        output='screen',
        parameters=[
            parameters_file_path,
            str(parameters_file_path),
            [
                EnvironmentVariable(name='FILE_PATH'), os.sep,
                'test_ukf_localization_node_interfaces.yaml'
            ],
        ],
    )

    return LaunchDescription([
        ukf_node,
    ])
Exemplo n.º 22
0
def test_this_launch_file_path():
    if 'MY_ENVIRONMENT_VARIABLE' in os.environ:
        del os.environ['MY_ENVIRONMENT_VARIABLE']
    lc = LaunchContext()
    sub1 = EnvironmentVariable('MY_ENVIRONMENT_VARIABLE')
    with pytest.raises(SubstitutionFailure) as ex:
        sub1.perform(lc)
    ex.match("environment variable 'MY_ENVIRONMENT_VARIABLE' does not exist")

    sub2 = EnvironmentVariable('MY_ENVIRONMENT_VARIABLE', default_value='')
    assert '' == sub2.perform(lc)

    sub3 = EnvironmentVariable('MY_ENVIRONMENT_VARIABLE', default_value='MY_DEFAULT_VALUE')
    assert 'MY_DEFAULT_VALUE' == sub3.perform(lc)

    SetEnvironmentVariable('MY_ENVIRONMENT_VARIABLE', 'SOME_VALUE').visit(lc)
    assert 'SOME_VALUE' == sub1.perform(lc)
    assert 'SOME_VALUE' == sub2.perform(lc)
    assert 'SOME_VALUE' == sub3.perform(lc)
    del os.environ['MY_ENVIRONMENT_VARIABLE']
Exemplo n.º 23
0
def generate_launch_description():

    ld = LaunchDescription()

    world_arg = DeclareLaunchArgument(
            'world',
            default_value='empty.world',
            description='Gazebo world file'
    )

    headless_arg = DeclareLaunchArgument(
            'headless',
            default_value='false',
            description="Set to 'true' to run gazebo headless"
    )

    # We need to add the models and worlds directories to env so gazebo can find them
    triton_gazebo_dir = get_package_share_directory('triton_gazebo')

    gmp = 'GAZEBO_MODEL_PATH'
    add_model_path = SetEnvironmentVariable(
        name=gmp, 
        value=[
            EnvironmentVariable(gmp), 
            os.pathsep + os.path.join(triton_gazebo_dir, 'gazebo', 'models')
        ]
    )

    grp = 'GAZEBO_RESOURCE_PATH'
    add_resource_path = SetEnvironmentVariable(
        name=grp, 
        value=[
            EnvironmentVariable(grp), 
            os.pathsep + os.path.join(triton_gazebo_dir, 'gazebo')
        ]
    )

    gazebo_server = IncludeLaunchDescription(
        launch_description_source=PythonLaunchDescriptionSource(
            os.path.join(get_package_share_directory('gazebo_ros'), 
            'launch', 'gzserver.launch.py')
        ),
        launch_arguments={
            'world': ['worlds/', LaunchConfiguration('world')],
            'verbose': 'true'
            }.items()
    )

    gazebo_client = IncludeLaunchDescription(
        launch_description_source=PythonLaunchDescriptionSource(
            os.path.join(get_package_share_directory('gazebo_ros'), 
            'launch', 'gzclient.launch.py')
        ),
        condition=UnlessCondition(LaunchConfiguration('headless')),
    )

    ld.add_action(world_arg)
    ld.add_action(headless_arg)
    ld.add_action(add_model_path)
    ld.add_action(add_resource_path)
    ld.add_action(gazebo_server)
    ld.add_action(gazebo_client)
    return ld