def generate_load_controller_launch_description(controller_name, controller_type=None, controller_params_file=None): """ Generate launch description for loading a controller using spawner.py. Returns a list of LaunchDescription actions adding the 'controller_manager_name' and 'unload_on_kill' LaunchArguments and a Node action that runs the controller_manager spawner.py node to load and start a controller Examples # noqa: D416 -------- # Assuming the controller type and controller parameters are known to the controller_manager generate_load_controller_launch_description('joint_state_controller') # Passing controller type and controller parameter file to load generate_load_controller_launch_description( 'joint_state_controller', controller_type='joint_state_controller/JointStateController', controller_params_file=os.path.join(get_package_share_directory('my_pkg'), 'config', 'controller_params.yaml') ) """ declare_controller_mgr_name = DeclareLaunchArgument( 'controller_manager_name', default_value='controller_manager', description='Controller manager node name' ) declare_unload_on_kill = DeclareLaunchArgument( 'unload_on_kill', default_value='false', description='Wait until the node is interrupted and then unload controller' ) spawner_arguments = [ controller_name, '--controller-manager', LaunchConfiguration('controller_manager_name') ] if controller_type: spawner_arguments += ['--controller-type', controller_type] if controller_params_file: spawner_arguments += ['--param-file', controller_params_file] # Setting --unload-on-kill if launch arg unload_on_kill is "true" # See https://github.com/ros2/launch/issues/290 spawner_arguments += [PythonExpression( ['"--unload-on-kill"', ' if "true" == "', LaunchConfiguration('unload_on_kill'), '" else ""'] )] spawner = Node(package='controller_manager', executable='spawner.py', arguments=spawner_arguments, shell=True, output='screen') return LaunchDescription([ declare_controller_mgr_name, declare_unload_on_kill, spawner, ])
def generate_launch_description(): pkg = "ros2_latency" # We need to convert the desired MB into conf_mb = LaunchConfiguration("megabytes", default=10.0) points_per_mb = round( 1024.0 * 1024.0 / 32.0) # See field point_step in `ros2 topic echo /pc_source` resulting_points = PythonExpression( ["int(", str(points_per_mb), " * ", conf_mb, ")"]) return LaunchDescription([ Node(package=pkg, name='ros2_latency', executable='source', parameters=[ { "num_points": resulting_points }, ], output="screen"), Node(package=pkg, name='ros2_latency', executable='repeater', output="screen"), Node(package=pkg, name='ros2_latency', executable='repeater.py', output="screen"), Node(package=pkg, name='ros2_latency', executable='measure', output="screen"), ])
def _plugin_command(arg): cmd = [ '"-s libgazebo_ros_', arg, '.so" if "true" == "', LaunchConfiguration(arg), '" else ""' ] py_cmd = PythonExpression(cmd) return py_cmd
def _boolean_command(arg): cmd = [ '"--', arg, '" if "true" == "', LaunchConfiguration(arg), '" else ""' ] py_cmd = PythonExpression(cmd) return py_cmd
def generate_launch_description(): ld = LaunchDescription([ DeclareLaunchArgument( 'gazebo_model_path_env_var', description='GAZEBO_MODEL_PATH environment variable'), DeclareLaunchArgument( 'gazebo_plugin_path_env_var', description='GAZEBO_PLUGIN_PATH environment variable'), DeclareLaunchArgument( 'headless', default_value='False', description='Whether to execute gzclient'), DeclareLaunchArgument( 'world_model_file', description='Full path to world model file to load'), DeclareLaunchArgument( 'robot_gt_urdf_file', description='Full path to robot urdf model file to load'), DeclareLaunchArgument( 'robot_realistic_urdf_file', description='Full path to robot urdf model file to load'), SetEnvironmentVariable('RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1'), SetEnvironmentVariable('GAZEBO_MODEL_PATH', LaunchConfiguration('gazebo_model_path_env_var')), SetEnvironmentVariable('GAZEBO_PLUGIN_PATH', LaunchConfiguration('gazebo_plugin_path_env_var')), ExecuteProcess( cmd=['gzserver', '--verbose', '-s', 'libgazebo_ros_init.so', LaunchConfiguration('world_model_file')], output='screen'), ExecuteProcess( condition=IfCondition(PythonExpression(['not ', LaunchConfiguration('headless')])), cmd=['gzclient'], output='log'), Node( package='robot_state_publisher', node_executable='robot_state_publisher', node_name='robot_state_publisher_gt', output='log', parameters=[{'use_sim_time': True}], arguments=[LaunchConfiguration('robot_gt_urdf_file')]), Node( package='tf2_ros', node_executable='static_transform_publisher', node_name='gt_odom_static_transform_publisher', output='log', parameters=[{'use_sim_time': True}], arguments=["0", "0", "0", "0", "0", "0", "map", "odom"]), # odom is actually the ground truth, because currently (Eloquent) odom and base_link are hardcoded in the navigation stack (recoveries and controller) >:C Node( package='robot_state_publisher', node_executable='robot_state_publisher', node_name='robot_state_publisher_realistic', output='log', parameters=[{'use_sim_time': True}], arguments=[LaunchConfiguration('robot_realistic_urdf_file')]), ]) return ld
def generate_launch_description(): # Get gazebo_ros package path gazebo_ros_share_path = get_package_share_directory('gazebo_ros') lobot_desc_share_path = get_package_share_directory('lobot_description') sim_share_path = get_package_share_directory('arm_simulation') gym_zero_g_world_path = os.path.join(lobot_desc_share_path, "worlds/gym_zero_g_world.sdf") zero_g_world_path = os.path.join(lobot_desc_share_path, "worlds/zero_g_world.sdf") cmd = [ '"', gym_zero_g_world_path, '"', ' if "', LaunchConfiguration('gym'), '" == "True" ', 'else ', '"', zero_g_world_path, '"' ] # The expression above expression is evaluated to something like this: # <some_path>/gym_zero_g_world.sdf if "<LaunchConfig evaluation result>" == "True" else <some_path>/zero_g_world.sdf py_cmd = PythonExpression(cmd) # Launch gzserver gzserver = IncludeLaunchDescription(PythonLaunchDescriptionSource( os.path.join(gazebo_ros_share_path, 'launch', 'gzserver.launch.py')), launch_arguments={ 'extra_gazebo_args': '__log_level:=info', 'pause': 'true', 'world': py_cmd }.items()) spawn_entity = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(sim_share_path, 'launch', 'spawn_entity.launch.py')), ) # Launch gzclient gzclient = IncludeLaunchDescription(PythonLaunchDescriptionSource( os.path.join(gazebo_ros_share_path, 'launch', 'gzclient.launch.py')), condition=IfCondition( LaunchConfiguration('gui'))) return LaunchDescription([ DeclareLaunchArgument( 'gym', default_value='False', description= 'Bool to specify if the simulation is to be ran with openai gym training' ), DeclareLaunchArgument( 'gui', default_value='True', description= 'Bool to specify if gazebo should be launched with GUI or not'), gzserver, spawn_entity, gzclient, ])
def generate_launch_description(): omnivelma_dir = get_package_share_directory('omnivelma_navigation_2') bringup_dir = get_package_share_directory('nav2_bringup') launch_dir = os.path.join(bringup_dir, 'launch') map_location = os.path.join(omnivelma_dir, 'maps', 'willow_garage.yaml') nav_params_dir = os.path.join(omnivelma_dir, 'params', 'nav2_params.yaml') slam = LaunchConfiguration('use_slam') nav_params_cmd = launch.actions.DeclareLaunchArgument( name='nav_params_file', default_value=nav_params_dir, description="Navigation parameters file") map_cmd = launch.actions.DeclareLaunchArgument(name='map_file', default_value=map_location, description="Map file") use_slam_cmd = DeclareLaunchArgument(name='use_slam', default_value='False', description="SLAM or localization") slam_cmd = IncludeLaunchDescription( launch.launch_description_sources.PythonLaunchDescriptionSource( os.path.join(omnivelma_dir, 'launch/slam_launch.py')), condition=IfCondition(slam), launch_arguments={ # 'params_file': launch.substitutions.LaunchConfiguration('nav_params_file'), }.items(), ) amcl_cmd = IncludeLaunchDescription( launch.launch_description_sources.PythonLaunchDescriptionSource( os.path.join(launch_dir, 'localization_launch.py')), condition=IfCondition(PythonExpression(['not ', slam])), launch_arguments={ 'params_file': launch.substitutions.LaunchConfiguration('nav_params_file'), 'map': launch.substitutions.LaunchConfiguration('map_file') }.items(), ) # Create the launch description and populate ld = LaunchDescription() ld.add_action(use_slam_cmd) ld.add_action(nav_params_cmd) ld.add_action(map_cmd) ld.add_action(amcl_cmd) ld.add_action(slam_cmd) return ld
def generate_launch_description(): use_sim_time = LaunchConfiguration('use_sim_time') params_file = LaunchConfiguration('params_file') default_params_file = os.path.join( get_package_share_directory("slam_toolbox"), 'config', 'mapper_params_online_async.yaml') declare_use_sim_time_argument = DeclareLaunchArgument( 'use_sim_time', default_value='true', description='Use simulation/Gazebo clock') declare_params_file_cmd = DeclareLaunchArgument( 'params_file', default_value=default_params_file, description= 'Full path to the ROS2 parameters file to use for the slam_toolbox node' ) # If the provided param file doesn't have slam_toolbox params, we must pass the # default_params_file instead. This could happen due to automatic propagation of # LaunchArguments. See: # https://github.com/ros-planning/navigation2/pull/2243#issuecomment-800479866 has_node_params = HasNodeParams(source_file=params_file, node_name='slam_toolbox') actual_params_file = PythonExpression([ '"', params_file, '" if ', has_node_params, ' else "', default_params_file, '"' ]) log_param_change = LogInfo(msg=[ 'provided params_file ', params_file, ' does not contain slam_toolbox parameters. Using default: ', default_params_file ], condition=UnlessCondition(has_node_params)) start_async_slam_toolbox_node = Node( parameters=[actual_params_file, { 'use_sim_time': use_sim_time }], package='slam_toolbox', executable='async_slam_toolbox_node', name='slam_toolbox', output='screen') ld = LaunchDescription() ld.add_action(declare_use_sim_time_argument) ld.add_action(declare_params_file_cmd) ld.add_action(log_param_change) ld.add_action(start_async_slam_toolbox_node) return ld
def generate_launch_description(): ld = LaunchDescription() # environment variables DRONE_DEVICE_ID = os.getenv('DRONE_DEVICE_ID') # arguments ld.add_action( DeclareLaunchArgument("rplidar_mode", default_value="outdoor")) ld.add_action( DeclareLaunchArgument("serial_port", default_value="/dev/rplidar")) # mode select for rplidar # ---------------------- # Sensitivity: optimized for longer ranger, better sensitivity but weak environment elimination # Boost: optimized for sample rate # Stability: for light elimination performance, but shorter range and lower sample rate rplidar_mode = PythonExpression([ '"Stability" if "outdoor" == "', LaunchConfiguration("rplidar_mode"), '" else "Sensitivity"' ]) #namespace declarations namespace = DRONE_DEVICE_ID # frame names fcu_frame = DRONE_DEVICE_ID + "/fcu" # the same definition is in static_tf_launch.py file rplidar_frame = DRONE_DEVICE_ID + "/rplidar" # the same definition is in static_tf_launch.py file garmin_frame = DRONE_DEVICE_ID + "/garmin" # the same definition is in static_tf_launch.py file ld.add_action( Node( namespace=namespace, package='rplidar_ros2', executable='rplidar', name='rplidar', parameters=[{ 'serial_port': LaunchConfiguration("serial_port"), 'serial_baudrate': 256000, # A3 'frame_id': rplidar_frame, 'inverted': False, 'angle_compensate': True, 'scan_mode': rplidar_mode, }], output='screen', ), ), ld.add_action( IncludeLaunchDescription( PythonLaunchDescriptionSource( [ThisLaunchFileDir(), '/static_tf_launch.py'])), ), return ld
def generate_launch_description(): log_level = 'info' if (os.getenv('ROS_DISTRO') == "dashing") or (os.getenv('ROS_DISTRO') == "eloquent"): return LaunchDescription(declare_configurable_parameters(configurable_parameters) + [ # Realsense launch_ros.actions.Node( condition=IfCondition(PythonExpression([LaunchConfiguration('config_file'), " == ''"])), package='realsense2_camera', node_namespace=LaunchConfiguration("camera_name"), node_name=LaunchConfiguration("camera_name"), node_executable='realsense2_camera_node', prefix=['stdbuf -o L'], parameters=[set_configurable_parameters(configurable_parameters) ], output='screen', arguments=['--ros-args', '--log-level', LaunchConfiguration('log_level')], ), launch_ros.actions.Node( condition=IfCondition(PythonExpression([LaunchConfiguration('config_file'), " != ''"])), package='realsense2_camera', node_namespace=LaunchConfiguration("camera_name"), node_name=LaunchConfiguration("camera_name"), node_executable='realsense2_camera_node', prefix=['stdbuf -o L'], parameters=[set_configurable_parameters(configurable_parameters) , PythonExpression([LaunchConfiguration("config_file")]) ], output='screen', arguments=['--ros-args', '--log-level', LaunchConfiguration('log_level')], ), ]) else: return LaunchDescription(declare_configurable_parameters(configurable_parameters) + [ # Realsense launch_ros.actions.Node( condition=IfCondition(PythonExpression([LaunchConfiguration('config_file'), " == ''"])), package='realsense2_camera', namespace=LaunchConfiguration("camera_name"), name=LaunchConfiguration("camera_name"), executable='realsense2_camera_node', parameters=[set_configurable_parameters(configurable_parameters) ], output='screen', arguments=['--ros-args', '--log-level', LaunchConfiguration('log_level')], emulate_tty=True, ), launch_ros.actions.Node( condition=IfCondition(PythonExpression([LaunchConfiguration('config_file'), " != ''"])), package='realsense2_camera', namespace=LaunchConfiguration("camera_name"), name=LaunchConfiguration("camera_name"), executable='realsense2_camera_node', parameters=[set_configurable_parameters(configurable_parameters) , PythonExpression([LaunchConfiguration("config_file")]) ], output='screen', arguments=['--ros-args', '--log-level', LaunchConfiguration('log_level')], emulate_tty=True, ), ])
def generate_launch_description(): return LaunchDescription( declare_configurable_parameters(configurable_parameters) + [ # Realsense launch_ros.actions.Node( condition=IfCondition( PythonExpression( ["'", LaunchConfiguration('config_file'), "' == ''"])), package='realsense2_camera', namespace=LaunchConfiguration("camera_name"), name=LaunchConfiguration("camera_name"), executable='realsense2_camera_node', parameters=[ set_configurable_parameters(configurable_parameters) ], output='screen', emulate_tty=True, ), launch_ros.actions.Node( condition=IfCondition( PythonExpression( ["'", LaunchConfiguration('config_file'), "' != ''"])), package='realsense2_camera', namespace=LaunchConfiguration("camera_name"), name=LaunchConfiguration("camera_name"), executable='realsense2_camera_node', parameters=[ set_configurable_parameters(configurable_parameters), {LaunchConfiguration("config_file")} ], output='screen', emulate_tty=True, ), ])
def _arg_command(arg): cmd = ['"--', arg, '" if "" != "', LaunchConfiguration(arg), '" else ""'] py_cmd = PythonExpression(cmd) return py_cmd
def generate_launch_description(): # Get the launch directory bringup_dir = get_package_share_directory('nav2_bringup') namespace = LaunchConfiguration('namespace') use_sim_time = LaunchConfiguration('use_sim_time') autostart = LaunchConfiguration('autostart') params_file = LaunchConfiguration('params_file') use_composition = LaunchConfiguration('use_composition') container_name = LaunchConfiguration('container_name') lifecycle_nodes = [ 'controller_server', 'smoother_server', 'planner_server', 'behavior_server', 'bt_navigator', 'waypoint_follower' ] # Map fully qualified names to relative ones so the node's namespace can be prepended. # In case of the transforms (tf), currently, there doesn't seem to be a better alternative # https://github.com/ros/geometry2/issues/32 # https://github.com/ros/robot_state_publisher/pull/30 # TODO(orduno) Substitute with `PushNodeRemapping` # https://github.com/ros2/launch_ros/issues/56 remappings = [('/tf', 'tf'), ('/tf_static', 'tf_static')] # Create our own temporary YAML files that include substitutions param_substitutions = { 'use_sim_time': use_sim_time, 'autostart': autostart } configured_params = RewrittenYaml(source_file=params_file, root_key=namespace, param_rewrites=param_substitutions, convert_types=True) stdout_linebuf_envvar = SetEnvironmentVariable( 'RCUTILS_LOGGING_BUFFERED_STREAM', '1') declare_namespace_cmd = DeclareLaunchArgument( 'namespace', default_value='', description='Top-level namespace') declare_use_sim_time_cmd = DeclareLaunchArgument( 'use_sim_time', default_value='false', description='Use simulation (Gazebo) clock if true') declare_params_file_cmd = DeclareLaunchArgument( 'params_file', default_value=os.path.join(bringup_dir, 'params', 'nav2_params.yaml'), description= 'Full path to the ROS2 parameters file to use for all launched nodes') declare_autostart_cmd = DeclareLaunchArgument( 'autostart', default_value='true', description='Automatically startup the nav2 stack') declare_use_composition_cmd = DeclareLaunchArgument( 'use_composition', default_value='False', description='Use composed bringup if True') declare_container_name_cmd = DeclareLaunchArgument( 'container_name', default_value='nav2_container', description= 'the name of conatiner that nodes will load in if use composition') load_nodes = GroupAction(condition=IfCondition( PythonExpression(['not ', use_composition])), actions=[ Node(package='nav2_controller', executable='controller_server', output='screen', parameters=[configured_params], remappings=remappings), Node(package='nav2_smoother', executable='smoother_server', name='smoother_server', output='screen', parameters=[configured_params], remappings=remappings), Node(package='nav2_planner', executable='planner_server', name='planner_server', output='screen', parameters=[configured_params], remappings=remappings), Node(package='nav2_behaviors', executable='behavior_server', name='behavior_server', output='screen', parameters=[configured_params], remappings=remappings), Node(package='nav2_bt_navigator', executable='bt_navigator', name='bt_navigator', output='screen', parameters=[configured_params], remappings=remappings), Node(package='nav2_waypoint_follower', executable='waypoint_follower', name='waypoint_follower', output='screen', parameters=[configured_params], remappings=remappings), Node(package='nav2_lifecycle_manager', executable='lifecycle_manager', name='lifecycle_manager_navigation', output='screen', parameters=[{ 'use_sim_time': use_sim_time }, { 'autostart': autostart }, { 'node_names': lifecycle_nodes }]), ]) load_composable_nodes = LoadComposableNodes( condition=IfCondition(use_composition), target_container=container_name, composable_node_descriptions=[ ComposableNode(package='nav2_controller', plugin='nav2_controller::ControllerServer', name='controller_server', parameters=[configured_params], remappings=remappings), ComposableNode(package='nav2_smoother', plugin='nav2_smoother::SmootherServer', name='smoother_server', parameters=[configured_params], remappings=remappings), ComposableNode(package='nav2_planner', plugin='nav2_planner::PlannerServer', name='planner_server', parameters=[configured_params], remappings=remappings), ComposableNode(package='nav2_behaviors', plugin='behavior_server::BehaviorServer', name='behavior_server', parameters=[configured_params], remappings=remappings), ComposableNode(package='nav2_bt_navigator', plugin='nav2_bt_navigator::BtNavigator', name='bt_navigator', parameters=[configured_params], remappings=remappings), ComposableNode(package='nav2_waypoint_follower', plugin='nav2_waypoint_follower::WaypointFollower', name='waypoint_follower', parameters=[configured_params], remappings=remappings), ComposableNode(package='nav2_lifecycle_manager', plugin='nav2_lifecycle_manager::LifecycleManager', name='lifecycle_manager_navigation', parameters=[{ 'use_sim_time': use_sim_time, 'autostart': autostart, 'node_names': lifecycle_nodes }]), ], ) # Create the launch description and populate ld = LaunchDescription() # Set environment variables ld.add_action(stdout_linebuf_envvar) # Declare the launch options ld.add_action(declare_namespace_cmd) ld.add_action(declare_use_sim_time_cmd) ld.add_action(declare_params_file_cmd) ld.add_action(declare_autostart_cmd) ld.add_action(declare_use_composition_cmd) ld.add_action(declare_container_name_cmd) # Add the actions to launch all of the navigation nodes ld.add_action(load_nodes) ld.add_action(load_composable_nodes) return ld
def generate_launch_description(): # Get the launch directory social_bringup_dir = get_package_share_directory('social_nav2_bringup') nav_bringup_dir = get_package_share_directory('nav2_bringup') launch_dir = os.path.join(nav_bringup_dir, 'launch') # Create the launch configuration variables namespace = LaunchConfiguration('namespace') use_namespace = LaunchConfiguration('use_namespace') map_yaml_file = LaunchConfiguration('map') use_sim_time = LaunchConfiguration('use_sim_time') params_file = LaunchConfiguration('params_file') bt_xml_file = LaunchConfiguration('bt_xml_file') autostart = LaunchConfiguration('autostart') use_remappings = LaunchConfiguration('use_remappings') # Launch configuration variables specific to simulation rviz_config_file = LaunchConfiguration('rviz_config_file') use_simulator = LaunchConfiguration('use_simulator') use_robot_state_pub = LaunchConfiguration('use_robot_state_pub') use_rviz = LaunchConfiguration('use_rviz') headless = LaunchConfiguration('headless') world = LaunchConfiguration('world') # Map fully qualified names to relative ones so the node's namespace can be prepended. # In case of the transforms (tf), currently, there doesn't seem to be a better alternative # https://github.com/ros/geometry2/issues/32 # https://github.com/ros/robot_state_publisher/pull/30 # TODO(orduno) Substitute with `PushNodeRemapping` # https://github.com/ros2/launch_ros/issues/56 remappings = [('/tf', 'tf'), ('/tf_static', 'tf_static')] # Declare the launch arguments declare_namespace_cmd = DeclareLaunchArgument( 'namespace', default_value='', description='Top-level namespace') declare_use_namespace_cmd = DeclareLaunchArgument( 'use_namespace', default_value='false', description='Whether to apply a namespace to the navigation stack') declare_map_yaml_cmd = DeclareLaunchArgument( 'map', default_value=os.path.join(social_bringup_dir, 'maps', 'turtlebot3_house.yaml'), description='Full path to map file to load') declare_use_sim_time_cmd = DeclareLaunchArgument( 'use_sim_time', default_value='true', description='Use simulation (Gazebo) clock if true') declare_use_remappings_cmd = DeclareLaunchArgument( 'use_remappings', default_value='false', description='Arguments to pass to all nodes launched by the file') declare_params_file_cmd = DeclareLaunchArgument( 'params_file', default_value=os.path.join(social_bringup_dir, 'params', 'nav2_params.yaml'), description= 'Full path to the ROS2 parameters file to use for all launched nodes') declare_bt_xml_cmd = DeclareLaunchArgument( 'bt_xml_file', default_value=os.path.join( get_package_share_directory('social_nav2_bringup'), 'behavior_trees', 'follow_point.xml'), description='Full path to the behavior tree xml file to use') declare_autostart_cmd = DeclareLaunchArgument( 'autostart', default_value='true', description='Automatically startup the nav2 stack') declare_rviz_config_file_cmd = DeclareLaunchArgument( 'rviz_config_file', default_value=os.path.join(social_bringup_dir, 'rviz', 'nav2_default_view.rviz'), description='Full path to the RVIZ config file to use') declare_use_simulator_cmd = DeclareLaunchArgument( 'use_simulator', default_value='True', description='Whether to start the simulator') declare_use_robot_state_pub_cmd = DeclareLaunchArgument( 'use_robot_state_pub', default_value='True', description='Whether to start the robot state publisher') declare_use_rviz_cmd = DeclareLaunchArgument( 'use_rviz', default_value='True', description='Whether to start RVIZ') declare_simulator_cmd = DeclareLaunchArgument( 'headless', default_value='False', description='Whether to execute gzclient)') declare_world_cmd = DeclareLaunchArgument( 'world', # TODO(orduno) Switch back once ROS argument passing has been fixed upstream # https://github.com/ROBOTIS-GIT/turtlebot3_simulations/issues/91 # default_value=os.path.join(get_package_share_directory('turtlebot3_gazebo'), # 'worlds/turtlebot3_worlds/waffle.model'), default_value=os.path.join(social_bringup_dir, 'worlds', 'waffle_house.model'), description='Full path to world model file to load') # Specify the actions start_gazebo_server_cmd = ExecuteProcess( condition=IfCondition(use_simulator), cmd=[ 'gzserver', '-s', 'libgazebo_ros_init.so', '-s', 'libgazebo_ros_factory.so', world ], cwd=[launch_dir], output='screen') start_gazebo_client_cmd = ExecuteProcess(condition=IfCondition( PythonExpression([use_simulator, ' and not ', headless])), cmd=['gzclient'], cwd=[launch_dir], output='screen') urdf = os.path.join(social_bringup_dir, 'urdf', 'turtlebot3_waffle.urdf') start_robot_state_publisher_cmd = Node( condition=IfCondition(use_robot_state_pub), package='robot_state_publisher', executable='robot_state_publisher', name='robot_state_publisher', namespace=namespace, output='screen', parameters=[{ 'use_sim_time': use_sim_time }], remappings=remappings, arguments=[urdf]) start_rviz_cmd = Node( condition=IfCondition(use_rviz), package='rviz2', executable='rviz2', name='rviz2', arguments=['-d', rviz_config_file], output='screen', ) exit_event_handler = RegisterEventHandler( event_handler=OnProcessExit(target_action=start_rviz_cmd, on_exit=EmitEvent(event=Shutdown( reason='rviz exited')))) agent_spawner_cmd = Node(package='pedsim_gazebo_plugin', executable='spawn_pedsim_agents.py', name='spawn_pedsim_agents', output='screen') # Create the launch description and populate ld = LaunchDescription() # Declare the launch options ld.add_action(declare_namespace_cmd) ld.add_action(declare_use_namespace_cmd) ld.add_action(declare_map_yaml_cmd) ld.add_action(declare_use_sim_time_cmd) ld.add_action(declare_params_file_cmd) ld.add_action(declare_bt_xml_cmd) ld.add_action(declare_autostart_cmd) ld.add_action(declare_use_remappings_cmd) ld.add_action(declare_rviz_config_file_cmd) ld.add_action(declare_use_simulator_cmd) ld.add_action(declare_use_robot_state_pub_cmd) ld.add_action(declare_use_rviz_cmd) ld.add_action(declare_simulator_cmd) ld.add_action(declare_world_cmd) # Add any conditioned actions ld.add_action(start_gazebo_server_cmd) ld.add_action(start_gazebo_client_cmd) ld.add_action(agent_spawner_cmd) ld.add_action(start_rviz_cmd) ld.add_action(exit_event_handler) # Add the actions to launch all of the navigation nodes ld.add_action(start_robot_state_publisher_cmd) return ld
def generate_launch_description(): # Default nodes to launch respawn_nodes = bool(os.getenv(key="RESPAWN_NODES", default=1)) respawn_delay = float(os.getenv(key="RESPAWN_DELAY", default=5)) log_level = 'info' logger = LaunchConfiguration("log_level") if (os.getenv('ROS_DISTRO') == "dashing") or (os.getenv('ROS_DISTRO') == "eloquent"): return LaunchDescription( declare_configurable_parameters(configurable_parameters) + [ # Realsense launch_ros.actions.Node( condition=IfCondition( PythonExpression( [LaunchConfiguration('config_file'), " == ''"])), package='realsense2_camera', node_namespace=LaunchConfiguration("camera_name"), node_name=LaunchConfiguration("camera_name"), node_executable='realsense2_camera_node', prefix=['stdbuf -o L'], parameters=[ set_configurable_parameters(configurable_parameters) ], output='screen', arguments=[ '--ros-args', '--log-level', LaunchConfiguration('log_level') ], ), launch_ros.actions.Node( condition=IfCondition( PythonExpression( [LaunchConfiguration('config_file'), " != ''"])), package='realsense2_camera', node_namespace=LaunchConfiguration("camera_name"), node_name=LaunchConfiguration("camera_name"), node_executable='realsense2_camera_node', prefix=['stdbuf -o L'], parameters=[ set_configurable_parameters(configurable_parameters), PythonExpression([LaunchConfiguration("config_file")]) ], output='screen', arguments=[ '--ros-args', '--log-level', LaunchConfiguration('log_level') ], ), ]) else: return LaunchDescription( declare_configurable_parameters(configurable_parameters) + [ DeclareLaunchArgument( "log_level", default_value=["info"], description="Logging level", ), # Realsense launch_ros.actions.Node( condition=IfCondition( PythonExpression( [LaunchConfiguration('config_file'), " == ''"])), package='realsense2_camera', namespace=LaunchConfiguration("camera_name"), name=LaunchConfiguration("camera_name"), executable='realsense2_camera_node', parameters=[ set_configurable_parameters(configurable_parameters) ], output='screen', arguments=[ '--ros-args', '--log-level', LaunchConfiguration('log_level') ], emulate_tty=True, respawn=respawn_nodes, respawn_delay=respawn_delay), launch_ros.actions.Node( condition=IfCondition( PythonExpression( [LaunchConfiguration('config_file'), " != ''"])), package='realsense2_camera', namespace=LaunchConfiguration("camera_name"), name=LaunchConfiguration("camera_name"), executable='realsense2_camera_node', parameters=[ set_configurable_parameters(configurable_parameters), PythonExpression([LaunchConfiguration("config_file")]) ], output='screen', arguments=[ '--ros-args', '--log-level', LaunchConfiguration('log_level') ], emulate_tty=True, respawn=respawn_nodes, respawn_delay=respawn_delay), ])
def generate_launch_description(): # Get the launch directory bringup_dir = get_package_share_directory('nav2_bringup') launch_dir = os.path.join(bringup_dir, 'launch') # Create the launch configuration variables slam = LaunchConfiguration('slam') namespace = LaunchConfiguration('namespace') use_namespace = LaunchConfiguration('use_namespace') map_yaml_file = LaunchConfiguration('map') use_sim_time = LaunchConfiguration('use_sim_time') params_file = LaunchConfiguration('params_file') autostart = LaunchConfiguration('autostart') # Launch configuration variables specific to simulation rviz_config_file = LaunchConfiguration('rviz_config_file') use_simulator = LaunchConfiguration('use_simulator') use_robot_state_pub = LaunchConfiguration('use_robot_state_pub') use_rviz = LaunchConfiguration('use_rviz') headless = LaunchConfiguration('headless') world = LaunchConfiguration('world') # Map fully qualified names to relative ones so the node's namespace can be prepended. # In case of the transforms (tf), currently, there doesn't seem to be a better alternative # https://github.com/ros/geometry2/issues/32 # https://github.com/ros/robot_state_publisher/pull/30 # TODO(orduno) Substitute with `PushNodeRemapping` # https://github.com/ros2/launch_ros/issues/56 remappings = [('/tf', 'tf'), ('/tf_static', 'tf_static')] # Declare the launch arguments declare_namespace_cmd = DeclareLaunchArgument( 'namespace', default_value='', description='Top-level namespace') declare_use_namespace_cmd = DeclareLaunchArgument( 'use_namespace', default_value='false', description='Whether to apply a namespace to the navigation stack') declare_slam_cmd = DeclareLaunchArgument( 'slam', default_value='False', description='Whether run a SLAM') declare_map_yaml_cmd = DeclareLaunchArgument( 'map', default_value=os.path.join( bringup_dir, 'maps', 'turtlebot3_world.yaml'), description='Full path to map file to load') declare_use_sim_time_cmd = DeclareLaunchArgument( 'use_sim_time', default_value='true', description='Use simulation (Gazebo) clock if true') declare_params_file_cmd = DeclareLaunchArgument( 'params_file', default_value=os.path.join(bringup_dir, 'params', 'nav2_params.yaml'), description='Full path to the ROS2 parameters file to use for all launched nodes') declare_autostart_cmd = DeclareLaunchArgument( 'autostart', default_value='true', description='Automatically startup the nav2 stack') declare_rviz_config_file_cmd = DeclareLaunchArgument( 'rviz_config_file', default_value=os.path.join( bringup_dir, 'rviz', 'nav2_default_view.rviz'), description='Full path to the RVIZ config file to use') declare_use_simulator_cmd = DeclareLaunchArgument( 'use_simulator', default_value='True', description='Whether to start the simulator') declare_use_robot_state_pub_cmd = DeclareLaunchArgument( 'use_robot_state_pub', default_value='True', description='Whether to start the robot state publisher') declare_use_rviz_cmd = DeclareLaunchArgument( 'use_rviz', default_value='True', description='Whether to start RVIZ') declare_simulator_cmd = DeclareLaunchArgument( 'headless', default_value='False', description='Whether to execute gzclient)') declare_world_cmd = DeclareLaunchArgument( 'world', # TODO(orduno) Switch back once ROS argument passing has been fixed upstream # https://github.com/ROBOTIS-GIT/turtlebot3_simulations/issues/91 # default_value=os.path.join(get_package_share_directory('turtlebot3_gazebo'), # worlds/turtlebot3_worlds/waffle.model') default_value=os.path.join(bringup_dir, 'worlds', 'waffle.model'), description='Full path to world model file to load') # Specify the actions start_gazebo_server_cmd = ExecuteProcess( condition=IfCondition(use_simulator), cmd=['gzserver', '-s', 'libgazebo_ros_init.so', world], cwd=[launch_dir], output='screen') start_gazebo_client_cmd = ExecuteProcess( condition=IfCondition(PythonExpression( [use_simulator, ' and not ', headless])), cmd=['gzclient'], cwd=[launch_dir], output='screen') urdf = os.path.join(bringup_dir, 'urdf', 'turtlebot3_waffle.urdf') start_robot_state_publisher_cmd = Node( condition=IfCondition(use_robot_state_pub), package='robot_state_publisher', executable='robot_state_publisher', name='robot_state_publisher', namespace=namespace, output='screen', parameters=[{'use_sim_time': use_sim_time}], remappings=remappings, arguments=[urdf]) rviz_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(launch_dir, 'rviz_launch.py')), condition=IfCondition(use_rviz), launch_arguments={'namespace': '', 'use_namespace': 'False', 'rviz_config': rviz_config_file}.items()) bringup_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(launch_dir, 'bringup_launch.py')), launch_arguments={'namespace': namespace, 'use_namespace': use_namespace, 'slam': slam, 'map': map_yaml_file, 'use_sim_time': use_sim_time, 'params_file': params_file, 'autostart': autostart}.items()) # Create the launch description and populate ld = LaunchDescription() # Declare the launch options ld.add_action(declare_namespace_cmd) ld.add_action(declare_use_namespace_cmd) ld.add_action(declare_slam_cmd) ld.add_action(declare_map_yaml_cmd) ld.add_action(declare_use_sim_time_cmd) ld.add_action(declare_params_file_cmd) ld.add_action(declare_autostart_cmd) ld.add_action(declare_rviz_config_file_cmd) ld.add_action(declare_use_simulator_cmd) ld.add_action(declare_use_robot_state_pub_cmd) ld.add_action(declare_use_rviz_cmd) ld.add_action(declare_simulator_cmd) ld.add_action(declare_world_cmd) # Add any conditioned actions ld.add_action(start_gazebo_server_cmd) ld.add_action(start_gazebo_client_cmd) # Add the actions to launch all of the navigation nodes ld.add_action(start_robot_state_publisher_cmd) ld.add_action(rviz_cmd) ld.add_action(bringup_cmd) return ld
def generate_launch_description(): """ Launch lidar apollo instance segmentation node """ n = [] lidar_apollo_instance_segmentation_dir = get_package_share_directory( 'lidar_apollo_instance_segmentation') model = LaunchConfiguration('model', default='128') # Arguments n.append( DeclareLaunchArgument('model', default_value='128', description='lidar_model')) n.append( DeclareLaunchArgument( 'prototxt_file', default_value=os.path.join(lidar_apollo_instance_segmentation_dir, 'data/vls-128.prototxt'), description='prototxt file for lidar apollo instance segmentation', condition=IfCondition(PythonExpression([model, '==128'])))) n.append( DeclareLaunchArgument( 'caffemodel_file', default_value=os.path.join(lidar_apollo_instance_segmentation_dir, 'data/vls-128.caffemodel'), description= 'caffemodel file for lidar apollo instance segmentation', condition=IfCondition(PythonExpression([model, '==128'])))) n.append( DeclareLaunchArgument( 'engine_file', default_value=os.path.join(lidar_apollo_instance_segmentation_dir, 'data/vls-128.engine'), description='engine file for lidar apollo instance segmentation', condition=IfCondition(PythonExpression([model, '==128'])))) n.append( DeclareLaunchArgument( 'prototxt_file', default_value=os.path.join(lidar_apollo_instance_segmentation_dir, 'data/hdl-64.prototxt'), description='prototxt file for lidar apollo instance segmentation', condition=IfCondition(PythonExpression([model, '==64'])))) n.append( DeclareLaunchArgument( 'caffemodel_file', default_value=os.path.join(lidar_apollo_instance_segmentation_dir, 'data/hdl-64.caffemodel'), description= 'caffemodel file for lidar apollo instance segmentation', condition=IfCondition(PythonExpression([model, '==64'])))) n.append( DeclareLaunchArgument( 'engine_file', default_value=os.path.join(lidar_apollo_instance_segmentation_dir, 'data/hdl-64.engine'), description='engine file for lidar apollo instance segmentation', condition=IfCondition(PythonExpression([model, '==64'])))) n.append( DeclareLaunchArgument( 'prototxt_file', default_value=os.path.join(lidar_apollo_instance_segmentation_dir, 'data/vlp-16.prototxt'), description='prototxt file for lidar apollo instance segmentation', condition=IfCondition(PythonExpression([model, '==16'])))) n.append( DeclareLaunchArgument( 'caffemodel_file', default_value=os.path.join(lidar_apollo_instance_segmentation_dir, 'data/vlp-16.caffemodel'), description= 'caffemodel file for lidar apollo instance segmentation', condition=IfCondition(PythonExpression([model, '==16'])))) n.append( DeclareLaunchArgument( 'engine_file', default_value=os.path.join(lidar_apollo_instance_segmentation_dir, 'data/vlp-16.engine'), description='engine file for lidar apollo instance segmentation', condition=IfCondition(PythonExpression([model, '==16'])))) n.append( DeclareLaunchArgument('output/objects', default_value='labeled_clusters', description='output topic name')) n.append( DeclareLaunchArgument('target_frame', default_value='base_link', description='target frame')) n.append( DeclareLaunchArgument('z_offset', default_value='-2.0', description='z offset')) # Nodes n.append( Node(package='lidar_apollo_instance_segmentation', node_executable='lidar_apollo_instance_segmentation_node_exe', node_namespace='', node_name='lidar_apollo_instance_segmentation_node', output='screen', parameters=[[ lidar_apollo_instance_segmentation_dir, '/param/model_', LaunchConfiguration('model'), '.yaml' ], { 'prototxt_file': LaunchConfiguration('prototxt_file'), 'caffemodel_file': LaunchConfiguration('caffemodel_file'), 'engine_file': LaunchConfiguration('engine_file'), 'target_frame': LaunchConfiguration('target_frame'), 'z_offset': LaunchConfiguration('z_offset'), }], remappings=[("input/pointcloud", '/points_raw'), ("output/labeled_clusters", LaunchConfiguration('output/objects'))])) return LaunchDescription(n)
def generate_launch_description(): model, plugin, media = GazeboRosPaths.get_paths() if 'GAZEBO_MODEL_PATH' in environ: model += ':' + environ['GAZEBO_MODEL_PATH'] if 'GAZEBO_PLUGIN_PATH' in environ: plugin += ':' + environ['GAZEBO_PLUGIN_PATH'] if 'GAZEBO_RESOURCE_PATH' in environ: media += ':' + environ['GAZEBO_RESOURCE_PATH'] env = { 'GAZEBO_MODEL_PATH': model, 'GAZEBO_PLUGIN_PATH': plugin, 'GAZEBO_RESOURCE_PATH': media } return LaunchDescription([ DeclareLaunchArgument( 'version', default_value='false', description='Set "true" to output version information'), DeclareLaunchArgument( 'verbose', default_value='false', description='Set "true" to increase messages written to terminal'), DeclareLaunchArgument( 'help', default_value='false', description='Set "true" to produce gzclient help message'), DeclareLaunchArgument( 'extra_gazebo_args', default_value='', description='Extra arguments to be passed to Gazebo'), # Specific to gazebo_ros DeclareLaunchArgument( 'gdb', default_value='false', description='Set "true" to run gzserver with gdb'), DeclareLaunchArgument( 'valgrind', default_value='false', description='Set "true" to run gzserver with valgrind'), # Execute ExecuteProcess( cmd=[[ 'gzclient', _boolean_command('version'), ' ', _boolean_command('verbose'), ' ', _boolean_command('help'), ' ', LaunchConfiguration('extra_gazebo_args'), ]], output='screen', additional_env=env, shell=True, prefix=PythonExpression([ '"gdb -ex run --args" if "true" == "', LaunchConfiguration('gdb'), '"else "valgrind" if "true" == "', LaunchConfiguration('valgrind'), '"else ""' ]), ) ])
def generate_launch_description(): # Get the launch directory bringup_dir = get_package_share_directory('nav2_bringup') launch_dir = os.path.join(bringup_dir, 'launch') # Create the launch configuration variables namespace = LaunchConfiguration('namespace') use_namespace = LaunchConfiguration('use_namespace') slam = LaunchConfiguration('slam') map_yaml_file = LaunchConfiguration('map') use_sim_time = LaunchConfiguration('use_sim_time') params_file = LaunchConfiguration('params_file') autostart = LaunchConfiguration('autostart') use_composition = LaunchConfiguration('use_composition') # Map fully qualified names to relative ones so the node's namespace can be prepended. # In case of the transforms (tf), currently, there doesn't seem to be a better alternative # https://github.com/ros/geometry2/issues/32 # https://github.com/ros/robot_state_publisher/pull/30 # TODO(orduno) Substitute with `PushNodeRemapping` # https://github.com/ros2/launch_ros/issues/56 remappings = [('/tf', 'tf'), ('/tf_static', 'tf_static')] # Create our own temporary YAML files that include substitutions param_substitutions = { 'use_sim_time': use_sim_time, 'yaml_filename': map_yaml_file } configured_params = RewrittenYaml(source_file=params_file, root_key=namespace, param_rewrites=param_substitutions, convert_types=True) stdout_linebuf_envvar = SetEnvironmentVariable( 'RCUTILS_LOGGING_BUFFERED_STREAM', '1') declare_namespace_cmd = DeclareLaunchArgument( 'namespace', default_value='', description='Top-level namespace') declare_use_namespace_cmd = DeclareLaunchArgument( 'use_namespace', default_value='false', description='Whether to apply a namespace to the navigation stack') declare_slam_cmd = DeclareLaunchArgument('slam', default_value='False', description='Whether run a SLAM') declare_map_yaml_cmd = DeclareLaunchArgument( 'map', description='Full path to map yaml file to load') declare_use_sim_time_cmd = DeclareLaunchArgument( 'use_sim_time', default_value='false', description='Use simulation (Gazebo) clock if true') declare_params_file_cmd = DeclareLaunchArgument( 'params_file', default_value=os.path.join(bringup_dir, 'params', 'nav2_params.yaml'), description= 'Full path to the ROS2 parameters file to use for all launched nodes') declare_autostart_cmd = DeclareLaunchArgument( 'autostart', default_value='true', description='Automatically startup the nav2 stack') declare_use_composition_cmd = DeclareLaunchArgument( 'use_composition', default_value='True', description='Whether to use composed bringup') # Specify the actions bringup_cmd_group = GroupAction([ PushRosNamespace(condition=IfCondition(use_namespace), namespace=namespace), IncludeLaunchDescription(PythonLaunchDescriptionSource( os.path.join(launch_dir, 'slam_launch.py')), condition=IfCondition(slam), launch_arguments={ 'namespace': namespace, 'use_sim_time': use_sim_time, 'autostart': autostart, 'params_file': params_file }.items()), IncludeLaunchDescription(PythonLaunchDescriptionSource( os.path.join(launch_dir, 'localization_launch.py')), condition=IfCondition( PythonExpression(['not ', slam])), launch_arguments={ 'namespace': namespace, 'map': map_yaml_file, 'use_sim_time': use_sim_time, 'autostart': autostart, 'params_file': params_file }.items()), Node(condition=IfCondition(use_composition), package='nav2_bringup', executable='composed_bringup', output='screen', parameters=[configured_params, { 'autostart': autostart }], remappings=remappings), IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(launch_dir, 'navigation_launch.py')), condition=IfCondition(PythonExpression(['not ', use_composition])), launch_arguments={ 'namespace': namespace, 'use_sim_time': use_sim_time, 'autostart': autostart, 'params_file': params_file }.items()), ]) # Create the launch description and populate ld = LaunchDescription() # Set environment variables ld.add_action(stdout_linebuf_envvar) # Declare the launch options ld.add_action(declare_namespace_cmd) ld.add_action(declare_use_namespace_cmd) ld.add_action(declare_slam_cmd) ld.add_action(declare_map_yaml_cmd) ld.add_action(declare_use_sim_time_cmd) ld.add_action(declare_params_file_cmd) ld.add_action(declare_autostart_cmd) ld.add_action(declare_use_composition_cmd) # Add the actions to launch all of the navigation nodes ld.add_action(bringup_cmd_group) return ld
def generate_launch_description(): # Get the launch directory bringup_dir = get_package_share_directory('nav2_bringup') launch_dir = os.path.join(bringup_dir, 'launch') # Create the launch configuration variables namespace = LaunchConfiguration('namespace') use_namespace = LaunchConfiguration('use_namespace') slam = LaunchConfiguration('slam') map_yaml_file = LaunchConfiguration('map') use_sim_time = LaunchConfiguration('use_sim_time') params_file = LaunchConfiguration('params_file') default_bt_xml_filename = LaunchConfiguration('default_bt_xml_filename') autostart = LaunchConfiguration('autostart') stdout_linebuf_envvar = SetEnvironmentVariable( 'RCUTILS_LOGGING_BUFFERED_STREAM', '1') declare_namespace_cmd = DeclareLaunchArgument( 'namespace', default_value='', description='Top-level namespace') declare_use_namespace_cmd = DeclareLaunchArgument( 'use_namespace', default_value='false', description='Whether to apply a namespace to the navigation stack') declare_slam_cmd = DeclareLaunchArgument('slam', default_value='False', description='Whether run a SLAM') declare_map_yaml_cmd = DeclareLaunchArgument( 'map', description='Full path to map yaml file to load') declare_use_sim_time_cmd = DeclareLaunchArgument( 'use_sim_time', default_value='false', description='Use simulation (Gazebo) clock if true') declare_params_file_cmd = DeclareLaunchArgument( 'params_file', default_value=os.path.join(bringup_dir, 'params', 'nav2_params.yaml'), description= 'Full path to the ROS2 parameters file to use for all launched nodes') declare_bt_xml_cmd = DeclareLaunchArgument( 'default_bt_xml_filename', default_value=os.path.join( get_package_share_directory('nav2_bt_navigator'), 'behavior_trees', 'navigate_w_replanning_and_recovery.xml'), description='Full path to the behavior tree xml file to use') declare_autostart_cmd = DeclareLaunchArgument( 'autostart', default_value='true', description='Automatically startup the nav2 stack') # Specify the actions bringup_cmd_group = GroupAction([ PushRosNamespace(condition=IfCondition(use_namespace), namespace=namespace), IncludeLaunchDescription(PythonLaunchDescriptionSource( os.path.join(launch_dir, 'slam_launch.py')), condition=IfCondition(slam), launch_arguments={ 'namespace': namespace, 'use_sim_time': use_sim_time, 'autostart': autostart, 'params_file': params_file }.items()), IncludeLaunchDescription(PythonLaunchDescriptionSource( os.path.join(launch_dir, 'localization_launch.py')), condition=IfCondition( PythonExpression(['not ', slam])), launch_arguments={ 'namespace': namespace, 'map': map_yaml_file, 'use_sim_time': use_sim_time, 'autostart': autostart, 'params_file': params_file, 'use_lifecycle_mgr': 'false' }.items()), IncludeLaunchDescription(PythonLaunchDescriptionSource( os.path.join(launch_dir, 'navigation_launch.py')), launch_arguments={ 'namespace': namespace, 'use_sim_time': use_sim_time, 'autostart': autostart, 'params_file': params_file, 'default_bt_xml_filename': default_bt_xml_filename, 'use_lifecycle_mgr': 'false', 'map_subscribe_transient_local': 'true' }.items()), ]) # Create the launch description and populate ld = LaunchDescription() # Set environment variables ld.add_action(stdout_linebuf_envvar) # Declare the launch options ld.add_action(declare_namespace_cmd) ld.add_action(declare_use_namespace_cmd) ld.add_action(declare_slam_cmd) ld.add_action(declare_map_yaml_cmd) ld.add_action(declare_use_sim_time_cmd) ld.add_action(declare_params_file_cmd) ld.add_action(declare_autostart_cmd) ld.add_action(declare_bt_xml_cmd) # Add the actions to launch all of the navigation nodes ld.add_action(bringup_cmd_group) return ld
def generate_launch_description(): # Get the launch directory bringup_dir = get_package_share_directory('nav2_bringup') launch_dir = os.path.join(bringup_dir, 'launch') # Create the launch configuration variables namespace = LaunchConfiguration('namespace') map_yaml_file = LaunchConfiguration('map') use_sim_time = LaunchConfiguration('use_sim_time') params_file = LaunchConfiguration('params_file') bt_xml_file = LaunchConfiguration('bt_xml_file') autostart = LaunchConfiguration('autostart') use_remappings = LaunchConfiguration('use_remappings') # Launch configuration variables specific to simulation rviz_config_file = LaunchConfiguration('rviz_config_file') use_simulator = LaunchConfiguration('use_simulator') use_robot_state_pub = LaunchConfiguration('use_robot_state_pub') use_rviz = LaunchConfiguration('use_rviz') headless = LaunchConfiguration('headless') world = LaunchConfiguration('world') # TODO(orduno) Remove once `PushNodeRemapping` is resolved # https://github.com/ros2/launch_ros/issues/56 remappings = [((namespace, '/tf'), '/tf'), ((namespace, '/tf_static'), '/tf_static'), ('/tf', 'tf'), ('/tf_static', 'tf_static')] # Declare the launch arguments declare_namespace_cmd = DeclareLaunchArgument( 'namespace', default_value='', description='Top-level namespace') declare_map_yaml_cmd = DeclareLaunchArgument( 'map', default_value=os.path.join(bringup_dir, 'maps', 'turtlebot3_world.yaml'), description='Full path to map file to load') declare_use_sim_time_cmd = DeclareLaunchArgument( 'use_sim_time', default_value='true', description='Use simulation (Gazebo) clock if true') declare_params_file_cmd = DeclareLaunchArgument( 'params_file', default_value=os.path.join(bringup_dir, 'params', 'nav2_params.yaml'), description= 'Full path to the ROS2 parameters file to use for all launched nodes') declare_bt_xml_cmd = DeclareLaunchArgument( 'bt_xml_file', default_value=os.path.join( get_package_share_directory('nav2_bt_navigator'), 'behavior_trees', 'navigate_w_replanning_and_recovery.xml'), description='Full path to the behavior tree xml file to use') declare_autostart_cmd = DeclareLaunchArgument( 'autostart', default_value='false', description='Automatically startup the nav2 stack') declare_use_remappings_cmd = DeclareLaunchArgument( 'use_remappings', default_value='false', description='Arguments to pass to all nodes launched by the file') declare_rviz_config_file_cmd = DeclareLaunchArgument( 'rviz_config_file', default_value=os.path.join(bringup_dir, 'rviz', 'nav2_default_view.rviz'), description='Full path to the RVIZ config file to use') declare_use_simulator_cmd = DeclareLaunchArgument( 'use_simulator', default_value='True', description='Whether to start the simulator') declare_use_robot_state_pub_cmd = DeclareLaunchArgument( 'use_robot_state_pub', default_value='True', description='Whether to start the robot state publisher') declare_use_rviz_cmd = DeclareLaunchArgument( 'use_rviz', default_value='True', description='Whether to start RVIZ') declare_simulator_cmd = DeclareLaunchArgument( 'headless', default_value='False', description='Whether to execute gzclient)') declare_world_cmd = DeclareLaunchArgument( 'world', # TODO(orduno) Switch back once ROS argument passing has been fixed upstream # https://github.com/ROBOTIS-GIT/turtlebot3_simulations/issues/91 # default_value=os.path.join(get_package_share_directory('turtlebot3_gazebo'), # 'worlds/turtlebot3_worlds/waffle.model'), default_value=os.path.join(bringup_dir, 'worlds', 'waffle.model'), description='Full path to world model file to load') # Specify the actions start_gazebo_server_cmd = ExecuteProcess( condition=IfCondition(use_simulator), cmd=['gzserver', '-s', 'libgazebo_ros_init.so', world], cwd=[launch_dir], output='screen') start_gazebo_client_cmd = ExecuteProcess(condition=IfCondition( PythonExpression([use_simulator, ' and not ', headless])), cmd=['gzclient'], cwd=[launch_dir], output='screen') urdf = os.path.join(get_package_share_directory('turtlebot3_description'), 'urdf', 'turtlebot3_waffle.urdf') start_robot_state_publisher_cmd = Node( condition=IfCondition(use_robot_state_pub), package='robot_state_publisher', node_executable='robot_state_publisher', node_name='robot_state_publisher', output='screen', parameters=[{ 'use_sim_time': use_sim_time }], use_remappings=IfCondition(use_remappings), remappings=remappings, arguments=[urdf]) start_rviz_cmd = Node(condition=IfCondition(use_rviz), package='rviz2', node_executable='rviz2', node_name='rviz2', arguments=['-d', rviz_config_file], output='screen', use_remappings=IfCondition(use_remappings), remappings=[('/tf', 'tf'), ('/tf_static', 'tf_static'), ('goal_pose', 'goal_pose'), ('/clicked_point', 'clicked_point'), ('/initialpose', 'initialpose')]) exit_event_handler = RegisterEventHandler( event_handler=OnProcessExit(target_action=start_rviz_cmd, on_exit=EmitEvent(event=Shutdown( reason='rviz exited')))) bringup_cmd = IncludeLaunchDescription(PythonLaunchDescriptionSource( os.path.join(launch_dir, 'nav2_bringup_launch.py')), launch_arguments={ 'namespace': namespace, 'map': map_yaml_file, 'use_sim_time': use_sim_time, 'params_file': params_file, 'bt_xml_file': bt_xml_file, 'autostart': autostart, 'use_remappings': use_remappings }.items()) # Create the launch description and populate ld = LaunchDescription() # Declare the launch options ld.add_action(declare_namespace_cmd) ld.add_action(declare_map_yaml_cmd) ld.add_action(declare_use_sim_time_cmd) ld.add_action(declare_params_file_cmd) ld.add_action(declare_bt_xml_cmd) ld.add_action(declare_autostart_cmd) ld.add_action(declare_use_remappings_cmd) ld.add_action(declare_rviz_config_file_cmd) ld.add_action(declare_use_simulator_cmd) ld.add_action(declare_use_robot_state_pub_cmd) ld.add_action(declare_use_rviz_cmd) ld.add_action(declare_simulator_cmd) ld.add_action(declare_world_cmd) # Add any conditioned actions ld.add_action(start_gazebo_server_cmd) ld.add_action(start_gazebo_client_cmd) ld.add_action(start_rviz_cmd) # Add other nodes and processes we need ld.add_action(exit_event_handler) # Add the actions to launch all of the navigation nodes ld.add_action(start_robot_state_publisher_cmd) ld.add_action(bringup_cmd) return ld
def generate_launch_description(): return LaunchDescription([ # Arguments DeclareLaunchArgument(name='namespace', default_value='diffbot2', description='Node namespace'), DeclareLaunchArgument(name='robot_name', default_value=LaunchConfiguration('namespace'), description='Robot Name'), DeclareLaunchArgument(name='server_only', default_value='false', description='No gui, only server'), # ign gazebo IncludeLaunchDescription( PythonLaunchDescriptionSource( _path([ FindPackageShare('ros_ign_gazebo'), 'launch', 'ign_gazebo.launch.py' ])), launch_arguments={ 'ign_args': [ '-r ', PythonExpression([ '"-s " if "true" == "', LaunchConfiguration('server_only'), '" else ""' ]), _path([ FindPackageShare('diffbot2_simulation'), 'worlds', 'diffbot2_default.sdf' ]) ] }.items()), # diffbot2_description IncludeLaunchDescription( PythonLaunchDescriptionSource( _path([ FindPackageShare('diffbot2_description'), 'launch', 'spawn_robot.launch.py' ])), launch_arguments={'namespace': LaunchConfiguration('namespace')}.items()), # ros ign bridge Node(package='ros_ign_bridge', namespace=LaunchConfiguration('namespace'), executable='parameter_bridge', arguments=[ [ '/model/', LaunchConfiguration('namespace'), '/cmd_vel@geometry_msgs/msg/[email protected]' ], [ '/model/', LaunchConfiguration('namespace'), '/odometry@nav_msgs/msg/[email protected]' ] ], output='screen', remappings=[ (['/model/', LaunchConfiguration('namespace'), '/cmd_vel'], ['/', LaunchConfiguration('namespace'), '/cmd_vel']), (['/model/', LaunchConfiguration('namespace'), '/odometry'], ['/', LaunchConfiguration('namespace'), '/odometry']) ]), # robot spawn Node(package='ros_ign_gazebo', namespace=LaunchConfiguration('namespace'), executable='create', arguments=[ '-world', 'default', '-string', _xacro_load([ FindPackageShare('diffbot2_description'), 'urdf', 'diffbot2.xacro' ]), '-name', LaunchConfiguration('robot_name'), '-allow_renaming', 'true', '-z', '1' ], output='screen'), ])
def generate_launch_description(): xacro_path = os.path.join(get_package_share_directory('dsr_description2'), 'xacro') drcf_path = os.path.join(get_package_share_directory('common2'), 'bin/DRCF') # RViz2 rviz_config_file = get_package_share_directory( 'dsr_description2') + "/rviz/default.rviz" rviz_node = Node(package='rviz2', executable='rviz2', name='rviz2', output='log', arguments=['-d', rviz_config_file]) #change_permission = ExecuteProcess( # cmd=['chmod', '-R', '775', drcf_path], # output='screen' #) # Run DRCF Emulator DRCF_node = ExecuteProcess(cmd=['sh', [drcf_path, '/run_drcf.sh']], output='screen', condition=IfCondition( PythonExpression([ "'", LaunchConfiguration('mode'), "' == 'virtual'" ]))) # Static TF static_tf = Node( package='tf2_ros', executable='static_transform_publisher', name='static_transform_publisher', output='log', arguments=['0.0', '0.0', '0.0', '0.0', '0.0', '0.0', 'base', 'base_0']) # robot_state_publisher robot_state_publisher = Node( package='robot_state_publisher', executable='robot_state_publisher', name='robot_state_publisher', #output='both', output='screen', parameters=[{ 'robot_description': Command([ 'xacro', ' ', xacro_path, '/', LaunchConfiguration('model'), '.urdf.xacro color:=', LaunchConfiguration('color') ]) }]) # dsr_control2 dsr_control2 = Node( package='dsr_control2', executable='dsr_control_node2', name='dsr_control_node2', output='screen', parameters=[ { "name": LaunchConfiguration('name') }, { "rate": 100 }, { "standby": 5000 }, { "command": True }, { "host": LaunchConfiguration('host') }, { "port": LaunchConfiguration('port') }, { "mode": LaunchConfiguration('mode') }, { "model": LaunchConfiguration('model') }, { "gripper": "none" }, { "mobile": "none" }, #parameters_file_path # 파라미터 설정을 동일이름으로 launch 파일과 yaml 파일에서 할 경우 yaml 파일로 셋팅된다. ]) # rviz2 return LaunchDescription(args + [ #change_permission, DRCF_node, static_tf, robot_state_publisher, rviz_node, dsr_control2, ])
def generate_launch_description(): cmd = [[ 'gzclient', _boolean_command('version'), ' ', _boolean_command('verbose'), ' ', _boolean_command('help'), ' ', LaunchConfiguration('extra_gazebo_args'), ]] model, plugin, media = GazeboRosPaths.get_paths() if 'GAZEBO_MODEL_PATH' in environ: model += pathsep + environ['GAZEBO_MODEL_PATH'] if 'GAZEBO_PLUGIN_PATH' in environ: plugin += pathsep + environ['GAZEBO_PLUGIN_PATH'] if 'GAZEBO_RESOURCE_PATH' in environ: media += pathsep + environ['GAZEBO_RESOURCE_PATH'] env = { 'GAZEBO_MODEL_PATH': model, 'GAZEBO_PLUGIN_PATH': plugin, 'GAZEBO_RESOURCE_PATH': media, } prefix = PythonExpression([ '"gdb -ex run --args" if "true" == "', LaunchConfiguration('gdb'), '"else "valgrind" if "true" == "', LaunchConfiguration('valgrind'), '"else ""', ]) return LaunchDescription([ DeclareLaunchArgument( 'version', default_value='false', description='Set "true" to output version information'), DeclareLaunchArgument( 'verbose', default_value='false', description='Set "true" to increase messages written to terminal'), DeclareLaunchArgument( 'help', default_value='false', description='Set "true" to produce gzclient help message'), DeclareLaunchArgument( 'extra_gazebo_args', default_value='', description='Extra arguments to be passed to Gazebo'), # Specific to gazebo_ros DeclareLaunchArgument( 'gdb', default_value='false', description='Set "true" to run gzserver with gdb'), DeclareLaunchArgument( 'valgrind', default_value='false', description='Set "true" to run gzserver with valgrind'), DeclareLaunchArgument( 'gui_required', default_value='false', description= 'Set "true" to shut down launch script when GUI is terminated'), # Execute node with on_exit=Shutdown if gui_required is specified. # See ros-simulation/gazebo_ros_pkgs#1086. Simplification of logic # would be possible pending ros2/launch#290. ExecuteProcess( cmd=cmd, output='screen', additional_env=env, shell=True, prefix=prefix, on_exit=Shutdown(), condition=IfCondition(LaunchConfiguration('gui_required')), ), # Execute node with default on_exit if the node is not required ExecuteProcess( cmd=cmd, output='screen', additional_env=env, shell=True, prefix=prefix, condition=UnlessCondition(LaunchConfiguration('gui_required')), ), ])
def generate_launch_description(): package_dir = get_package_share_directory('tb3_sim') launch_file_dir = os.path.join(package_dir, 'launch') urdf_file = os.path.join(package_dir, 'urdf', 'turtlebot3_waffle.urdf') # Create the launch configuration variables: slam = LaunchConfiguration('slam') namespace = LaunchConfiguration('namespace') use_namespace = LaunchConfiguration('use_namespace') use_sim_time = LaunchConfiguration('use_sim_time') # Launch configuration variables specific to simulation: use_simulator = LaunchConfiguration('use_simulator') use_robot_state_pub = LaunchConfiguration('use_robot_state_pub') headless = LaunchConfiguration('headless') world = LaunchConfiguration('world') remappings = [('/tf', 'tf'), ('/tf_static', 'tf_static')] # Declare the launch arguments: declare_namespace_cmd = DeclareLaunchArgument( 'namespace', default_value='', description='Top-level namespace') declare_use_namespace_cmd = DeclareLaunchArgument( 'use_namespace', default_value='false', description='Whether to apply a namespace') declare_use_sim_time_cmd = DeclareLaunchArgument( 'use_sim_time', default_value='true', description='Use simulation (Gazebo) clock if true') declare_use_simulator_cmd = DeclareLaunchArgument( 'use_simulator', default_value='True', description='Whether to start the simulator') declare_use_robot_state_pub_cmd = DeclareLaunchArgument( 'use_robot_state_pub', default_value='True', description='Whether to start the robot state publisher') declare_simulator_cmd = DeclareLaunchArgument( 'headless', default_value='False', description='Whether to execute gzclient)') declare_world_cmd = DeclareLaunchArgument( 'world', # TODO(orduno) Switch back once ROS argument passing has been fixed upstream # https://github.com/ROBOTIS-GIT/turtlebot3_simulations/issues/91 # default_value=os.path.join(get_package_share_directory('turtlebot3_gazebo'), # 'worlds/turtlebot3_worlds/waffle.model'), default_value=os.path.join(package_dir, 'worlds', 'waffle.model'), description='Full path to world model file to load') # Actions: start_gazebo_server_cmd = ExecuteProcess( condition=IfCondition(use_simulator), cmd=['gzserver', '--verbose', '-s', 'libgazebo_ros_init.so', world], cwd=[launch_file_dir], output='screen') start_gazebo_client_cmd = ExecuteProcess(condition=IfCondition( PythonExpression([use_simulator, ' and not ', headless])), cmd=['gzclient'], cwd=[launch_file_dir], output='screen') start_robot_state_publisher_cmd = Node( condition=IfCondition(use_robot_state_pub), package='robot_state_publisher', executable='robot_state_publisher', name='robot_state_publisher', namespace=namespace, output='screen', parameters=[{ 'use_sim_time': use_sim_time }], remappings=remappings, arguments=[urdf_file]) ld = LaunchDescription() # Declare the launch options: ld.add_action(declare_namespace_cmd) ld.add_action(declare_use_namespace_cmd) ld.add_action(declare_use_sim_time_cmd) ld.add_action(declare_use_simulator_cmd) ld.add_action(declare_use_robot_state_pub_cmd) ld.add_action(declare_simulator_cmd) ld.add_action(declare_world_cmd) # Add any conditioned actions: ld.add_action(start_gazebo_server_cmd) ld.add_action(start_gazebo_client_cmd) ld.add_action(start_robot_state_publisher_cmd) return ld
def generate_launch_description(): package_dir = get_package_share_directory('ros2_astra_camera') parameters_path = os.path.join(package_dir, 'launch', 'params', 'astra_pro.yaml') urdf = os.path.join(package_dir, 'launch', 'urdf', 'astra_pro.urdf') enable_color_cloud = LaunchConfiguration('enable_color_cloud') declare_enable_color_cloud_cmd = DeclareLaunchArgument( 'enable_color_cloud', default_value='False', description='Whether to enable color cloud') start_depth_image_to_color_cloud_container_cmd = ComposableNodeContainer( name='depth_image_proc_container', namespace='', package='rclcpp_components', executable='component_container', condition=IfCondition(enable_color_cloud), composable_node_descriptions=[ ComposableNode( package='depth_image_proc', plugin='depth_image_proc::PointCloudXyzrgbNode', name='point_cloud_xyzrgb_node', parameters=[{ "queue_size": 5, "exact_sync": False }], remappings=[ ('rgb/camera_info', 'camera/projector/camera_info'), ('rgb/image_rect_color', 'camera/color/image_raw'), ('depth_registered/image_rect', 'camera/depth/image'), ('points', 'camera/depth_registered/points') ], ), ], output='screen', ) start_depth_image_to_cloud_container_cmd = ComposableNodeContainer( name='depth_image_proc_container', namespace='', package='rclcpp_components', executable='component_container', condition=IfCondition(PythonExpression(['not ', enable_color_cloud])), composable_node_descriptions=[ ComposableNode( package='depth_image_proc', plugin='depth_image_proc::PointCloudXyzNode', name='point_cloud_xyz_node', parameters=[{ "queue_size": 5, "exact_sync": False }], remappings=[('camera_info', 'camera/depth/camera_info'), ('image_rect', 'camera/depth/image'), ('points', 'camera/depth/points')], ), ], emulate_tty=True, output='screen', ) start_astra_camera_node_cmd = Node(package="ros2_astra_camera", executable="astra_camera_node", name="astra_camera_node", output="screen", emulate_tty=True, parameters=[parameters_path]) start_uvc_camera_node_cmd = Node(package="ros2_astra_camera", executable="uvc_camera_node", name="uvc_camera_node", output="screen", emulate_tty=True, parameters=[parameters_path]) start_robot_state_publisher_node_cmd = Node( package='robot_state_publisher', executable='robot_state_publisher', name='robot_state_publisher', output='screen', emulate_tty=True, arguments=[urdf]) ld = LaunchDescription() ld.add_action(declare_enable_color_cloud_cmd) ld.add_action(start_depth_image_to_color_cloud_container_cmd) ld.add_action(start_depth_image_to_cloud_container_cmd) ld.add_action(start_astra_camera_node_cmd) ld.add_action(start_uvc_camera_node_cmd) ld.add_action(start_robot_state_publisher_node_cmd) return ld
def generate_launch_description(): model, plugin, media = GazeboRosPaths.get_paths() if 'GAZEBO_MODEL_PATH' in environ: model += ':' + environ['GAZEBO_MODEL_PATH'] if 'GAZEBO_PLUGIN_PATH' in environ: plugin += ':' + environ['GAZEBO_PLUGIN_PATH'] if 'GAZEBO_RESOURCE_PATH' in environ: media += ':' + environ['GAZEBO_RESOURCE_PATH'] env = { 'GAZEBO_MODEL_PATH': model, 'GAZEBO_PLUGIN_PATH': plugin, 'GAZEBO_RESOURCE_PATH': media } return LaunchDescription([ DeclareLaunchArgument('world', default_value='', description='Specify world file name'), DeclareLaunchArgument( 'version', default_value='false', description='Set "true" to output version information.'), DeclareLaunchArgument( 'verbose', default_value='false', description='Set "true" to increase messages written to terminal.' ), DeclareLaunchArgument( 'help', default_value='false', description='Set "true" to produce gzserver help message.'), DeclareLaunchArgument( 'pause', default_value='false', description='Set "true" to start the server in a paused state.'), DeclareLaunchArgument( 'physics', default_value='', description='Specify a physics engine (ode|bullet|dart|simbody).'), DeclareLaunchArgument('play', default_value='', description='Play the specified log file.'), DeclareLaunchArgument('record', default_value='false', description='Set "true" to record state data.'), DeclareLaunchArgument( 'record_encoding', default_value='', description='Specify compression encoding format for log data ' '(zlib|bz2|txt).'), DeclareLaunchArgument( 'record_path', default_value='', description='Absolute path in which to store state data.'), DeclareLaunchArgument( 'record_period', default_value='', description='Specify recording period (seconds).'), DeclareLaunchArgument('record_filter', default_value='', description='Specify recording filter ' '(supports wildcard and regular expression).'), DeclareLaunchArgument( 'seed', default_value='', description='Start with a given a random number seed.'), DeclareLaunchArgument( 'iters', default_value='', description='Specify number of iterations to simulate.'), DeclareLaunchArgument( 'minimal_comms', default_value='false', description='Set "true" to reduce TCP/IP traffic output.'), DeclareLaunchArgument( 'profile', default_value='', description='Specify physics preset profile name from the options ' 'in the world file.'), DeclareLaunchArgument( 'extra_gazebo_args', default_value='', description='Extra arguments to be passed to Gazebo'), # Specific to gazebo_ros DeclareLaunchArgument( 'gdb', default_value='false', description='Set "true" to run gzserver with gdb'), DeclareLaunchArgument( 'valgrind', default_value='false', description='Set "true" to run gzserver with valgrind'), DeclareLaunchArgument( 'init', default_value='true', description='Set "false" not to load "libgazebo_ros_init.so"'), DeclareLaunchArgument( 'factory', default_value='true', description='Set "false" not to load "libgazebo_ros_factory.so"'), # Wait for (https://github.com/ros-simulation/gazebo_ros_pkgs/pull/941) # DeclareLaunchArgument('force_system', default_value='true', # description='Set "false" not to load \ # "libgazebo_ros_force_system.so"'), ExecuteProcess( cmd=[ 'gzserver', # Pass through arguments to gzserver LaunchConfiguration('world'), ' ', _boolean_command('version'), ' ', _boolean_command('verbose'), ' ', _boolean_command('help'), ' ', _boolean_command('pause'), ' ', _arg_command('physics'), ' ', LaunchConfiguration('physics'), ' ', _arg_command('play'), ' ', LaunchConfiguration('play'), ' ', _boolean_command('record'), ' ', _arg_command('record_encoding'), ' ', LaunchConfiguration('record_encoding'), ' ', _arg_command('record_path'), ' ', LaunchConfiguration('record_path'), ' ', _arg_command('record_period'), ' ', LaunchConfiguration('record_period'), ' ', _arg_command('record_filter'), ' ', LaunchConfiguration('record_filter'), ' ', _arg_command('seed'), ' ', LaunchConfiguration('seed'), ' ', _arg_command('iters'), ' ', LaunchConfiguration('iters'), ' ', _boolean_command('minimal_comms'), _plugin_command('init'), ' ', _plugin_command('factory'), ' ', # Wait for (https://github.com/ros-simulation/gazebo_ros_pkgs/pull/941) # _plugin_command('force_system'), ' ', _arg_command('profile'), ' ', LaunchConfiguration('profile'), LaunchConfiguration('extra_gazebo_args'), ], output='screen', additional_env=env, shell=True, prefix=PythonExpression([ '"gdb -ex run --args" if "true" == "', LaunchConfiguration('gdb'), '" else "valgrind" if "true" == "', LaunchConfiguration('valgrind'), '" else ""' ]), ) ])
def generate_launch_description(): default_metrics_config = os.path.join(get_package_share_directory('cloudwatch_robot'), 'config', 'cloudwatch_metrics_config.yaml') default_logs_config = os.path.join(get_package_share_directory('cloudwatch_robot'), 'config', 'cloudwatch_logs_config.yaml') with open(default_metrics_config, 'r') as f: config_text = f.read() config_yaml = yaml.safe_load(config_text) default_aws_metrics_namespace = config_yaml['cloudwatch_metrics_collector']['ros__parameters']['aws_metrics_namespace'] default_aws_region = config_yaml['cloudwatch_metrics_collector']['ros__parameters']['aws_client_configuration']['region'] with open(default_logs_config, 'r') as f: config_text = f.read() config_yaml = yaml.safe_load(config_text) default_log_group_name = config_yaml['cloudwatch_logger']['ros__parameters']['log_group_name'] default_aws_region = os.environ.get('ROS_AWS_REGION', default_aws_region) launch_actions = [ launch.actions.DeclareLaunchArgument( name='aws_region', description='AWS region override, defaults to config .yaml if unset', default_value=default_aws_region ), launch.actions.DeclareLaunchArgument( name='launch_id', description='Used for resource name suffix if specified', default_value=launch.substitutions.EnvironmentVariable('LAUNCH_ID') ), launch.actions.DeclareLaunchArgument( name='metrics_node_name', default_value="cloudwatch_metrics_collector" ), launch.actions.DeclareLaunchArgument( name='aws_metrics_namespace', default_value=default_aws_metrics_namespace ), launch.actions.DeclareLaunchArgument( name='logger_node_name', default_value='cloudwatch_logger' ), launch.actions.DeclareLaunchArgument( name='log_group_name', default_value=default_log_group_name ), launch_ros.actions.Node( package='cloudwatch_robot', node_executable='monitor_speed', node_name='monitor_speed', output='log' ), launch_ros.actions.Node( package='cloudwatch_robot', node_executable='monitor_obstacle_distance', node_name='monitor_obstacle_distance', output='log' ), launch_ros.actions.Node( package='cloudwatch_robot', node_executable='monitor_distance_to_goal', node_name='monitor_distance_to_goal', output='log' ), launch.actions.SetLaunchConfiguration( name='aws_metrics_namespace', value=PythonExpression(["'", LaunchConfiguration('aws_metrics_namespace'), "-", LaunchConfiguration('launch_id'), "'"]), condition=IfCondition(PythonExpression(["'true' if '", LaunchConfiguration('launch_id'), "' else 'false'"])) ), launch.actions.SetLaunchConfiguration( name='log_group_name', value=PythonExpression(["'", LaunchConfiguration('log_group_name'), "-", LaunchConfiguration('launch_id'), "'"]), condition=IfCondition(PythonExpression(["'true' if '", LaunchConfiguration('launch_id'), "' else 'false'"])) ), launch.actions.IncludeLaunchDescription( launch.launch_description_sources.PythonLaunchDescriptionSource( os.path.join(get_package_share_directory('health_metric_collector'), 'launch', 'health_metric_collector.launch.py') ), launch_arguments={ 'config_file': os.path.join(get_package_share_directory('cloudwatch_robot'), 'config', 'health_metrics_config.yaml') }.items() ), launch.actions.IncludeLaunchDescription( launch.launch_description_sources.PythonLaunchDescriptionSource( os.path.join(get_package_share_directory('cloudwatch_metrics_collector'), 'launch', 'cloudwatch_metrics_collector.launch.py') ), launch_arguments={ 'node_name': launch.substitutions.LaunchConfiguration('metrics_node_name'), 'config_file': os.path.join(get_package_share_directory('cloudwatch_robot'), 'config', 'cloudwatch_metrics_config.yaml'), 'aws_region': launch.substitutions.LaunchConfiguration('aws_region'), 'aws_metrics_namespace': launch.substitutions.LaunchConfiguration('aws_metrics_namespace'), }.items() ), launch.actions.IncludeLaunchDescription( launch.launch_description_sources.PythonLaunchDescriptionSource( os.path.join(get_package_share_directory('cloudwatch_logger'), 'launch', 'cloudwatch_logger.launch.py') ), launch_arguments={ 'node_name': launch.substitutions.LaunchConfiguration('logger_node_name'), 'config_file': os.path.join(get_package_share_directory('cloudwatch_robot'), 'config', 'cloudwatch_logs_config.yaml'), 'aws_region': launch.substitutions.LaunchConfiguration('aws_region'), 'log_group_name': launch.substitutions.LaunchConfiguration('log_group_name'), }.items() ), ] ld = launch.LaunchDescription(launch_actions) return ld
def generate_launch_description(): omnivelma_dir = get_package_share_directory('omnivelma_navigation_2') rviz_config_dir = os.path.join(omnivelma_dir, 'rviz2/rviz2_config.rviz') slam = LaunchConfiguration('use_slam') use_slam_cmd = DeclareLaunchArgument(name='use_slam', default_value='False', description="SLAM or localization") rviz_cmd = Node( package='rviz2', executable='rviz2', name='rviz2', arguments=['-d', rviz_config_dir], # output='screen' ) laserscan_merger_cmd = Node(package='omnivelma_navigation_2', executable='laserscan_multi_merger', name='laserscan_multi_merger', output='screen') error_pub_cmd = Node(package='omnivelma_navigation_2', executable='error_publisher', name='error_publisher', output='screen') cov_pub_cmd = Node(package='omnivelma_navigation_2', executable='cov_publisher', name='cov_publisher', output='screen') tf_broadcaster_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(omnivelma_dir, 'launch/tf_broadcaster.launch.py')), ) ekf_odom_cmd = IncludeLaunchDescription( launch.launch_description_sources.PythonLaunchDescriptionSource( os.path.join(omnivelma_dir, 'launch/ekf_odom.launch.py')), ) ekf_map_cmd = IncludeLaunchDescription( launch.launch_description_sources.PythonLaunchDescriptionSource( os.path.join(omnivelma_dir, 'launch/ekf_map.launch.py')), condition=IfCondition(PythonExpression(['not ', slam])), ) # Create the launch description and populate ld = LaunchDescription() ld.add_action(use_slam_cmd) ld.add_action(rviz_cmd) ld.add_action(laserscan_merger_cmd) ld.add_action(error_pub_cmd) ld.add_action(cov_pub_cmd) ld.add_action(tf_broadcaster_cmd) ld.add_action(ekf_odom_cmd) ld.add_action(ekf_map_cmd) return ld
def IfEqualsCondition(arg_name: str, value: str): return IfCondition( PythonExpression( ['"', LaunchConfiguration(arg_name), '" == "', value, '"']))