def launch_pkg_command(self, arguments, **kwargs): pkg_command_action = ExecuteProcess( cmd=['ros2', 'pkg', *arguments], additional_env={'PYTHONUNBUFFERED': '1'}, name='ros2pkg-cli', output='screen', **kwargs) with launch_testing.tools.launch_process( launch_service, pkg_command_action, proc_info, proc_output) as pkg_command: yield pkg_command
def generate_launch_description(): launch_file_dir = os.path.join( get_package_share_directory('turtlebot3_gazebo'), 'launch') world = os.path.join(get_package_share_directory('camille_arbault_rob1'), 'challenge_maze.world') return LaunchDescription([ ExecuteProcess( cmd=['gazebo', '--verbose', world, '-s', 'libgazebo_ros_init.so'], output='screen'), ExecuteProcess(cmd=['gz', 'model', '-m', model, '-f', model], prefix="bash -c 'sleep 5s; $0 $@'", output='screen'), IncludeLaunchDescription( PythonLaunchDescriptionSource( [launch_file_dir, '/robot_state_publisher.launch.py']), launch_arguments={'use_sim_time': 'true'}.items(), ), ])
def generate_test_description(rmw_implementation): path_to_complex_node_script = os.path.join( os.path.dirname(__file__), 'fixtures', 'complex_node.py' ) additional_env = {'RMW_IMPLEMENTATION': rmw_implementation} return LaunchDescription([ # Always restart daemon to isolate tests. ExecuteProcess( cmd=['ros2', 'daemon', 'stop'], name='daemon-stop', on_exit=[ ExecuteProcess( cmd=['ros2', 'daemon', 'start'], name='daemon-start', on_exit=[ # Add test fixture actions. Node( executable=sys.executable, arguments=[path_to_complex_node_script], name='complex_node', additional_env=additional_env, ), Node( executable=sys.executable, arguments=[path_to_complex_node_script], name='complex_node', additional_env=additional_env, ), Node( executable=sys.executable, arguments=[path_to_complex_node_script], name='complex_node_2', additional_env=additional_env, ), launch_testing.actions.ReadyToTest(), ], additional_env=additional_env ) ] ), ])
def launch_interface_command(self, arguments, prepend_arguments=[], shell=False): interface_command_action = ExecuteProcess( cmd=[*prepend_arguments, 'ros2', 'interface', *arguments], additional_env={'PYTHONUNBUFFERED': '1'}, name='ros2interface-cli', shell=shell, output='screen' ) with launch_testing.tools.launch_process( launch_service, interface_command_action, proc_info, proc_output ) as interface_command: yield interface_command
def generate_launch_description(): use_sim_time = LaunchConfiguration('use_sim_time', default='True') world_file_name = os.environ['HIDE_SEEK_WORLD'] world = os.path.join(get_package_share_directory('robot_hide_seek'), 'worlds', world_file_name) launch_file_dir = os.path.join( get_package_share_directory('robot_hide_seek'), 'launch') return LaunchDescription([ ExecuteProcess(cmd=['gazebo', world, '-s', 'libgazebo_ros_init.so'], output='screen'), ExecuteProcess(cmd=[ 'ros2', 'param', 'set', '/gazebo', 'use_sim_time', use_sim_time ], output='screen'), IncludeLaunchDescription( PythonLaunchDescriptionSource( [launch_file_dir, '/robot_state_publisher.launch.py']), launch_arguments={'use_sim_time': use_sim_time}.items(), ), ])
def generate_launch_description(): emulator_path = 'install/tello_driver/lib/tello_driver/tello_emulator' tello_driver_params = [{'drone_ip': '127.0.0.1'}] return LaunchDescription([ ExecuteProcess(cmd=[emulator_path], output='screen'), Node(package='tello_driver', node_executable='tello_driver', node_name='tello_driver', parameters=tello_driver_params, output='screen'), ])
def generate_launch_description(): package_name = 'ifm3d_ros2' rviz_config = os.path.join(get_package_share_directory(package_name), 'etc', 'ifm3d.rviz') return LaunchDescription([ ExecuteProcess( cmd=['ros2', 'run', 'rviz2', 'rviz2', '-d', rviz_config], output='screen', log_cmd=True), ])
def generate_test_description(): launch_description = LaunchDescription() launch_description.add_action( ExecuteProcess(cmd=[ os.path.join(os.path.dirname(__file__), 'test_dump_params_node.py') ], name='test_dump_params')) processes_to_test = [ ExecuteProcess( cmd=[os.getenv('TEST_EXECUTABLE'), '-n', 'test_dump_params'], name='test_dump_params_yaml', output='screen'), ExecuteProcess( cmd=[os.getenv('TEST_EXECUTABLE'), '-n', 'test_dump_params', '-v'], name='test_dump_params_yaml_verbose', output='screen') ] for process in processes_to_test: launch_description.add_action(process) launch_description.add_action(launch_testing.actions.ReadyToTest()) return launch_description, {'processes_to_test': processes_to_test}
def generate_launch_description(): ld = LaunchDescription() gazebo_dir = get_package_share_directory('tr_gazebo') world_path = os.path.join(gazebo_dir, 'worlds', 'sub_and_ball.world') gazebo_command = ExecuteProcess(cmd=['gazebo', '--verbose', world_path]) ld.add_action(gazebo_command) return ld
def generate_launch_description(): map_yaml_file = os.getenv('TEST_MAP') world = os.getenv('TEST_WORLD') bt_navigator_xml = os.path.join( get_package_share_directory('nav2_bt_navigator'), 'behavior_trees', os.getenv('BT_NAVIGATOR_XML')) bringup_dir = get_package_share_directory('nav2_bringup') params_file = os.path.join(bringup_dir, 'params', 'nav2_params.yaml') # Replace the `use_astar` setting on the params file param_substitutions = {'GridBased.use_astar': os.getenv('ASTAR')} configured_params = RewrittenYaml(source_file=params_file, root_key='', param_rewrites=param_substitutions, convert_types=True) return LaunchDescription([ SetEnvironmentVariable('RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1'), # Launch gazebo server for simulation ExecuteProcess(cmd=[ 'gzserver', '-s', 'libgazebo_ros_init.so', '--minimal_comms', world ], output='screen'), # TODO(orduno) Launch the robot state publisher instead # using a local copy of TB3 urdf file Node(package='tf2_ros', node_executable='static_transform_publisher', output='screen', arguments=[ '0', '0', '0', '0', '0', '0', 'base_footprint', 'base_link' ]), Node( package='tf2_ros', node_executable='static_transform_publisher', output='screen', arguments=['0', '0', '0', '0', '0', '0', 'base_link', 'base_scan']), IncludeLaunchDescription(PythonLaunchDescriptionSource( os.path.join(bringup_dir, 'launch', 'bringup_launch.py')), launch_arguments={ 'namespace': '', 'use_namespace': 'False', 'map': map_yaml_file, 'use_sim_time': 'True', 'params_file': configured_params, 'bt_xml_file': bt_navigator_xml, 'autostart': 'True' }.items()), ])
def main(argv=sys.argv[1:]): ld = generate_launch_description() test1_action = ExecuteProcess( cmd=[get_package_prefix('robot_localization') + '/lib/robot_localization/test_filter_base_diagnostics_timestamps'], output='screen', ) lts = LaunchTestService() lts.add_test_action(ld, test1_action) ls = LaunchService(argv=argv) ls.include_launch_description(ld) return lts.run(ls)
def main(argv=sys.argv[1:]): testExecutable = os.getenv('TEST_EXECUTABLE') ld = LaunchDescription([]) test1_action = ExecuteProcess(cmd=[testExecutable], name='test_planner_costmaps_node', output='screen') lts = LaunchTestService() lts.add_test_action(ld, test1_action) ls = LaunchService(argv=argv) ls.include_launch_description(ld) return lts.run(ls)
def generate_launch_description(): cmd = ['MicroXRCEAgent', 'udp', '-p 2018'] env = { 'LD_PRELOAD': "/usr/local/lib/libfastrtps.so.1 /usr/local/lib/libfastcdr.so.1" } return LaunchDescription([ Node(package='m5stack_example', node_executable='stamp_example', output='screen'), ExecuteProcess(cmd=cmd, additional_env=env, output='screen') ])
def launch_domain_bridge(self, arguments): executable = os.path.join(os.getcwd(), 'domain_bridge') if os.name == 'nt': executable += '.exe' cmd = [executable] + arguments domain_bridge_proc = ExecuteProcess( cmd=cmd, output='screen', ) with launch_testing.tools.launch_process( launch_service, domain_bridge_proc, proc_info, proc_output) as launch_process: yield launch_process
def generate_launch_description(): package_name = 'jackal_gazebo' sdf_file = os.path.join( get_package_share_directory(package_name), 'models', 'jackal', 'model.sdf' ) use_sim_time = LaunchConfiguration("use_sim_time", default="true") world_file_name = "sorting.world" world = os.path.join( get_package_share_directory(package_name), "worlds", world_file_name ) launch_file_dir = os.path.join(get_package_share_directory(package_name), "launch") return LaunchDescription( [ ExecuteProcess( cmd=[ "gzserver", "--verbose", world, "-s", "libgazebo_ros_init.so", "-s", "libgazebo_ros_factory.so", ], output="screen", ), ExecuteProcess( cmd=["ros2", "param", "set", "/gazebo", "use_sim_time", use_sim_time], output="screen", ), IncludeLaunchDescription( PythonLaunchDescriptionSource( [launch_file_dir, "/robot_state_publisher.launch.py"] ), launch_arguments={"use_sim_time": use_sim_time}.items(), ), ExecuteProcess(cmd=['ros2', 'run', package_name, 'spawn_jackal', sdf_file]), ] )
def generate_launch_description(): urdf = os.path.join(get_package_share_directory('tello_description'), 'urdf', 'tello.urdf') return LaunchDescription([ # Rviz ExecuteProcess( cmd=['rviz2', '-d', 'install/flock2/share/flock2/launch/one.rviz'], output='screen'), # Publish static transforms Node(package='robot_state_publisher', node_executable='robot_state_publisher', output='screen', arguments=[urdf]), # Driver Node(package='tello_driver', node_executable='tello_driver_main', output='screen', node_name='tello_driver', node_namespace='solo'), # Joystick Node(package='joy', node_executable='joy_node', output='screen'), # Flock controller Node(package='flock2', node_executable='flock_base', output='screen'), # Drone controller Node(package='flock2', node_executable='drone_base', output='screen', node_name='drone_base', node_namespace='solo'), # Mapper Node(package='fiducial_vlam', node_executable='vmap_main', output='screen'), # Visual localizer Node(package='fiducial_vlam', node_executable='vloc_main', output='screen', node_name='vloc_main', node_namespace='solo'), # WIP: planner Node(package='flock2', node_executable='planner_node', output='screen'), ])
def generate_launch_description(): use_sim_time = LaunchConfiguration('use_sim_time', default='True') return launch.LaunchDescription([ # launch.actions.DeclareLaunchArgument( # 'entity', # default_value='entity'), # launch.actions.DeclareLaunchArgument( # 'file', # default_value='~/deps_ws/src/turtlebot3/turtlebot3/turtlebot3_description/urdf/turtlebot3_waffle_pi.urdf', # description='Path to UDRF file'), # launch.actions.DeclareLaunchArgument( # 'gazebo_namespace', # default_value='gazebo'), ExecuteProcess(cmd=[ 'ros2', 'param', 'set', '/gazebo', 'use_sim_time', use_sim_time ], output='screen'), launch_ros.actions.Node( package='xv2_ros2_spawn_model_to_ros1', executable='spawn_model', output='screen', #name=[launch.substitutions.LaunchConfiguration('entity'), 'talker']), name='spawn_entity', parameters=[ { 'entity': 'waffle' }, # {'file': '/root/deps_ws/src/turtlebot3/turtlebot3/turtlebot3_description/urdf/turtlebot3_waffle.urdf'}, { 'file': '/root/ws/src/robotic_order_fulfillment_robotic_turtle/xv2_description/urdf/fake_turtle.urdf' }, # {'file': '/root/ws/src/robotic_order_fulfillment_robotic_turtle/xv2_description/urdf/xv2_turtle.urdf'}, { 'gazebo_namespace': '/gazebo' }, { 'x': 0.0 }, { 'y': 0.65 }, { 'z': 0.0 }, ]), ]) # ros2 run ros2_spawn_model_to_ros1 spawn -entity entity -file ~/deps_ws/src/turtlebot3/turtlebot3/turtlebot3_description/urdf/turtlebot3_waffle_pi.urdf -gazebo_namespace gazebo
def generate_launch_description(): use_sim_time = LaunchConfiguration('use_sim_time', default='true') # world_file_name = 'amazon_warehouse.world' # world = os.path.join(get_package_share_directory('amazon_robot_gazebo'), 'worlds', world_file_name) # launch_file_dir = os.path.join(get_package_share_directory('amazon_robot_gazebo'), 'launch') world_file_name = 'amazon_warehouse/amazon_robot.model' world = os.path.join(get_package_share_directory('amazon_robot_gazebo'), 'worlds', world_file_name) launch_file_dir = os.path.join(get_package_share_directory('amazon_robot_gazebo'), 'launch') # sdf_file_name = 'amazon_robot2/model.sdf' # sdf = os.path.join( # get_package_share_directory('amazon_robot_gazebo'), # 'models', # sdf_file_name) # urdf_file_name = 'amazon_warehouse_robot.urdf.xacro' # urdf = os.path.join( # get_package_share_directory('amazon_robot_description'), # 'urdf', # urdf_file_name) # xml = open(sdf, 'r').read() # xml = xml.replace('"', '\\"') # swpan_args = '{name: \"amazon_robot\", xml: \"' + xml + '\" }' return LaunchDescription([ ExecuteProcess( cmd=['gazebo', '--verbose', world, '-s', 'libgazebo_ros_init.so'], output='screen'), # ExecuteProcess( # cmd=['ros2', 'param', 'set', '/gazebo', 'use_sim_time', use_sim_time], # output='screen'), IncludeLaunchDescription( PythonLaunchDescriptionSource([launch_file_dir, '/robot_state_publisher.py']), launch_arguments={'use_sim_time': use_sim_time}.items(), ), # ExecuteProcess( # cmd=['ros2', 'service', 'call', '/spawn_entity', 'gazebo_msgs/SpawnEntity', swpan_args], # output='screen'), ])
def generate_test_description(rmw_implementation): path_to_echo_server_script = os.path.join( os.path.dirname(__file__), 'fixtures', 'echo_server.py' ) additional_env = {'RMW_IMPLEMENTATION': rmw_implementation} return LaunchDescription([ # Always restart daemon to isolate tests. ExecuteProcess( cmd=['ros2', 'daemon', 'stop'], name='daemon-stop', on_exit=[ ExecuteProcess( cmd=['ros2', 'daemon', 'start'], name='daemon-start', on_exit=[ # Add test fixture actions. Node( executable=sys.executable, arguments=[path_to_echo_server_script], node_name='echo_server', node_namespace='my_ns', additional_env=additional_env, ), Node( executable=sys.executable, arguments=[path_to_echo_server_script], node_name='_hidden_echo_server', node_namespace='my_ns', remappings=[('echo', '_echo')], additional_env=additional_env, ), launch_testing.actions.ReadyToTest() ], additional_env=additional_env ) ] ), ])
def generate_launch_description(): return LaunchDescription([ # ExecuteProcess(cmd=['rviz2', '-d', 'src/fiducial_vlam/fiducial_vlam/cfg/default.rviz'], output='screen'), ExecuteProcess(cmd=['rviz2'], output='screen'), Node(package='tello_driver', node_executable='tello_driver', output='screen'), Node(package='tello_driver', node_executable='tello_joy', output='screen'), Node(package='joy', node_executable='joy_node', output='screen'), # Node(package='fiducial_vlam', node_executable='vloc_node', output='screen'), # Node(package='fiducial_vlam', node_executable='vmap_node', output='screen'), ])
def main(argv=sys.argv[1:]): ld = generate_launch_description() test1_action = ExecuteProcess( cmd=[os.path.join(os.getenv('TEST_DIR'), 'tester_node.py'), '-r', '-2.0', '-0.5', '100.0', '100.0'], name='tester_node', output='screen') lts = LaunchTestService() lts.add_test_action(ld, test1_action) ls = LaunchService(argv=argv) ls.include_launch_description(ld) return lts.run(ls)
def test_echo_filter(self, launch_service, proc_info, proc_output): params = [ ('/clitest/topic/echo_filter_all_pass', "m.data=='hello'", True), ('/clitest/topic/echo_filter_all_filtered', "m.data=='success'", False), ] for topic, filter_expr, has_output in params: with self.subTest(topic=topic, filter_expr=filter_expr, print_count=10): # Check for inconsistent arguments publisher = self.node.create_publisher(String, topic, 10) assert publisher def publish_message(): publisher.publish(String(data='hello')) publish_timer = self.node.create_timer(0.5, publish_message) try: command_action = ExecuteProcess( cmd=(['ros2', 'topic', 'echo'] + ['--filter', filter_expr] + [topic, 'std_msgs/String']), additional_env={'PYTHONUNBUFFERED': '1'}, output='screen') with launch_testing.tools.launch_process( launch_service, command_action, proc_info, proc_output, output_filter=launch_testing_ros.tools. basic_output_filter( filtered_rmw_implementation= get_rmw_implementation_identifier( ))) as command: # The future won't complete - we will hit the timeout self.executor.spin_until_future_complete( rclpy.task.Future(), timeout_sec=5) command.wait_for_shutdown(timeout=10) # Check results if has_output: assert 'hello' in command.output, 'Echo CLI did not output' else: assert 'hello' not in command.output, 'All messages should be filtered out' finally: # Cleanup self.node.destroy_timer(publish_timer) self.node.destroy_publisher(publisher)
def main(argv=sys.argv[1:]): testExecutable = os.getenv('TEST_EXECUTABLE') ld = generate_launch_description() test1_action = ExecuteProcess( cmd=[testExecutable], name='test_dynamic_params_client', ) lts = LaunchTestService() lts.add_test_action(ld, test1_action) ls = LaunchService(argv=argv) ls.include_launch_description(ld) return lts.run(ls)
def main(argv=sys.argv[1:]): ld = generate_launch_description() testExecutable = os.getenv('TEST_EXECUTABLE') test1_action = ExecuteProcess(cmd=[testExecutable], name='test_spin_recovery_fake_node', output='screen') lts = LaunchTestService() lts.add_test_action(ld, test1_action) ls = LaunchService(argv=argv) ls.include_launch_description(ld) return lts.run(ls)
def generate_launch_description(): rviz_config = Path(get_package_share_directory('openrover_demo'), 'config', 'default.rviz').resolve() assert rviz_config.is_file() return LaunchDescription([ DeclareLaunchArgument('frame', default_value='map', description='The fixed frame to be used in RViz'), SetEnvironmentVariable('RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1'), ExecuteProcess(cmd=[ 'rviz2', '--display-config', str(rviz_config), '--fixed-frame', LaunchConfiguration(variable_name='frame') ], output='screen'), ])
def generate_test_description(): launch_description = LaunchDescription() # Set the output format to a "verbose" format that is expected by the executable output os.environ['RCUTILS_CONSOLE_OUTPUT_FORMAT'] = \ '[{severity}] [{name}]: {message} ({function_name}() at {file_name}:{line_number})' executable = os.path.join(os.getcwd(), 'test_logging_long_messages') if os.name == 'nt': executable += '.exe' process_name = 'test_logging_long_messages' launch_description.add_action( ExecuteProcess(cmd=[executable], name=process_name, output='screen')) launch_description.add_action(launch_testing.actions.ReadyToTest()) return launch_description, {'process_name': process_name}
def launch_param_dump_command(self, arguments): param_dump_command_action = ExecuteProcess( cmd=['ros2', 'param', 'dump', *arguments], additional_env={ 'RMW_IMPLEMENTATION': rmw_implementation, }, name='ros2param-dump-cli', output='screen' ) with launch_testing.tools.launch_process( launch_service, param_dump_command_action, proc_info, proc_output, output_filter=rmw_implementation_filter ) as param_dump_command: yield param_dump_command
def launch_topic_command(self, arguments): topic_command_action = ExecuteProcess( cmd=['ros2', 'topic', *arguments], additional_env={ 'RMW_IMPLEMENTATION': rmw_implementation, 'PYTHONUNBUFFERED': '1' }, name='ros2topic-cli', output='screen' ) with launch_testing.tools.launch_process( launch_service, topic_command_action, proc_info, proc_output, output_filter=rmw_implementation_filter ) as topic_command: yield topic_command
def generate_launch_description(): use_sim_time = LaunchConfiguration('use_sim_time', default='True') kobuki_gazebo_demo_path= get_package_share_directory('kobuki_gazebo_demo') gazebo_model_path = os.path.join(kobuki_gazebo_demo_path,'models') os.environ['GAZEBO_MODEL_PATH'] = gazebo_model_path obstacle_world = os.path.join(kobuki_gazebo_demo_path, 'worlds', "test_room_object_obstacle.world") launch_file_dir = os.path.join(kobuki_gazebo_demo_path, 'launch','includes') return LaunchDescription([ ExecuteProcess( cmd=['gazebo', '--verbose', obstacle_world, '-s', 'libgazebo_ros_init.so'], output='screen'), ExecuteProcess( cmd=['ros2', 'param', 'set', '/gazebo', 'use_sim_time', use_sim_time], output='screen'), IncludeLaunchDescription( PythonLaunchDescriptionSource([launch_file_dir, '/robot.launch.py']), launch_arguments={'use_sim_time': use_sim_time}.items(), ), ])
def generate_test_description(): tmp_dir_name = tempfile.mkdtemp() output_path = Path(tmp_dir_name) / 'ros2bag_test_record' record_all_process = ExecuteProcess( cmd=[ 'ros2', 'bag', 'record', '-a', '--output', output_path.as_posix() ], name='ros2bag-cli', output='screen', ) return LaunchDescription( [record_all_process, launch_testing.actions.ReadyToTest()]), locals()