def generate_launch_description(): """Generate launch description with multiple components.""" mouse_node = LifecycleNode(name='raspimouse', package='raspimouse', executable='raspimouse', output='screen', parameters=[{ 'use_light_sensors': False, }]) imu_driver = LifecycleNode(name='rt_usb_9axisimu_driver', package='rt_usb_9axisimu_driver', executable='rt_usb_9axisimu_driver', output='screen', parameters=[{ 'port': '/dev/ttyACM0', }]) direction_controller = Node( package='raspimouse_ros2_examples', executable='direction_controller', output='screen', ) manager = Node(name='manager', package='raspimouse_ros2_examples', executable='lifecycle_node_manager', output='screen', parameters=[{ 'components': ['raspimouse', 'rt_usb_9axisimu_driver'] }]) return launch.LaunchDescription( [mouse_node, imu_driver, direction_controller, manager])
def generate_launch_description(): # Get the launch directory example_dir = get_package_share_directory('social_nav2_goal_updaters') stdout_linebuf_envvar = SetEnvironmentVariable( 'RCUTILS_LOGGING_BUFFERED_STREAM', '1') # Specify the actions escort_cmd = LifecycleNode(package='social_nav2_goal_updaters', executable='escort_goal_updater_node', name='escort_goal_updater_node', output='screen', parameters=[]) follow_cmd = LifecycleNode(package='social_nav2_goal_updaters', executable='follow_goal_updater_node', name='follow_goal_updater_node', output='screen', parameters=[]) hri_cmd = LifecycleNode(package='social_nav2_goal_updaters', executable='hri_goal_updater_node', name='hri_goal_updater_node', output='screen', parameters=[]) emit_event_to_request_that_escort_configure_transition = EmitEvent( event=ChangeState( lifecycle_node_matcher=launch.events.matches_action(escort_cmd), transition_id=lifecycle_msgs.msg.Transition.TRANSITION_CONFIGURE, )) emit_event_to_request_that_follow_configure_transition = EmitEvent( event=ChangeState( lifecycle_node_matcher=launch.events.matches_action(follow_cmd), transition_id=lifecycle_msgs.msg.Transition.TRANSITION_CONFIGURE, )) emit_event_to_request_that_hri_configure_transition = EmitEvent( event=ChangeState( lifecycle_node_matcher=launch.events.matches_action(hri_cmd), transition_id=lifecycle_msgs.msg.Transition.TRANSITION_CONFIGURE, )) # Create the launch description and populate ld = LaunchDescription() # Set environment variables ld.add_action(stdout_linebuf_envvar) # Declare the launch options ld.add_action(escort_cmd) ld.add_action(follow_cmd) ld.add_action(hri_cmd) ld.add_action(emit_event_to_request_that_escort_configure_transition) ld.add_action(emit_event_to_request_that_follow_configure_transition) ld.add_action(emit_event_to_request_that_hri_configure_transition) return ld
def test_node_name(): node_object = LifecycleNode( package='asd', executable='bsd', name='my_node', namespace='my_ns', ) lc = LaunchContext() node_object._perform_substitutions(lc) assert node_object.is_node_name_fully_specified() is True
def generate_launch_description(): return LaunchDescription([ LifecycleNode(package='lifecycle', node_executable='lifecycle_talker', node_name='lc_talker', output='screen'), ])
def generate_launch_description(): return LaunchDescription([ LifecycleNode(package='?????????', node_executable='???????????', node_name='???????????', output='????????') ])
def generate_launch_description(): declare_lidar = DeclareLaunchArgument( 'lidar', default_value='lds', description='LiDAR: lds only, for now.') mouse_node = LifecycleNode( node_name='raspimouse', package='raspimouse', node_executable='raspimouse', output='screen', parameters=[ os.path.join( get_package_share_directory('raspimouse_ros2_examples'), 'config', 'mouse.yml') ]) def func_launch_lidar_node(context): if context.launch_configurations['lidar'] == 'lds': return [ IncludeLaunchDescription( PythonLaunchDescriptionSource([ os.path.join( get_package_share_directory('hls_lfcd_lds_driver'), 'launch'), '/hlds_laser.launch.py' ]), ) ] launch_lidar_node = OpaqueFunction(function=func_launch_lidar_node) ld = LaunchDescription() ld.add_action(declare_lidar) ld.add_action(mouse_node) ld.add_action(launch_lidar_node) return ld
def generate_launch_description(): params_file = LaunchConfiguration( 'params', default=[ThisLaunchFileDir(), '/launch_params.yaml']) # make sure the dbc file gets installed with the launch file dbc_file_path = get_package_share_directory('raptor_dbw_can') + \ "/launch/New_Eagle_DBW_3.3.388.dbc" return LaunchDescription([ Node( package='raptor_dbw_can', executable='raptor_dbw_can_node', output='screen', namespace='raptor_dbw_interface', parameters=[{ "dbw_dbc_file": dbc_file_path }], remappings=[ ('/raptor_dbw_interface/can_rx', '/can_rx_tx/can_tx'), ('/raptor_dbw_interface/can_tx', '/can_rx_tx/can_rx'), ], ), LifecycleNode(package='kvaser_interface', node_executable='kvaser_can_bridge', node_name="kvaser_interface", output='screen', namespace='', parameters=[params_file]), ])
def generate_launch_description(): share_dir = get_package_share_directory('ydlidar_ros2_driver') parameter_file = LaunchConfiguration('params_file') node_name = 'ydlidar_ros2_driver_node' params_declare = DeclareLaunchArgument( 'params_file', default_value=os.path.join(share_dir, 'params', 'ydlidar.yaml'), description='FPath to the ROS2 parameters file to use.') driver_node = LifecycleNode( package='ydlidar_ros2_driver', node_executable='ydlidar_ros2_driver_node', node_name='ydlidar_ros2_driver_node', output='screen', emulate_tty=True, parameters=[parameter_file], node_namespace='/', ) tf2_node = Node( package='tf2_ros', node_executable='static_transform_publisher', node_name='static_tf_pub_laser', arguments=[ '0', '0', '0.02', '0', '0', '0', '1', 'base_link', 'laser_frame' ], ) return LaunchDescription([ params_declare, driver_node, tf2_node, ])
def generate_launch_description(): return LaunchDescription([ LifecycleNode(package='radar_conti_ars408', node_executable='radar_conti_ars408_composition', node_name='radar_conti_ars408', output='screen') ])
def generate_launch_description(): return LaunchDescription([ LifecycleNode(package='lifecycle', node_executable='lifecycle_talker', name='lc_talker', output='screen'), Node(package='lifecycle', node_executable='lifecycle_listener', output='screen'), Node(package='lifecycle', node_executable='lifecycle_service_client', output='screen') ])
def generate_launch_description(): return LaunchDescription([ LifecycleNode( package='lifecycle', node_executable='lifecycle_talker', node_name='lc_talker', output='screen', parameters=[ '/home/alaa/ros2_ws/src/ros2/demos/lifecycle/myparams.yaml' ]), Node(package='lifecycle', node_executable='lifecycle_listener', output='screen'), Node(package='lifecycle', node_executable='lifecycle_service_client', output='screen') ]) #thisdict = { # "brand": "Ford", # "model": "Mustang", # "year": 1964 #} #['/home/alaa/ros2_ws/src/ros2/demos/lifecycle/myparams.yaml']
def generate_launch_description(): set_tty_launch_config_action = launch.actions.SetLaunchConfiguration( "emulate_tty", "True") watchdog_node = LifecycleNode( package='sw_watchdog', node_executable='windowed_watchdog', node_namespace='', node_name='windowed_watchdog', output='screen', arguments=['220', '3', '--publish', '--activate'] #arguments=['__log_level:=debug'] ) # When the watchdog reaches the 'inactive' state, log a message watchdog_inactive_handler = RegisterEventHandler( OnStateTransition( target_lifecycle_node=watchdog_node, goal_state='inactive', entities=[ # Log LogInfo(msg="Watchdog transitioned to 'INACTIVE' state."), ], )) return launch.LaunchDescription([ set_tty_launch_config_action, watchdog_node, watchdog_inactive_handler ])
def generate_launch_description(): set_tty_launch_config_action = launch.actions.SetLaunchConfiguration( "emulate_tty", "True") # Launch Description ld = launch.LaunchDescription() # Watchdog node watchdog_node = LifecycleNode(package='sw_watchdog', node_executable='simple_watchdog', node_namespace='', node_name='simple_docker_watchdog', output='screen', arguments=['220', '--publish', '--activate'] #arguments=['__log_level:=debug'] ) # Make the Watchdog node take the 'activate' transition watchdog_activate_trans_event = EmitEvent(event=ChangeState( lifecycle_node_matcher=launch.events.matches_action(watchdog_node), transition_id=lifecycle_msgs.msg.Transition.TRANSITION_ACTIVATE, )) # When the watchdog reaches the 'inactive' state from 'active', log message # and restart monitored entity (via docker) watchdog_inactive_handler = RegisterEventHandler( OnStateTransition( target_lifecycle_node=watchdog_node, start_state='deactivating', goal_state='inactive', entities=[ # Log LogInfo(msg="Watchdog transitioned to 'INACTIVE' state."), # Restart the monitored entity OpaqueFunction(function=docker_restart), # Change state event (inactive -> active) watchdog_activate_trans_event, ], )) # When Shutdown is requested, clean up docker shutdown_handler = RegisterEventHandler( OnShutdown( on_shutdown=[ # Log LogInfo(msg="watchdog_in_docker was asked to shutdown."), # Clean up docker OpaqueFunction(function=docker_stop), ], )) # Add the actions to the launch description. # The order they are added reflects the order in which they will be executed ld.add_action(set_tty_launch_config_action) ld.add_action(OpaqueFunction(function=docker_run)) ld.add_action(watchdog_node) ld.add_action(watchdog_inactive_handler) ld.add_action(shutdown_handler) return ld
def func_launch_mouse_node(context): if context.launch_configurations['mouse'] == "true": return [LifecycleNode( name='raspimouse', package='raspimouse', executable='raspimouse', output='screen', parameters=[os.path.join(get_package_share_directory( 'raspimouse_ros2_examples'), 'config', 'mouse.yml')] )]
def generate_launch_description(): share_dir = get_package_share_directory('ros2_ouster') parameter_file = LaunchConfiguration('params_file') node_name = 'ouster_driver' params_declare = DeclareLaunchArgument( 'params_file', default_value=os.path.join(share_dir, 'params', 'os1.yaml'), description='FPath to the ROS2 parameters file to use.') driver_node = LifecycleNode( package='ros2_ouster', executable='ouster_driver', name=node_name, output='screen', emulate_tty=True, parameters=[parameter_file], namespace='/', ) configure_event = EmitEvent(event=ChangeState( lifecycle_node_matcher=matches_action(driver_node), transition_id=lifecycle_msgs.msg.Transition.TRANSITION_CONFIGURE, )) activate_event = RegisterEventHandler( OnStateTransition( target_lifecycle_node=driver_node, goal_state='inactive', entities=[ LogInfo( msg="[LifecycleLaunch] Ouster driver node is activating."), EmitEvent(event=ChangeState( lifecycle_node_matcher=matches_action(driver_node), transition_id=lifecycle_msgs.msg.Transition. TRANSITION_ACTIVATE, )), ], )) # TODO make lifecycle transition to shutdown before SIGINT shutdown_event = RegisterEventHandler( OnShutdown(on_shutdown=[ EmitEvent(event=ChangeState( lifecycle_node_matcher=matches_node_name(node_name=node_name), transition_id=lifecycle_msgs.msg.Transition. TRANSITION_ACTIVE_SHUTDOWN, )), LogInfo(msg="[LifecycleLaunch] Ouster driver node is exiting."), ], )) return LaunchDescription([ params_declare, driver_node, activate_event, configure_event, shutdown_event, ])
def generate_launch_description(): share_dir = get_package_share_directory('serial_driver') node_name = 'serial_bridge_node' params_declare = DeclareLaunchArgument( 'params_file', default_value=os.path.join(share_dir, 'params', 'example.params.yaml'), description='File path to the ROS2 parameters file to use') bridge_node = LifecycleNode( package='serial_driver', executable='serial_bridge', name=node_name, namespace=TextSubstitution(text=''), parameters=[LaunchConfiguration('params_file')], output='screen', ) configure_event_handler = RegisterEventHandler( event_handler=OnProcessStart( target_action=bridge_node, on_start=[ EmitEvent(event=ChangeState( lifecycle_node_matcher=matches_action(bridge_node), transition_id=Transition.TRANSITION_CONFIGURE, ), ), ], )) activate_event_handler = RegisterEventHandler( event_handler=OnStateTransition( target_lifecycle_node=bridge_node, start_state='configuring', goal_state='inactive', entities=[ EmitEvent(event=ChangeState( lifecycle_node_matcher=matches_action(bridge_node), transition_id=Transition.TRANSITION_ACTIVATE, ), ), ], )) shutdown_event_handler = RegisterEventHandler(event_handler=OnShutdown( on_shutdown=[ EmitEvent(event=ChangeState( lifecycle_node_matcher=matches_node_name(node_name), transition_id=Transition.TRANSITION_ACTIVE_SHUTDOWN, )) ])) return LaunchDescription([ params_declare, bridge_node, configure_event_handler, activate_event_handler, shutdown_event_handler, ])
def generate_launch_description(): # Launch Description ld = launch.LaunchDescription() # Add the actions to the launch description. # The order they are added reflects the order in which they will be executed. ComponentInstance4_node = LifecycleNode( node_name='ComponentInstance4', package='handtracker', node_executable='HandTracker', remappings=[ ('image_S', 'ComponentInstance5/Image/image_P'), ('points_P', 'ComponentInstance4/Float32MultiArray/points_P') ], parameters=[share_dir+'/launch/cfg/param.yaml'], output='screen', emulate_tty=True # assure that RCLCPP output gets flushed ) ld.add_entity(ComponentInstance4_node) # transition to configure after startup configure_ComponentInstance4 = launch.actions.RegisterEventHandler( launch.event_handlers.on_process_start.OnProcessStart( target_action=ComponentInstance4_node, on_start=[ launch.actions.EmitEvent( event=launch_ros.events.lifecycle.ChangeState( lifecycle_node_matcher=launch.events.matches_action(ComponentInstance4_node), transition_id=lifecycle_msgs.msg.Transition.TRANSITION_CONFIGURE ) ) ] ) ) ld.add_entity(configure_ComponentInstance4) # transition to activate, once inactive activate_ComponentInstance4 = launch.actions.RegisterEventHandler( launch_ros.event_handlers.OnStateTransition( target_lifecycle_node=ComponentInstance4_node, start_state='configuring', goal_state='inactive', entities=[ launch.actions.EmitEvent( event=launch_ros.events.lifecycle.ChangeState( lifecycle_node_matcher=launch.events.matches_action(ComponentInstance4_node), transition_id=lifecycle_msgs.msg.Transition.TRANSITION_ACTIVATE ) ) ] ) ) ld.add_entity(activate_ComponentInstance4) return ld
def test_lifecycle_node_constructor(): # Construction without namespace with pytest.raises(TypeError): LifecycleNode( package='asd', executable='bsd', name='my_node', ) with pytest.raises(TypeError): LifecycleNode( package='asd', executable='bsd', namespace='my_ns', ) # Successfull construction LifecycleNode( package='asd', executable='bsd', name='my_node', namespace='my_ns', )
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
def test_lifecycle_node_constructor(): # Construction without namespace with pytest.raises(TypeError): LifecycleNode( package='asd', executable='bsd', name='my_node', ) # Construction without name # TODO(ivanpauno): This should raise TypeError. with pytest.raises(RuntimeError): LifecycleNode( package='asd', executable='bsd', namespace='my_ns', ) # Successfull construction LifecycleNode( package='asd', executable='bsd', name='my_node', namespace='my_ns', )
def generate_launch_description(): params_file_path = os.path.join(get_package_share_directory( 'vicon2_driver'), 'config', 'vicon2_driver_params.yaml') stdout_linebuf_envvar = SetEnvironmentVariable( 'RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1') # print('') # print('params_file_path: ', params_file_path) # print('') driver_node = LifecycleNode( node_name='vicon2_driver_node', package='vicon2_driver', node_executable='vicon2_driver_main', output='screen', parameters=[params_file_path], ) # Make the driver node take the 'configure' transition driver_configure_trans_event = EmitEvent( event=ChangeState( lifecycle_node_matcher=launch.events.matchers.matches_action(driver_node), transition_id=lifecycle_msgs.msg.Transition.TRANSITION_CONFIGURE, ) ) # Make the driver node take the 'activate' transition # driver_activate_trans_event = EmitEvent( # event = ChangeState( # lifecycle_node_matcher = launch.events.matchers.matches_action(driver_node), # transition_id = lifecycle_msgs.msg.Transition.TRANSITION_ACTIVATE, # ) # ) # Create the launch description and populate ld = LaunchDescription() ld.add_action(stdout_linebuf_envvar) ld.add_action(driver_node) ld.add_action(driver_configure_trans_event) # ld.add_action(driver_activate_trans_event) return ld
def generate_launch_description(): # use: 'zed' for "ZED" camera - 'zedm' for "ZED mini" camera camera_model = 'zed' # URDF file to be loaded by Robot State Publisher urdf = os.path.join(get_package_share_directory('stereolabs_zed'), 'urdf', camera_model + '.urdf') # ZED Configurations to be loaded by ZED Node config_common = os.path.join(get_package_share_directory('stereolabs_zed'), 'config', 'common.yaml') config_camera = os.path.join(get_package_share_directory('stereolabs_zed'), 'config', camera_model + '.yaml') # Set LOG format os.environ[ 'RCUTILS_CONSOLE_OUTPUT_FORMAT'] = '{time}: [{name}] [{severity}] - {message}' return LaunchDescription([ # Robot State Publisher Node( node_namespace='zed', node_name='zed_state_publisher', package='robot_state_publisher', node_executable='robot_state_publisher', output='screen', arguments=[urdf], ), # ZED LifecycleNode( node_namespace='zed', # must match the namespace in config -> YAML node_name='zed_node', # must match the node name in config -> YAML package='stereolabs_zed', node_executable='zed_wrapper_node', output='screen', parameters=[ config_common, # Common parameters config_camera, # Camera related parameters ], ), ])
def generate_launch_description(): # Launch Description ld = launch.LaunchDescription() # Add the actions to the launch description. # The order they are added reflects the order in which they will be executed. ComponentInstance4_node = LifecycleNode( node_name='ComponentInstance4', package='handtracker', node_executable='HandTracker', remappings=[('image_S', 'ComponentInstance5/Image/image_P'), ('points_P', 'ComponentInstance4/Float32MultiArray/points_P')], parameters=[share_dir + '/launch/cfg/param.yaml'], output='screen', emulate_tty=True # assure that RCLCPP output gets flushed ) ld.add_entity(ComponentInstance4_node) return ld
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(): share_dir = get_package_share_directory('nav2_gps_waypoint_follower_demo') parameter_file = LaunchConfiguration('params_file') node_name = 'gps_waypoint_follower_demo' params_declare = DeclareLaunchArgument( 'params_file', default_value=os.path.join(share_dir, 'params', 'demo_gps_waypoints.yaml'), description='FPath to the ROS2 parameters file to use.') driver_node = LifecycleNode( package='nav2_gps_waypoint_follower_demo', executable='gps_waypoint_follower_demo', name=node_name, namespace='', output='screen', parameters=[parameter_file], ) return LaunchDescription([ params_declare, driver_node, ])
def generate_launch_description(): # use: 'zed' for "ZED" camera - 'zedm' for "ZED mini" camera camera_model = 'zed' # URDF file to be loaded by Robot State Publisher urdf = os.path.join(get_package_share_directory('stereolabs_zed'), 'urdf', camera_model + '.urdf') # ZED Configurations to be loaded by ZED Node config_common = os.path.join(get_package_share_directory('stereolabs_zed'), 'config', 'common.yaml') config_camera = os.path.join(get_package_share_directory('stereolabs_zed'), 'config', camera_model + '.yaml') # Set LOG format os.environ[ 'RCUTILS_CONSOLE_OUTPUT_FORMAT'] = '{time}: [{name}] [{severity}]\t{message}' # Launch Description ld = launch.LaunchDescription() # Prepare the ZED node zed_node = LifecycleNode( node_namespace='zed', # must match the namespace in config -> YAML node_name='zed_node', # must match the node name in config -> YAML package='stereolabs_zed', node_executable='zed_wrapper_node', output='screen', parameters=[ config_common, # Common parameters config_camera, # Camera related parameters ]) # Prepare the Robot State Publisher node rsp_node = Node(node_name='zed_state_publisher', package='robot_state_publisher', node_executable='robot_state_publisher', output='screen', arguments=[urdf, 'robot_description:=zed_description']) # Make the ZED node take the 'configure' transition zed_configure_trans_event = EmitEvent(event=ChangeState( lifecycle_node_matcher=launch.events.matches_action(zed_node), transition_id=lifecycle_msgs.msg.Transition.TRANSITION_CONFIGURE, )) # Make the ZED node take the 'activate' transition zed_activate_trans_event = EmitEvent(event=ChangeState( lifecycle_node_matcher=launch.events.matches_action(zed_node), transition_id=lifecycle_msgs.msg.Transition.TRANSITION_ACTIVATE, )) # Shutdown event shutdown_event = EmitEvent(event=launch.events.Shutdown()) # When the ZED node reaches the 'inactive' state from 'unconfigured', make it take the 'activate' transition and start the Robot State Publisher zed_inactive_from_unconfigured_state_handler = RegisterEventHandler( OnStateTransition( target_lifecycle_node=zed_node, start_state='configuring', goal_state='inactive', entities=[ # Log LogInfo( msg= "'ZED' reached the 'INACTIVE' state, start the 'Robot State Publisher' node and 'activating'." ), # Robot State Publisher rsp_node, # Change State event ( inactive -> active ) zed_activate_trans_event, ], )) # When the ZED node reaches the 'inactive' state from 'active', it has been deactivated and it will wait for a manual activation zed_inactive_from_active_state_handler = RegisterEventHandler( OnStateTransition( target_lifecycle_node=zed_node, start_state='deactivating', goal_state='inactive', entities=[ # Log LogInfo( msg= "'ZED' reached the 'INACTIVE' state from 'ACTIVE' state. Waiting for manual activation..." ) ], )) # When the ZED node reaches the 'active' state, log a message. zed_active_state_handler = RegisterEventHandler( OnStateTransition( target_lifecycle_node=zed_node, goal_state='active', entities=[ # Log LogInfo(msg="'ZED' reached the 'ACTIVE' state"), ], )) # When the ZED node reaches the 'finalized' state, log a message and exit. zed_finalized_state_handler = RegisterEventHandler( OnStateTransition( target_lifecycle_node=zed_node, goal_state='finalized', entities=[ # Log LogInfo( msg= "'ZED' reached the 'FINALIZED' state. Killing the node..." ), shutdown_event, ], )) # Add the actions to the launch description. # The order they are added reflects the order in which they will be executed. ld.add_action(zed_inactive_from_unconfigured_state_handler) ld.add_action(zed_inactive_from_active_state_handler) ld.add_action(zed_active_state_handler) ld.add_action(zed_finalized_state_handler) ld.add_action(zed_node) ld.add_action(zed_configure_trans_event) return ld
def launch_setup(context, *args, **kwargs): # fmt: off architecture_type = LaunchConfiguration("architecture_type", default="awf/universe") autoware_launch_file = LaunchConfiguration( "autoware_launch_file", default=default_autoware_launch_file_of( architecture_type.perform(context))) autoware_launch_package = LaunchConfiguration( "autoware_launch_package", default=default_autoware_launch_package_of( architecture_type.perform(context))) global_frame_rate = LaunchConfiguration("global_frame_rate", default=30.0) global_real_time_factor = LaunchConfiguration("global_real_time_factor", default=1.0) global_timeout = LaunchConfiguration("global_timeout", default=180) initialize_duration = LaunchConfiguration("initialize_duration", default=30) launch_autoware = LaunchConfiguration("launch_autoware", default=True) launch_rviz = LaunchConfiguration("launch_rviz", default=False) output_directory = LaunchConfiguration("output_directory", default=Path("/tmp")) port = LaunchConfiguration("port", default=8080) record = LaunchConfiguration("record", default=True) scenario = LaunchConfiguration("scenario", default=Path("/dev/null")) sensor_model = LaunchConfiguration("sensor_model", default="") sigterm_timeout = LaunchConfiguration("sigterm_timeout", default=8) vehicle_model = LaunchConfiguration("vehicle_model", default="") workflow = LaunchConfiguration("workflow", default=Path("/dev/null")) # fmt: on print(f"architecture_type := {architecture_type.perform(context)}") print( f"autoware_launch_file := {autoware_launch_file.perform(context)}") print( f"autoware_launch_package := {autoware_launch_package.perform(context)}" ) print(f"global_frame_rate := {global_frame_rate.perform(context)}") print( f"global_real_time_factor := {global_real_time_factor.perform(context)}" ) print(f"global_timeout := {global_timeout.perform(context)}") print(f"initialize_duration := {initialize_duration.perform(context)}") print(f"launch_autoware := {launch_autoware.perform(context)}") print(f"launch_rviz := {launch_rviz.perform(context)}") print(f"output_directory := {output_directory.perform(context)}") print(f"port := {port.perform(context)}") print(f"record := {record.perform(context)}") print(f"scenario := {scenario.perform(context)}") print(f"sensor_model := {sensor_model.perform(context)}") print(f"sigterm_timeout := {sigterm_timeout.perform(context)}") print(f"vehicle_model := {vehicle_model.perform(context)}") print(f"workflow := {workflow.perform(context)}") def make_parameters(): parameters = [ { "architecture_type": architecture_type }, { "autoware_launch_file": autoware_launch_file }, { "autoware_launch_package": autoware_launch_package }, { "initialize_duration": initialize_duration }, { "launch_autoware": launch_autoware }, { "port": port }, { "record": record }, { "sensor_model": sensor_model }, { "vehicle_model": vehicle_model }, ] def description(): return get_package_share_directory( vehicle_model.perform(context) + "_description") if vehicle_model.perform(context): parameters.append(description() + "/config/vehicle_info.param.yaml") parameters.append(description() + "/config/simulator_model.param.yaml") return parameters return [ # fmt: off DeclareLaunchArgument("architecture_type", default_value=architecture_type), DeclareLaunchArgument("autoware_launch_file", default_value=autoware_launch_file), DeclareLaunchArgument("autoware_launch_package", default_value=autoware_launch_package), DeclareLaunchArgument("global_frame_rate", default_value=global_frame_rate), DeclareLaunchArgument("global_real_time_factor", default_value=global_real_time_factor), DeclareLaunchArgument("global_timeout", default_value=global_timeout), DeclareLaunchArgument("launch_autoware", default_value=launch_autoware), DeclareLaunchArgument("launch_rviz", default_value=launch_rviz), DeclareLaunchArgument("output_directory", default_value=output_directory), DeclareLaunchArgument("scenario", default_value=scenario), DeclareLaunchArgument("sensor_model", default_value=sensor_model), DeclareLaunchArgument("sigterm_timeout", default_value=sigterm_timeout), DeclareLaunchArgument("vehicle_model", default_value=vehicle_model), DeclareLaunchArgument("workflow", default_value=workflow), # fmt: on Node( package="scenario_test_runner", executable="scenario_test_runner", namespace="simulation", name="scenario_test_runner", output="screen", on_exit=Shutdown(), arguments=[ # fmt: off "--global-frame-rate", global_frame_rate, "--global-real-time-factor", global_real_time_factor, "--global-timeout", global_timeout, "--output-directory", output_directory, "--scenario", scenario, "--workflow", workflow, # fmt: on ], ), Node( package="simple_sensor_simulator", executable="simple_sensor_simulator_node", namespace="simulation", name="simple_sensor_simulator", output="screen", parameters=[{ "port": port }], ), LifecycleNode( package="openscenario_interpreter", executable="openscenario_interpreter_node", namespace="simulation", name="openscenario_interpreter", output="screen", parameters=make_parameters(), # on_exit=Shutdown(), ), Node( package="openscenario_visualization", executable="openscenario_visualization_node", namespace="simulation", name="openscenario_visualizer", output="screen", ), Node( package="rviz2", executable="rviz2", name="rviz2", output={ "stderr": "log", "stdout": "log" }, condition=IfCondition(launch_rviz), arguments=[ "-d", str( # Path(get_package_share_directory("scenario_test_runner")) Path(get_package_share_directory("traffic_simulator")) / "config/scenario_simulator_v2.rviz"), ], ), ]
def generate_launch_description(): # Get the launch directory pkg_dir = get_package_share_directory('clean_up') nav_dir = get_package_share_directory('gb_navigation') manipulation_dir = get_package_share_directory('gb_manipulation') gb_world_model_dir = get_package_share_directory('gb_world_model') world_config_dir = os.path.join(gb_world_model_dir, 'config') namespace = LaunchConfiguration('namespace') dope_params_file = LaunchConfiguration('dope_params_file') declare_dope_params_cmd = DeclareLaunchArgument( 'dope_params_file', default_value=os.path.join(get_package_share_directory('dope_launch'), 'config', 'config_pose.yaml'), description='Full path to the TF Pose Estimation parameters file to use' ) declare_namespace_cmd = DeclareLaunchArgument('namespace', default_value='', description='Namespace') stdout_linebuf_envvar = SetEnvironmentVariable( 'RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1') gb_manipulation_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(get_package_share_directory('gb_manipulation'), 'launch', 'gb_manipulation_launch.py'))) gb_navigation_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(get_package_share_directory('gb_navigation'), 'launch', 'nav2_tiago_launch.py'))) plansys2_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(get_package_share_directory('plansys2_bringup'), 'launch', 'plansys2_bringup_launch_monolithic.py')), launch_arguments={ 'model_file': pkg_dir + '/pddl/domain.pddl:' + nav_dir + '/pddl/domain.pddl' }.items()) dope_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(get_package_share_directory('dope_launch'), 'launch', 'dope_launch.py')), launch_arguments={'dope_params_file': dope_params_file}.items()) # Specify the actions clean_up_executor_cmd = LifecycleNode(package='clean_up', executable='cleanup_executor_node', name='cleanup_executor_node') emit_event_to_request_that_clean_up_executor_configure_transition = EmitEvent( event=ChangeState( lifecycle_node_matcher=launch.events.matches_action( clean_up_executor_cmd), transition_id=lifecycle_msgs.msg.Transition.TRANSITION_CONFIGURE, )) emit_event_to_request_that_clean_up_executor_activate_transition = EmitEvent( event=ChangeState( lifecycle_node_matcher=launch.events.matches_action( clean_up_executor_cmd), transition_id=lifecycle_msgs.msg.Transition.TRANSITION_ACTIVATE, )) on_configure_clean_up_executor_handler = RegisterEventHandler( OnStateTransition( target_lifecycle_node=clean_up_executor_cmd, goal_state='inactive', entities=[ emit_event_to_request_that_clean_up_executor_activate_transition ])) # Specify the dependencies vision_cmd = LifecycleNode(package='clean_up', executable='vision_sim_node', name='vision') emit_event_to_request_that_vision_configure_transition = EmitEvent( event=ChangeState( lifecycle_node_matcher=launch.events.matches_action(vision_cmd), transition_id=lifecycle_msgs.msg.Transition.TRANSITION_CONFIGURE, )) attention_manager_cmd = Node(package='gb_attention', executable='attention_server', output='screen') wm_cmd = Node(package='gb_world_model', executable='world_model_main', output='screen', parameters=[world_config_dir + '/world.yml']) ld = LaunchDescription() # Set environment variables ld.add_action(stdout_linebuf_envvar) ld.add_action(declare_namespace_cmd) ld.add_action(declare_dope_params_cmd) # Declare the launch options # Event handlers ld.add_action(on_configure_clean_up_executor_handler) ld.add_action(gb_manipulation_cmd) ld.add_action(gb_navigation_cmd) ld.add_action(plansys2_cmd) ld.add_action(clean_up_executor_cmd) ld.add_action(vision_cmd) ld.add_action(emit_event_to_request_that_vision_configure_transition) ld.add_action( emit_event_to_request_that_clean_up_executor_configure_transition) ld.add_action(attention_manager_cmd) ld.add_action(wm_cmd) ld.add_action(dope_cmd) return ld
def generate_launch_description(): package_name = 'ifm3d_ros2' node_namespace = 'ifm3d' node_name = 'camera' node_exe = 'camera_standalone' # os.environ['RCUTILS_CONSOLE_OUTPUT_FORMAT'] = \ # "[{%s}] {%s} [{%s}]: {%s}\n({%s}() at {%s}:{%s})" % \ # ("severity", "time", "name", "message", # "function_name", "file_name", "line_number") os.environ['RCUTILS_CONSOLE_OUTPUT_FORMAT'] = \ "[{%s}] {%s} [{%s}]: {%s}" % ("severity", "time", "name", "message") # XXX: This is a hack, there does not seem to be a nice way (or at least # finding the docs is not obvious) to do this with the ROS2 launch api # # Basically, we are trying to allow for passing through the command line # args to the launch file through to the node executable itself (like ROS # 1). # # My assumption is that either: # 1. This stuff exists somewhere in ROS2 and I don't know about it yet # 2. This stuff will exist in ROS2 soon, so, this will likely get factored # out (hopefully soon) # parameters = [] remaps = [] for arg in sys.argv: if ':=' in arg: split_arg = arg.split(sep=':=', maxsplit=1) assert len(split_arg) == 2 if arg.startswith("ns"): node_namespace = split_arg[1] elif arg.startswith("node"): node_name = split_arg[1] elif arg.startswith("params"): parameters.append(tuple(split_arg)[1]) else: remaps.append(tuple(split_arg)) def add_prefix(tup): assert len(tup) == 2 if node_namespace.startswith("/"): prefix = "%s/%s" % (node_namespace, node_name) else: prefix = "/%s/%s" % (node_namespace, node_name) retval = [None, None] if not tup[0].startswith(prefix): retval[0] = prefix + '/' + tup[0] else: retval[0] = tup[0] if not tup[1].startswith(prefix): retval[1] = prefix + '/' + tup[1] else: retval[1] = tup[1] return tuple(retval) remaps = list(map(add_prefix, remaps)) #------------------------------------------------------------ # Nodes #------------------------------------------------------------ # # Coord frame transform from camera_optical_link to camera_link # tf_node = \ ExecuteProcess( cmd=['ros2', 'run', 'tf2_ros', 'static_transform_publisher', '0', '0', '0', str(-pi/2.), '0', str(-pi/2.), str(node_name + "_link"), str(node_name + "_optical_link")], #output='screen', log_cmd=True ) # # The camera component # camera_node = \ LifecycleNode( package=package_name, node_executable=node_exe, node_namespace=node_namespace, node_name=node_name, output='screen', parameters=parameters, remappings=remaps, log_cmd=True, ) #------------------------------------------------------------ # Events we need to emit to induce state transitions #------------------------------------------------------------ camera_configure_evt = \ EmitEvent( event=ChangeState( lifecycle_node_matcher = \ launch.events.matches_action(camera_node), transition_id = lifecycle_msgs.msg.Transition.TRANSITION_CONFIGURE ) ) camera_activate_evt = \ EmitEvent( event=ChangeState( lifecycle_node_matcher = \ launch.events.matches_action(camera_node), transition_id = lifecycle_msgs.msg.Transition.TRANSITION_ACTIVATE ) ) camera_cleanup_evt = \ EmitEvent( event=ChangeState( lifecycle_node_matcher = \ launch.events.matches_action(camera_node), transition_id = lifecycle_msgs.msg.Transition.TRANSITION_CLEANUP ) ) camera_shutdown_evt = EmitEvent(event=launch.events.Shutdown()) #------------------------------------------------------------ # These are the edges of the state machine graph we want to autonomously # manage #------------------------------------------------------------ # # unconfigured -> configuring -> inactive # camera_node_unconfigured_to_inactive_handler = \ RegisterEventHandler( OnStateTransition( target_lifecycle_node = camera_node, start_state = 'configuring', goal_state = 'inactive', entities = [ LogInfo(msg = "Emitting 'TRANSITION_ACTIVATE' event"), camera_activate_evt, ], ) ) # # active -> deactivating -> inactive # camera_node_active_to_inactive_handler = \ RegisterEventHandler( OnStateTransition( target_lifecycle_node = camera_node, start_state = 'deactivating', goal_state = 'inactive', entities = [ LogInfo(msg = "Emitting 'TRANSITION_CLEANUP' event"), camera_cleanup_evt, ], ) ) # # inactive -> cleaningup -> unconfigured # camera_node_inactive_to_unconfigured_handler = \ RegisterEventHandler( OnStateTransition( target_lifecycle_node = camera_node, start_state = 'cleaningup', goal_state = 'unconfigured', entities = [ LogInfo(msg = "Emitting 'TRANSITION_CONFIGURE' event"), camera_configure_evt, ], ) ) # # * -> errorprocessing -> unconfigured # camera_node_errorprocessing_to_unconfigured_handler = \ RegisterEventHandler( OnStateTransition( target_lifecycle_node = camera_node, start_state = 'errorprocessing', goal_state = 'unconfigured', entities = [ LogInfo(msg = "Emitting 'TRANSITION_CONFIGURE' event"), camera_configure_evt, ], ) ) # # * -> shuttingdown -> finalized # camera_node_shuttingdown_to_finalized_handler = \ RegisterEventHandler( OnStateTransition( target_lifecycle_node = camera_node, start_state = 'shuttingdown', goal_state = 'finalized', entities = [ LogInfo(msg = "Emitting 'SHUTDOWN' event"), camera_shutdown_evt, ], ) ) #------------------------------------------------------------ # Now, add all the actions to a launch description and return it #------------------------------------------------------------ ld = LaunchDescription() ld.add_action(camera_node_unconfigured_to_inactive_handler) ld.add_action(camera_node_active_to_inactive_handler) ld.add_action(camera_node_inactive_to_unconfigured_handler) ld.add_action(camera_node_errorprocessing_to_unconfigured_handler) ld.add_action(camera_node_shuttingdown_to_finalized_handler) ld.add_action(tf_node) ld.add_action(camera_node) ld.add_action(camera_configure_evt) return ld
def generate_launch_description(): package_name = 'ifm3d_ros2' node_namespace = 'ifm3d' node_name = 'camera' node_exe = 'camera_standalone' # os.environ['RCUTILS_CONSOLE_OUTPUT_FORMAT'] = \ # "[{%s}] {%s} [{%s}]: {%s}\n({%s}() at {%s}:{%s})" % \ # ("severity", "time", "name", "message", # "function_name", "file_name", "line_number") os.environ['RCUTILS_CONSOLE_OUTPUT_FORMAT'] = \ "[{%s}] {%s} [{%s}]: {%s}" % ("severity", "time", "name", "message") # XXX: This is a hack, there does not seem to be a nice way (or at least # finding the docs is not obvious) to do this with the ROS2 launch api # # Basically, we are trying to allow for passing through the command line # args to the launch file through to the node executable itself (like ROS # 1). # # My assumption is that either: # 1. This stuff exists somewhere in ROS2 and I don't know about it yet # 2. This stuff will exist in ROS2 soon, so, this will likely get factored # out (hopefully soon) # parameters = [] remaps = [] for arg in sys.argv: if ':=' in arg: split_arg = arg.split(sep=':=', maxsplit=1) assert len(split_arg) == 2 if arg.startswith("ns"): node_namespace = split_arg[1] elif arg.startswith("node"): node_name = split_arg[1] elif arg.startswith("params"): parameters.append(tuple(split_arg)[1]) else: remaps.append(tuple(split_arg)) def add_prefix(tup): assert len(tup) == 2 if node_namespace.startswith("/"): prefix = "%s/%s" % (node_namespace, node_name) else: prefix = "/%s/%s" % (node_namespace, node_name) retval = [None, None] if not tup[0].startswith(prefix): retval[0] = prefix + '/' + tup[0] else: retval[0] = tup[0] if not tup[1].startswith(prefix): retval[1] = prefix + '/' + tup[1] else: retval[1] = tup[1] return tuple(retval) remaps = list(map(add_prefix, remaps)) return LaunchDescription([ ExecuteProcess( cmd=['ros2', 'run', 'tf2_ros', 'static_transform_publisher', '0', '0', '0', '-1.5707963267948966', '0', '-1.5707963267948966', str(node_name + "_link"), str(node_name + "_optical_link")], output='screen', log_cmd=True ), LifecycleNode( package=package_name, node_executable=node_exe, node_namespace=node_namespace, node_name=node_name, output='screen', parameters=parameters, remappings=remaps, log_cmd=True, ), ])