def generate_robot_launch_description(robot_namespace: str, simulation=False): """Generate robot launch description based on namespace.""" map = LaunchConfiguration("map") namespace = LaunchConfiguration("namespace") use_namespace = LaunchConfiguration("use_namespace") use_sim_time = LaunchConfiguration("use_sim_time") autostart = LaunchConfiguration("autostart") default_bt_xml_filename = LaunchConfiguration("default_bt_xml_filename") params = tempfile.NamedTemporaryFile(mode="w", delete=False) robot_params = os.path.join(get_package_share_directory(robot_namespace), "param", f"{robot_namespace}.yml") navigation_params = os.path.join(get_package_share_directory("robot"), "param", "robot.yml") merged_params = hiyapyco.load([navigation_params, robot_params], method=hiyapyco.METHOD_MERGE) params.file.write(hiyapyco.dump(merged_params)) urdf = os.path.join(get_package_share_directory(robot_namespace), "robot", f"{robot_namespace}.urdf") robot_launch_file_dir = os.path.dirname(__file__) nav2_bt_xml_file = os.path.join( get_package_share_directory("robot"), "behavior_trees", "navigate_w_replanning_time.xml", ) remappings = [("/tf", "tf"), ("/tf_static", "tf_static")] return launch.LaunchDescription([ DeclareLaunchArgument( "namespace", default_value=robot_namespace, description="Robot global namespace", ), DeclareLaunchArgument( "use_namespace", default_value="true", description= "Whether to apply a namespace to the robot stack including navigation2", ), DeclareLaunchArgument("autostart", default_value="true", description="Autostart the nav stack"), DeclareLaunchArgument("use_sim_time", default_value="false", description="Use /clock if true"), DeclareLaunchArgument( "default_bt_xml_filename", default_value=nav2_bt_xml_file, description="Full path to the behavior tree xml file to use", ), GroupAction([ PushRosNamespace(condition=IfCondition(use_namespace), namespace=namespace), Node( package="lcd_driver", executable="lcd_driver", output="screen", parameters=[params.name], remappings=remappings, ), Node( package="robot_state_publisher", executable="robot_state_publisher", output="screen", parameters=[params.name], arguments=[urdf], remappings=remappings, ), Node( package="localisation", executable="localisation", output="screen", parameters=[params.name], remappings=remappings, ), Node( package="cetautomatix", executable="cetautomatix", output="screen", parameters=[params.name], remappings=remappings, ), Node( package="teb_obstacles", executable="teb_obstacles", output="screen", parameters=[], ), IncludeLaunchDescription( PythonLaunchDescriptionSource( [robot_launch_file_dir, "/navigation_launch.py"]), launch_arguments={ "autostart": autostart, "namespace": namespace, "use_sim_time": use_sim_time, "default_bt_xml_filename": default_bt_xml_filename, "params_file": params.name, }.items(), ), ]), IncludeLaunchDescription( PythonLaunchDescriptionSource( [robot_launch_file_dir, "/interfaces.py"]), condition=IfCondition(str(not simulation)), launch_arguments={ "namespace": namespace, "use_namespace": use_namespace, "use_sim_time": use_sim_time, "params_file": params.name, }.items(), ), ])
def generate_launch_description(): gazebo_package_prefix = get_package_share_directory("gazebo_ros") package_prefix = get_package_share_directory("halodi-controller-gazebo") model, plugin, media = GazeboRosPaths.get_paths() return LaunchDescription([ DeclareLaunchArgument( "world", default_value=os.path.join(package_prefix, "worlds", "eve_flat_ground.world"), description="Set world to launch", ), DeclareLaunchArgument( "verbose", default_value="true", description="Enable verbosity", ), # Note that the Halodi Controller publishes /clock and therefore conflicts with gazebo_ros_init # Also, resetting the world state is not currently supported by the controller. # Therefore, we disable the gazebo_ros_init plugin DeclareLaunchArgument( "init", default_value="false", 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"', ), DeclareLaunchArgument( "trajectory-api", default_value="true", description= 'Set "false" to disable trajectory api and use realtime api', ), DeclareLaunchArgument( "headless", default_value="false", description='Set "true" to disable the visual UI', ), SetEnvironmentVariable("HALODI_TRAJECTORY_API", LaunchConfiguration("trajectory-api")), DeclareLaunchArgument( "variable-server", default_value="false", description= 'Set "true" to enable the variable server and use SCSVisualizer to tune variables', ), SetEnvironmentVariable("SCS_VARIABLE_SERVER", LaunchConfiguration("variable-server")), IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(gazebo_package_prefix, "launch", "gzserver.launch.py"))), IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(gazebo_package_prefix, "launch", "gzclient.launch.py")), condition=UnlessCondition(LaunchConfiguration("headless")), ), ])
def generate_launch_description(): map_yaml_file = os.getenv('TEST_MAP') world = os.getenv('TEST_WORLD') urdf = os.getenv('TEST_URDF') sdf = os.getenv('TEST_SDF') bt_xml_file = os.path.join(get_package_share_directory('nav2_bt_navigator'), 'behavior_trees', os.getenv('BT_NAVIGATOR_XML')) bringup_dir = get_package_share_directory('nav2_bringup') robot1_params_file = os.path.join(bringup_dir, # noqa: F841 'params/nav2_multirobot_params_1.yaml') robot2_params_file = os.path.join(bringup_dir, # noqa: F841 'params/nav2_multirobot_params_2.yaml') # Names and poses of the robots robots = [ {'name': 'robot1', 'x_pose': 0.0, 'y_pose': 0.5, 'z_pose': 0.01}, {'name': 'robot2', 'x_pose': 0.0, 'y_pose': -0.5, 'z_pose': 0.01}] # Launch Gazebo server for simulation start_gazebo_cmd = ExecuteProcess( cmd=['gzserver', '-s', 'libgazebo_ros_factory.so', '--minimal_comms', world], output='screen') # Define commands for spawing the robots into Gazebo spawn_robots_cmds = [] for robot in robots: spawn_robots_cmds.append( Node( package='nav2_gazebo_spawner', executable='nav2_gazebo_spawner', output='screen', arguments=[ '--robot_name', TextSubstitution(text=robot['name']), '--robot_namespace', TextSubstitution(text=robot['name']), '--sdf', TextSubstitution(text=sdf), '-x', TextSubstitution(text=str(robot['x_pose'])), '-y', TextSubstitution(text=str(robot['y_pose'])), '-z', TextSubstitution(text=str(robot['z_pose']))] )) # Define commands for launching the robot state publishers robot_state_pubs_cmds = [] for robot in robots: robot_state_pubs_cmds.append( Node( package='robot_state_publisher', executable='robot_state_publisher', namespace=TextSubstitution(text=robot['name']), output='screen', parameters=[{'use_sim_time': 'True'}], remappings=[('/tf', 'tf'), ('/tf_static', 'tf_static')], arguments=[urdf])) # Define commands for launching the navigation instances nav_instances_cmds = [] for robot in robots: params_file = eval(robot['name'] + '_params_file') group = GroupAction([ # Instances use the robot's name for namespace PushRosNamespace(robot['name']), IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(bringup_dir, 'launch', 'bringup_launch.py')), launch_arguments={ 'namespace': robot['name'], 'map': map_yaml_file, 'use_sim_time': 'True', 'params_file': params_file, 'bt_xml_file': bt_xml_file, 'autostart': 'True', 'use_remappings': 'True'}.items()) ]) nav_instances_cmds.append(group) ld = LaunchDescription() ld.add_action(SetEnvironmentVariable('RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1'),) ld.add_action(start_gazebo_cmd) for spawn_robot in spawn_robots_cmds: ld.add_action(spawn_robot) for state_pub in robot_state_pubs_cmds: ld.add_action(state_pub) for nav_instance in nav_instances_cmds: ld.add_action(nav_instance) return ld
def generate_launch_description(): # Get URDF via xacro crane_x7_description_path = os.path.join( get_package_share_directory('crane_x7_description')) xacro_file = os.path.join(crane_x7_description_path, 'urdf', 'crane_x7.urdf.xacro') robot_description = {'robot_description': Command(['xacro ', xacro_file, ' use_gazebo:=false'])} crane_x7_controllers_config = os.path.join( get_package_share_directory('crane_x7_control'), 'config', 'crane_x7_controllers.yaml' ) rviz_config= os.path.join(crane_x7_description_path, 'config', 'display.rviz') spawn_robot_state_publisher = Node( package='robot_state_publisher', executable='robot_state_publisher', name='robot_state_publisher', parameters=[robot_description], output='screen' ) spawn_controller_manager = Node( package='controller_manager', executable='ros2_control_node', parameters=[robot_description, crane_x7_controllers_config], output={'stdout': 'screen', 'stderr': 'screen', }, ) spawn_joint_state_broadcaster = Node( package='controller_manager', executable='spawner.py', arguments=['joint_state_broadcaster', '--controller-manager', '/controller_manager'], ) spawn_joint_velocity_controller = Node( package="controller_manager", executable="spawner.py", arguments=["joint_velocity_controller", "-c", "/controller_manager"], ) spawn_mpc = IncludeLaunchDescription( PythonLaunchDescriptionSource([os.path.join( get_package_share_directory('crane_x7_mpc'), 'launch'), '/crane_x7_mpc.launch.py']), ) rviz = Node( package='rviz2', executable='rviz2', name='rviz2', output='log', arguments=['-d', rviz_config] ) return LaunchDescription([ spawn_robot_state_publisher, spawn_controller_manager, spawn_joint_state_broadcaster, spawn_joint_velocity_controller, spawn_mpc, rviz, ])
def generate_launch_description(): """ Launch all nodes defined in the architecture for Milestone 3 of the AVP 2020 Demo. More details about what is included can be found at https://gitlab.com/autowarefoundation/autoware.auto/AutowareAuto/-/milestones/25. """ avp_demo_pkg_prefix = get_package_share_directory('autoware_auto_avp_demo') lgsvl_param_file = os.path.join( avp_demo_pkg_prefix, 'param/lgsvl_interface.param.yaml') map_publisher_param_file = os.path.join( avp_demo_pkg_prefix, 'param/map_publisher.param.yaml') ndt_localizer_param_file = os.path.join( avp_demo_pkg_prefix, 'param/ndt_localizer.param.yaml') mpc_param_file = os.path.join( avp_demo_pkg_prefix, 'param/mpc.param.yaml') pc_filter_transform_pkg_prefix = get_package_share_directory( 'point_cloud_filter_transform_nodes') pc_filter_transform_param_file = os.path.join( pc_filter_transform_pkg_prefix, 'param/vlp16_sim_lexus_filter_transform.param.yaml') urdf_pkg_prefix = get_package_share_directory('lexus_rx_450h_description') urdf_path = os.path.join(urdf_pkg_prefix, 'urdf/lexus_rx_450h.urdf') # Arguments lgsvl_interface_param = DeclareLaunchArgument( 'lgsvl_interface_param_file', default_value=lgsvl_param_file, description='Path to config file for LGSVL Interface' ) map_publisher_param = DeclareLaunchArgument( 'map_publisher_param_file', default_value=map_publisher_param_file, description='Path to config file for Map Publisher' ) ndt_localizer_param = DeclareLaunchArgument( 'ndt_localizer_param_file', default_value=ndt_localizer_param_file, description='Path to config file for ndt localizer' ) mpc_param = DeclareLaunchArgument( 'mpc_param_file', default_value=mpc_param_file, description='Path to config file for MPC' ) pc_filter_transform_param = DeclareLaunchArgument( 'pc_filter_transform_param_file', default_value=pc_filter_transform_param_file, description='Path to config file for Point Cloud Filter/Transform Nodes' ) # Nodes lgsvl_interface = Node( package='lgsvl_interface', node_executable='lgsvl_interface_exe', node_namespace='vehicle', output='screen', parameters=[ LaunchConfiguration('lgsvl_interface_param_file'), {"lgsvl.publish_tf": "true"} ], remappings=[ ("vehicle_control_cmd", "/lgsvl/vehicle_control_cmd"), ("vehicle_state_cmd", "/lgsvl/vehicle_state_cmd"), ("state_report", "/lgsvl/state_report"), ("state_report_out", "/vehicle/state_report"), ("gnss_odom", "/lgsvl/gnss_odom"), ("vehicle_odom", "/lgsvl/vehicle_odom") ] ) filter_transform_vlp16_front = Node( package='point_cloud_filter_transform_nodes', node_executable='point_cloud_filter_transform_node_exe', node_name='filter_transform_vlp16_front', node_namespace='lidar_front', parameters=[LaunchConfiguration('pc_filter_transform_param_file')], remappings=[("points_in", "points_raw")] ) filter_transform_vlp16_rear = Node( package='point_cloud_filter_transform_nodes', node_executable='point_cloud_filter_transform_node_exe', node_name='filter_transform_vlp16_rear', node_namespace='lidar_rear', parameters=[LaunchConfiguration('pc_filter_transform_param_file')], remappings=[("points_in", "points_raw")] ) map_publisher = Node( package='ndt_nodes', node_executable='ndt_map_publisher_exe', node_namespace='localization', parameters=[LaunchConfiguration('map_publisher_param_file')] ) urdf_publisher = Node( package='robot_state_publisher', node_executable='robot_state_publisher', node_name='robot_state_publisher', arguments=[str(urdf_path)] ) ndt_localizer = Node( package='ndt_nodes', node_executable='p2d_ndt_localizer_exe', node_namespace='localization', node_name='p2d_ndt_localizer_node', parameters=[LaunchConfiguration('ndt_localizer_param_file')], remappings=[ ("points_in", "/lidars/points_fused_downsampled"), ("observation_republish", "/lidars/points_fused_viz"), ] ) mpc = Node( package='mpc_controller_node', node_executable='mpc_controller_node_exe', node_name='mpc_controller', node_namespace='control', parameters=[LaunchConfiguration('mpc_param_file')] ) core_launch = IncludeLaunchDescription( PythonLaunchDescriptionSource([avp_demo_pkg_prefix, '/launch/ms3_core.launch.py']), launch_arguments={}.items() ) return LaunchDescription([ lgsvl_interface_param, map_publisher_param, ndt_localizer_param, mpc_param, pc_filter_transform_param, urdf_publisher, lgsvl_interface, map_publisher, ndt_localizer, mpc, filter_transform_vlp16_front, filter_transform_vlp16_rear, core_launch, ])
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(): # ros2 run --prefix 'gdb -ex run --args' nav2_planner planner_server --ros-args -r __node:=planner_server --params-file /home/ubuntu/social_nav2_ws/src/social_nav2/social_nav2_bringup/params/nav2_params.yaml # Get the launch directory exp_bringup_dir = get_package_share_directory('social_nav2_exp_bringup') scene_file = LaunchConfiguration('scene_file') simulation_factor = LaunchConfiguration('simulation_factor') social_bringup_dir = get_package_share_directory('social_nav2_bringup') launch_dir = os.path.join(social_bringup_dir, 'launch') # Create the launch configuration variables namespace = LaunchConfiguration('namespace') frame_id = LaunchConfiguration('frame_id') declare_scene_file_cmd = DeclareLaunchArgument( 'scene_file', default_value=os.path.join(exp_bringup_dir, 'scenarios', 'escorting.xml'), description='') declare_simulation_factor_cmd = DeclareLaunchArgument( 'simulation_factor', default_value='0.15', description='Simulator factor. 0.0 to get static agents') declare_frame_id_cmd = DeclareLaunchArgument('frame_id', default_value='map', description='Reference frame') social_nav_bringup_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(launch_dir, 'social_nav_launch.py'))) social_goal_updater_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join( get_package_share_directory('social_nav2_goal_updaters'), 'launch', 'social_goal_updaters_launch.py'))) escort_controller_cmd = Node(package='social_nav2_experiments', executable='social_nav2_hri', name='social_nav2_hri', output='screen') escort_sim = IncludeLaunchDescription(PythonLaunchDescriptionSource( os.path.join(exp_bringup_dir, 'launch', 'escort_sim_launch.py')), launch_arguments={ 'scene_file': scene_file, 'simulation_factor': simulation_factor }.items()) distance_to_agent_cmd = Node(package='measuring_tools', executable='distance_to_agent_node', name='distance_to_agent_node', output='screen', arguments=["agent_1"]) robot_cost_cmd = Node(package='measuring_tools', executable='robot_cost_node', name='robot_cost_node', output='screen') path_cmd = Node(package='measuring_tools', executable='path_pub_node', name='path_pub_node', output='screen') topics_2_csv_cmd = Node(package='social_nav2_csv', executable='exp2_topics_2_csv', name='exp2_topics_2_csv', output='screen') # Create the launch description and populate ld = LaunchDescription() ld.add_action(declare_scene_file_cmd) ld.add_action(declare_simulation_factor_cmd) ld.add_action(declare_frame_id_cmd) ld.add_action(distance_to_agent_cmd) ld.add_action(path_cmd) #ld.add_action(topics_2_csv_cmd) ld.add_action(social_goal_updater_cmd) ld.add_action(escort_sim) ld.add_action(social_nav_bringup_cmd) return ld
def generate_launch_description(): ld = LaunchDescription([ # World path argument DeclareLaunchArgument( 'world_path', default_value= default_world_path, description='Provide full world file path and name'), LogInfo(msg=LaunchConfiguration('world_path')), ]) # Get path to gazebo package gazebo_package_prefix = get_package_share_directory('gazebo_ros') # Launch gazebo servo with world file from world_path gazebo_server = IncludeLaunchDescription( PythonLaunchDescriptionSource([gazebo_package_prefix,'/launch/gzserver.launch.py']), launch_arguments={'world': LaunchConfiguration('world_path')}.items(), ) ld.add_action(gazebo_server) instance = 0 for model_params in models: base_model = str(models[model_params]["base_model"]) spawn_pose = models[model_params]["spawn_pose"] sdf_version = str(models[model_params]["sdf_version"]) mavlink_tcp_port = str(models[model_params]["mavlink_tcp_port"]) mavlink_udp_port = str(models[model_params]["mavlink_udp_port"]) qgc_udp_port = str(models[model_params]["qgc_udp_port"]) sdk_udp_port = str(models[model_params]["sdk_udp_port"]) serial_enabled = str(models[model_params]["serial_enabled"]) serial_device = str(models[model_params]["serial_device"]) serial_baudrate = str(models[model_params]["serial_baudrate"]) enable_lockstep = str(models[model_params]["enable_lockstep"]) hil_mode = str(models[model_params]["hil_mode"]) sdf_output_path = str(models[model_params]["output_path"]) config_file = str(models[model_params]["config_file"]) if models[model_params]["model_name"] == "NotSet": model_name = 'sitl_tii_{:s}_{:d}'.format(base_model,instance) else: model_name = models[model_params]["model_name"] if sdf_output_path == "0": sdf_output_path = "/tmp" # Path for PX4 binary storage sitl_output_path = '/tmp/{:s}'.format(model_name) generate_args = '''--base_model "{:s}" --sdf_version "{:s}" --mavlink_tcp_port "{:s}" --mavlink_udp_port "{:s}" --qgc_udp_port "{:s}" --sdk_udp_port "{:s}" --serial_enabled "{:s}" --serial_device "{:s}" --serial_baudrate "{:s}" --enable_lockstep "{:s}" --hil_mode "{:s}" --model_name "{:s}" --output_path "{:s}" --config_file "{:s}"'''.format( base_model, sdf_version, mavlink_tcp_port, mavlink_udp_port, qgc_udp_port, sdk_udp_port, serial_enabled, serial_device, serial_baudrate, enable_lockstep, hil_mode, model_name, sdf_output_path, config_file).replace("\n","").replace(" ","") generate_model = ['''python3 /home/{:s}/git/tii_gazebo/scripts/jinja_model_gen.py {:s}'''.format(user_name, generate_args).replace("\n","").replace(" ","")] # Command to make storage folder sitl_folder_cmd = ['mkdir -p \"{:s}\"'.format(sitl_output_path)] latitude_vehicle = float(latitude) + ((float(spawn_pose[1])/6378137.0)*(180.0/np.pi)) longitude_vehicle = float(longitude) + ((float(spawn_pose[0])/ (6378137.0*np.cos((np.pi*float(latitude))/180.0)))*(180.0/np.pi)) altitude_vehicle = float(altitude) + float(spawn_pose[2]) px4_env = '''export PX4_SIM_MODEL=\"{:s}\"; export PX4_HOME_LAT={:s}; export PX4_HOME_LON={:s}; export PX4_HOME_ALT={:s};'''.format( base_model, str(latitude_vehicle), str(longitude_vehicle), str(altitude_vehicle)).replace("\n","").replace(" ","") # Command to export model and run PX4 binary px4_cmd = '''{:s} eval \"\"{:s}/bin/px4\" -w {:s} \"{:s}/etc\" -s etc/init.d-posix/rcS -i {:d}\"; bash'''.format( px4_env, px4_path, sitl_output_path, px4_path, instance) # Xterm command to name xterm window and run px4_cmd xterm_px4_cmd = ['''xterm -hold -T \"PX4 NSH {:s}\" -n \"PX4 NSH {:s}\" -e \'{:s}\''''.format( sitl_output_path, sitl_output_path, px4_cmd).replace("\n","").replace(" ","")] jinja_generate = ExecuteProcess( cmd=generate_model, name='jinja_gen_{:s}'.format(model_name), shell=True, output='screen') ld.add_action(jinja_generate) # Make storage command make_sitl_folder = ExecuteProcess( cmd=sitl_folder_cmd, name='make_sitl_folder_{:s}'.format(model_name), shell=True) ld.add_action(make_sitl_folder) # Run PX4 binary px4_posix = ExecuteProcess( cmd=xterm_px4_cmd, name='xterm_px4_nsh_{:s}'.format(model_name), shell=True) ld.add_action(px4_posix) # GAZEBO_MODEL_PATH has to be correctly set for Gazebo to be able to find the model spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py', arguments=['-entity', '{:s}'.format(model_name), '-x', str(spawn_pose[0]), '-y', str(spawn_pose[1]), '-z', str(spawn_pose[2]), '-R', str(spawn_pose[3]), '-P', str(spawn_pose[4]), '-Y', str(spawn_pose[5]), '-file', '{:s}/{:s}.sdf'.format(sdf_output_path, model_name)], name='spawn_{:s}'.format(model_name), output='screen') ld.add_action(spawn_entity) instance += 1 # Launch gazebo client gazebo_client = IncludeLaunchDescription( PythonLaunchDescriptionSource([gazebo_package_prefix,'/launch/gzclient.launch.py'])) LogInfo(msg="\nWaiting to launch Gazebo Client...\n") sleep(2) ld.add_action(gazebo_client) return ld
def generate_launch_description(): # Get the launch directory nav2_bringup_dir = get_package_share_directory('nav2_bringup') marathon_dir = get_package_share_directory('marathon_ros2_bringup') marathon_launch_dir = os.path.join(marathon_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') default_bt_xml_file = LaunchConfiguration('default_bt_xml_file') autostart = LaunchConfiguration('autostart') cmd_vel_topic = LaunchConfiguration('cmd_vel_topic') # Launch configuration variables specific to simulation rviz_config_file = LaunchConfiguration('rviz_config_file') use_rviz = LaunchConfiguration('use_rviz') # 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_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(marathon_dir, 'maps/aulario', 'map.yaml'), description='Full path to map 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(marathon_dir, 'params', 'nav2_pp_tiago_params.yaml'), description= 'Full path to the ROS2 parameters file to use for all launched nodes') #declare_params_file_cmd = DeclareLaunchArgument( # 'params_file', # default_value=os.path.join(nav2_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_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='true', description='Automatically startup the nav2 stack') declare_rviz_config_file_cmd = DeclareLaunchArgument( 'rviz_config_file', default_value=os.path.join(nav2_bringup_dir, 'rviz', 'nav2_default_view.rviz'), description='Full path to the RVIZ config file to use') declare_use_rviz_cmd = DeclareLaunchArgument( 'use_rviz', default_value='True', description='Whether to start RVIZ') declare_cmd_vel_topic_cmd = DeclareLaunchArgument( 'cmd_vel_topic', default_value='nav_vel', description='Command velocity topic') start_rviz_cmd = Node(condition=IfCondition(use_rviz), package='rviz2', executable='rviz2', arguments=['-d', rviz_config_file], output='log', 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(marathon_launch_dir, 'nav2_bringup_launch.py')), launch_arguments={ 'namespace': namespace, 'use_namespace': use_namespace, 'map': map_yaml_file, 'use_sim_time': use_sim_time, 'params_file': params_file, 'bt_xml_file': default_bt_xml_file, 'autostart': autostart, 'cmd_vel_topic': cmd_vel_topic }.items()) # contextual_cmd = IncludeLaunchDescription( # PythonLaunchDescriptionSource(os.path.join(marathon_launch_dir, 'nav2_contextual_launch.py')), # launch_arguments={'next_wp': '0'}.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_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_rviz_config_file_cmd) ld.add_action(declare_use_rviz_cmd) ld.add_action(declare_cmd_vel_topic_cmd) # Add any conditioned actions ld.add_action(start_rviz_cmd) # Add other nodes and processes we need ld.add_action(exit_event_handler) # ld.add_action(contextual_cmd) # Add the actions to launch all of the navigation nodes ld.add_action(bringup_cmd) return ld
def generate_test_description(): #path_to_test = os.path.dirname(__file__) file_path = pathlib.Path(__file__) # Here, parent first removes the file name parent_file_path = pathlib.Path(__file__).parent thruster_manager_launch = os.path.join( get_package_share_directory('uuv_thruster_manager'), 'launch', 'thruster_manager.launch' ) thruster_manager_yaml = os.path.join( str(parent_file_path), 'test_vehicle_thruster_manager_proportional.yaml' ) xacro_file = os.path.join( str(parent_file_path), 'test_vehicle_z_axis.urdf.xacro' ) output = os.path.join( str(parent_file_path), 'robot_description_z_axis.urdf' ) doc = xacro.process(xacro_file) ensure_path_exists(output) try: with open(output, 'w') as file_out: file_out.write(doc) except IOError as e: print("Failed to open output: ", exc=e) args = output.split() launch_args = [('model_name', 'test_vehicle'), ('output_dir', '/tmp'), ('config_file', thruster_manager_yaml), ('reset_tam', 'true'), ('urdf_file', output)] thruster_manager_launch_desc = IncludeLaunchDescription( AnyLaunchDescriptionSource(thruster_manager_launch), launch_arguments=launch_args) joint_state_publisher = launch_ros.actions.Node( node_namespace = 'test_vehicle', package="joint_state_publisher", node_executable="joint_state_publisher", node_name="joint_state_publisher", arguments=args, output='screen', parameters=[{'use_sim_time':False}, {'rate': 100}], ) robot_state_description = launch_ros.actions.Node( node_namespace = 'test_vehicle', package='robot_state_publisher', node_executable='robot_state_publisher', # TODO To replace in foxy with parameters=[{'robot_description', Command('ros2 run xacro...')}] arguments=args, output='screen', parameters=[{'use_sim_time':False}], # Use subst here ) return ( launch.LaunchDescription([ joint_state_publisher, robot_state_description, thruster_manager_launch_desc, launch_testing.actions.ReadyToTest(), ]) )
def generate_launch_description(): # Declare arguments declared_arguments = [] declared_arguments.append( DeclareLaunchArgument( "robot_ip", description="IP address by which the robot can be reached.", ) ) declared_arguments.append( DeclareLaunchArgument( "use_fake_hardware", default_value="false", description="Start robot with fake hardware mirroring command to its states.", ) ) declared_arguments.append( DeclareLaunchArgument( "fake_sensor_commands", default_value="false", description="Enable fake command interfaces for sensors used for simple simulations. \ Used only if 'use_fake_hardware' parameter is true.", ) ) declared_arguments.append( DeclareLaunchArgument( "initial_joint_controller", default_value="scaled_joint_trajectory_controller", description="Initially loaded robot controller.", choices=[ "scaled_joint_trajectory_controller", "joint_trajectory_controller", "forward_velocity_controller", "forward_position_controller", ], ) ) declared_arguments.append( DeclareLaunchArgument( "activate_joint_controller", default_value="true", description="Activate loaded joint controller.", ) ) # Initialize Arguments robot_ip = LaunchConfiguration("robot_ip") use_fake_hardware = LaunchConfiguration("use_fake_hardware") fake_sensor_commands = LaunchConfiguration("fake_sensor_commands") initial_joint_controller = LaunchConfiguration("initial_joint_controller") activate_joint_controller = LaunchConfiguration("activate_joint_controller") base_launch = IncludeLaunchDescription( PythonLaunchDescriptionSource([ThisLaunchFileDir(), "/ur_control.launch.py"]), launch_arguments={ "ur_type": "ur5", "robot_ip": robot_ip, "use_fake_hardware": use_fake_hardware, "fake_sensor_commands": fake_sensor_commands, "initial_joint_controller": initial_joint_controller, "activate_joint_controller": activate_joint_controller, }.items(), ) return LaunchDescription(declared_arguments + [base_launch])
def generate_launch_description(): # Get the launch directory bringup_dir = get_package_share_directory('nav2_bringup') mod_bringup_dir = get_package_share_directory('rsb_nav2') launch_dir = os.path.join(bringup_dir, 'launch') # Names and poses of the robots robots = [ {'name': 'robot1', 'x_pose': 0.0, 'y_pose': 0.5, 'z_pose': 0.01}, {'name': 'robot2', 'x_pose': 0.0, 'y_pose': -0.5, 'z_pose': 0.01} ] # Simulation settings world = LaunchConfiguration('world') simulator = LaunchConfiguration('simulator') # On this example all robots are launched with the same settings map_yaml_file = LaunchConfiguration('map') default_bt_xml_filename = LaunchConfiguration('default_bt_xml_filename') autostart = LaunchConfiguration('autostart') rviz_config_file = LaunchConfiguration('rviz_config') use_robot_state_pub = LaunchConfiguration('use_robot_state_pub') use_rviz = LaunchConfiguration('use_rviz') log_settings = LaunchConfiguration('log_settings', default='true') # Declare the launch arguments declare_world_cmd = DeclareLaunchArgument( 'world', default_value=os.path.join(bringup_dir, 'worlds', 'world_only.model'), description='Full path to world file to load') declare_simulator_cmd = DeclareLaunchArgument( 'simulator', default_value='gazebo', description='The simulator to use (gazebo or gzserver)') 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_robot1_params_file_cmd = DeclareLaunchArgument( 'robot1_params_file', default_value=os.path.join(mod_bringup_dir, 'params', 'nav2_multirobot_params_1.yaml'), #MOD description='Full path to the ROS2 parameters file to use for robot1 launched nodes') declare_robot2_params_file_cmd = DeclareLaunchArgument( 'robot2_params_file', default_value=os.path.join(mod_bringup_dir, 'params', 'nav2_multirobot_params_2.yaml'), #MOD description='Full path to the ROS2 parameters file to use for robot2 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 stacks') declare_rviz_config_file_cmd = DeclareLaunchArgument( 'rviz_config', default_value=os.path.join(bringup_dir, 'rviz', 'nav2_namespaced_view.rviz'), description='Full path to the RVIZ config file to use.') 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') # Start Gazebo with plugin providing the robot spawing service start_gazebo_cmd = ExecuteProcess( cmd=[simulator, '--verbose', '-s', 'libgazebo_ros_factory.so', world], output='screen') #rviz_config_1 = DeclareLaunchArgument( # 'rviz_config_1', # default_value=os.path.join(pkg_dir, 'rviz', 'robot1_config.rviz'), # description='Full path to the RViz config file to use.') #rviz_config_2 = DeclareLaunchArgument( # 'rviz_config_2', # default_value=os.path.join(pkg_dir, 'rviz', 'robot2_config.rviz'), # description='Full path to the RViz config file to use.') #rviz_config_list = [rviz_config_1, rviz_config_2] # Define commands for spawing the robots into Gazebo spawn_robots_cmds = [] for robot in robots: spawn_robots_cmds.append( IncludeLaunchDescription( PythonLaunchDescriptionSource(os.path.join(bringup_dir, 'launch', 'spawn_tb3_launch.py')), launch_arguments={ 'x_pose': TextSubstitution(text=str(robot['x_pose'])), 'y_pose': TextSubstitution(text=str(robot['y_pose'])), 'z_pose': TextSubstitution(text=str(robot['z_pose'])), 'robot_name': robot['name'], 'turtlebot_type': TextSubstitution(text='waffle') }.items())) # Define commands for launching the navigation instances nav_instances_cmds = [] for robot in robots: params_file = LaunchConfiguration(robot['name'] + '_params_file') group = GroupAction([ IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(launch_dir, 'rviz_launch.py')), condition=IfCondition(use_rviz), launch_arguments={ 'namespace': TextSubstitution(text=robot['name']), 'use_namespace': 'True', 'rviz_config': rviz_config_file}.items()), IncludeLaunchDescription( PythonLaunchDescriptionSource(os.path.join(bringup_dir, 'launch', 'tb3_simulation_launch.py')), launch_arguments={'namespace': robot['name'], 'use_namespace': 'True', 'map': map_yaml_file, 'use_sim_time': 'True', 'params_file': params_file, 'default_bt_xml_filename': default_bt_xml_filename, 'autostart': autostart, 'use_rviz': 'False', 'use_simulator': 'False', 'headless': 'False', 'use_robot_state_pub': use_robot_state_pub}.items()), LogInfo( condition=IfCondition(log_settings), msg=['Launching ', robot['name']]), LogInfo( condition=IfCondition(log_settings), msg=[robot['name'], ' map yaml: ', map_yaml_file]), LogInfo( condition=IfCondition(log_settings), msg=[robot['name'], ' params yaml: ', params_file]), LogInfo( condition=IfCondition(log_settings), msg=[robot['name'], ' behavior tree xml: ', default_bt_xml_filename]), LogInfo( condition=IfCondition(log_settings), msg=[robot['name'], ' rviz config file: ', rviz_config_file]), LogInfo( condition=IfCondition(log_settings), msg=[robot['name'], ' using robot state pub: ', use_robot_state_pub]), LogInfo( condition=IfCondition(log_settings), msg=[robot['name'], ' autostart: ', autostart]) ]) nav_instances_cmds.append(group) # Create the launch description and populate ld = LaunchDescription() # Declare the launch options ld.add_action(declare_robot1_params_file_cmd) ld.add_action(declare_robot2_params_file_cmd) ld.add_action(declare_bt_xml_cmd) ld.add_action(declare_autostart_cmd) ld.add_action(declare_rviz_config_file_cmd) ld.add_action(declare_use_robot_state_pub_cmd) ld.add_action(declare_use_rviz_cmd) ld.add_action(declare_map_yaml_cmd) ld.add_action(declare_simulator_cmd) ld.add_action(declare_world_cmd) # Add the actions to start gazebo, robots and simulations ld.add_action(start_gazebo_cmd) for spawn_robot_cmd in spawn_robots_cmds: ld.add_action(spawn_robot_cmd) sleep(1) for simulation_instance_cmd in nav_instances_cmds: ld.add_action(simulation_instance_cmd) return ld
def generate_launch_description(): # ROS packages pkg_mammoth_gazebo = get_package_share_directory('mammoth_gazebo') pkg_robot_state_controller = get_package_share_directory( 'robot_state_controller') pkg_teleop_twist_joy = get_package_share_directory('teleop_twist_joy') # Config joy_config = os.path.join(pkg_mammoth_gazebo, 'config/joystick', 'xbone.config.yaml') # Launch arguments drive_mode_switch_button = LaunchConfiguration('drive_mode_switch_button', default='8') use_sim_time = LaunchConfiguration('use_sim_time', default='true') use_rviz = LaunchConfiguration('use_rviz', default='true') follow_waypoints = LaunchConfiguration('follow_waypoints', default='false') # Nodes state_publishers = IncludeLaunchDescription( PythonLaunchDescriptionSource([ os.path.join(pkg_mammoth_gazebo, 'launch'), '/include/state_publishers/state_publishers.launch.py' ]), launch_arguments={'use_sim_time': use_sim_time}.items(), ) ign_gazebo = IncludeLaunchDescription( PythonLaunchDescriptionSource([ os.path.join(pkg_mammoth_gazebo, 'launch'), '/include/gazebo/gazebo.launch.py' ]), ) joy_with_teleop_twist = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(pkg_teleop_twist_joy, 'launch', 'teleop-launch.py')), launch_arguments={ 'joy_config': 'xbox', 'joy_dev': '/dev/input/js0', 'config_filepath': joy_config }.items(), ) lidar_processor = IncludeLaunchDescription( PythonLaunchDescriptionSource([ os.path.join(pkg_mammoth_gazebo, 'launch'), '/include/lidar_processor/lidar_processor.launch.py' ]), launch_arguments={'use_sim_time': use_sim_time}.items(), ) pointcloud_to_laserscan = IncludeLaunchDescription( PythonLaunchDescriptionSource([ os.path.join(pkg_mammoth_gazebo, 'launch'), '/include/pointcloud_to_laserscan/pointcloud_to_laserscan.launch.py' ]), launch_arguments={'use_sim_time': use_sim_time}.items(), ) navigation = IncludeLaunchDescription( PythonLaunchDescriptionSource([ os.path.join(pkg_mammoth_gazebo, 'launch'), '/include/navigation/navigation.launch.py' ]), launch_arguments={'use_sim_time': use_sim_time}.items(), ) rviz = IncludeLaunchDescription( PythonLaunchDescriptionSource([ os.path.join(pkg_mammoth_gazebo, 'launch'), '/include/rviz/rviz.launch.py' ]), launch_arguments={ 'use_rviz': use_rviz, 'use_sim_time': use_sim_time }.items(), ) waypoint_publisher = IncludeLaunchDescription( PythonLaunchDescriptionSource([ os.path.join(pkg_mammoth_gazebo, 'launch'), '/include/waypoint_publisher/waypoint.launch.py' ]), launch_arguments={ 'use_sim_time': use_sim_time, 'follow_waypoints': follow_waypoints }.items(), ) robot_state_controller = IncludeLaunchDescription( PythonLaunchDescriptionSource([ os.path.join(pkg_robot_state_controller, 'launch'), '/rsc_with_ipp.launch.py' ]), launch_arguments={ 'switch_button': drive_mode_switch_button, 'use_sim_time': use_sim_time }.items(), ) return LaunchDescription([ # Launch Arguments DeclareLaunchArgument( 'drive_mode_switch_button', default_value='8', description= 'Which button is used on the joystick to switch drive mode. (In joy message)' ), DeclareLaunchArgument( 'use_sim_time', default_value='true', description='Use simulation (Gazebo) clock if true'), DeclareLaunchArgument('use_rviz', default_value='true', description='Open rviz if true'), DeclareLaunchArgument('follow_waypoints', default_value='false', description='follow way points if true'), # Nodes state_publishers, ign_gazebo, joy_with_teleop_twist, lidar_processor, pointcloud_to_laserscan, navigation, rviz, waypoint_publisher, robot_state_controller, ])
def generate_launch_description(): hardware_config = Path(get_package_share_directory('pilot_kobuki'), 'config', 'hardware.yaml') assert hardware_config.is_file() kobuki_dir = get_package_share_directory('pilot_kobuki') launch_dir = os.path.join(kobuki_dir, 'launch') #enable_align_depth = launch.substitutions.LaunchConfiguration('enable_aligned_depth', default="false") #rplidar_dir = get_package_share_directory('rplidar_ros') #rplidar_launch = launch.actions.IncludeLaunchDescription( # launch.launch_description_sources.PythonLaunchDescriptionSource( # rplidar_dir + '/launch/rplidar.launch.py')) # 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') declare_map_yaml_cmd = DeclareLaunchArgument( 'map', default_value=os.path.join( kobuki_dir, 'map', 'test_lab.yaml'), # cambiar por el mapa del bar description='Full path to map file to load') declare_params_file_cmd = DeclareLaunchArgument( 'params_file', default_value=os.path.join(kobuki_dir, 'params', '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='true', 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') #rplidar_node = launch_ros.actions.Node( #package='rplidar_ros', #node_executable='rplidarNode', #parameters=[hardware_config], #parameters=[{'enable_aligned_depth':enable_align_depth}], #output='screen') rplidar_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(get_package_share_directory('rplidar_ros'), 'launch', 'rplidar.launch.py'))) #realsense_node = launch_ros.actions.Node( # package='realsense_ros2_camera', # node_executable='realsense_ros2_camera', # node_name='realsense_ros2_camera', # #parameters=[{'enable_aligned_depth':enable_align_depth}], # output='screen'), kobuki_node = launch_ros.actions.Node(package='turtlebot2_drivers', node_executable='kobuki_node', output='screen') tf_kobuki2laser_node = launch_ros.actions.Node( package='tf2_ros', node_executable='static_transform_publisher', output='screen', arguments=[ '0.11', '0.0', '0.17', '0', '0', '1', '0', 'base_link', 'laser_frame' ]) laserfilter_node = launch_ros.actions.Node( package='pilot_kobuki', node_executable='laser_filter_node') tf_kobuki2imu_node = launch_ros.actions.Node( package='tf2_ros', node_executable='static_transform_publisher', output='screen', arguments=[ '0.0', '0.0', '0.0', '0', '0', '0', '1', 'base_link', 'imu_link' ]) nav2_cmd = IncludeLaunchDescription(PythonLaunchDescriptionSource( os.path.join(get_package_share_directory('nav2_bringup'), 'launch', 'nav2_bringup_launch.py')), launch_arguments={ 'autostart': 'true', 'map': os.path.join( kobuki_dir, 'map', 'test_lab.yaml') }.items()) #turtlebot2_cartographer_prefix = get_package_share_directory('turtlebot2_cartographer') #cartographer_config_dir = os.path.join(turtlebot2_cartographer_prefix, 'configuration_files') #cartographer_node = launch_ros.actions.Node( package='cartographer_ros', node_executable='cartographer_node', output='screen', # arguments=['-configuration_directory', cartographer_config_dir, # '-configuration_basename', 'turtlebot_2d.lua' #]); return launch.LaunchDescription([ rplidar_cmd, laserfilter_node, #cartographer_node, #realsense_node, kobuki_node, tf_kobuki2laser_node, tf_kobuki2imu_node, nav2_cmd ])
def generate_launch_description(): user = LaunchConfiguration('user', default=os.path.join( get_package_share_directory('ecard'), 'users', 'default.yaml')) config_rgbd_gaze_calibration_kappa = LaunchConfiguration( 'config_rgbd_gaze_calibration_kappa', default=os.path.join(get_package_share_directory('ecard'), 'config', 'rgbd_gaze', 'calibration', 'rgbd_gaze_calibration_kappa.yaml')) config_simple_marker_detector = LaunchConfiguration( 'config_simple_marker_detector', default=os.path.join(get_package_share_directory('ecard'), 'config', 'rgbd_gaze', 'calibration', 'simple_marker_detector.yaml')) return LaunchDescription([ DeclareLaunchArgument( 'user', default_value=user, description='Path to config for user of RGB-D gaze'), DeclareLaunchArgument( 'config_rgbd_gaze_calibration_kappa', default_value=config_rgbd_gaze_calibration_kappa, description='Path to config for RGB-D Gaze calibration for eyeball' ), DeclareLaunchArgument( 'config_simple_marker_detector', default_value=config_simple_marker_detector, description='Path to config for simple marker detector'), IncludeLaunchDescription( PythonLaunchDescriptionSource([ os.path.join(get_package_share_directory('ecard'), 'launch', 'rgbd_gaze', 'rgbd_gaze.launch.py') ]), launch_arguments=[('user', user)], ), Node( package='rgbd_gaze', node_executable='calibration_kappa', node_name='rgbd_gaze_calibration_kappa', node_namespace='', output='screen', parameters=[config_rgbd_gaze_calibration_kappa], remappings=[('head_pose', 'ecard/rgbd_gaze/head_pose'), ('optical_axes', 'ecard/rgbd_gaze/optical_axes'), ('scene_point', 'ecard/rgbd_gaze/scene_point'), ('visualisation_markers', 'ecard/rgbd_gaze/visualisation_markers')], ), Node( package='simple_marker_detector', node_executable='simple_marker_detector', node_name='simple_marker_detector', node_namespace='', output='screen', parameters=[config_simple_marker_detector], remappings=[ ('camera/color/image_raw', 'scene_d435/camera/color/image_raw'), ('camera/aligned_depth_to_color/image_raw', 'scene_d435/camera/aligned_depth_to_color/image_raw'), ('camera/aligned_depth_to_color/camera_info', 'scene_d435/camera/aligned_depth_to_color/camera_info'), ('marker_centre', 'ecard/rgbd_gaze/scene_point') ], ), ])
def generate_launch_description(): gazebo = IncludeLaunchDescription( PythonLaunchDescriptionSource([ os.path.join(get_package_share_directory('gazebo_ros'), 'launch'), '/gazebo.launch.py' ]), ) # Get URDF via xacro crane_x7_description_path = os.path.join( get_package_share_directory('crane_x7_description')) xacro_file = os.path.join(crane_x7_description_path, 'urdf', 'crane_x7.urdf.xacro') robot_description = { 'robot_description': Command(['xacro ', xacro_file, ' use_gazebo:=true']) } crane_x7_gazebo_controllers_config = os.path.join( get_package_share_directory('crane_x7_gazebo'), 'config', 'crane_x7_gazebo_controllers.yaml') spawn_robot_state_publisher = Node(package='robot_state_publisher', executable='robot_state_publisher', parameters=[robot_description], output='screen') # Gazebo's robot entity spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py', arguments=[ '-topic', 'robot_description', '-entity', 'crane_x7', '-x', '0', '-y', '0', '-z', '0' ], output='screen') spawn_controller_manager = Node( package='controller_manager', executable='ros2_control_node', parameters=[robot_description, crane_x7_gazebo_controllers_config], output={ 'stdout': 'screen', 'stderr': 'screen', }, ) spawn_joint_state_broadcaster = Node( package='controller_manager', executable='spawner.py', arguments=[ 'joint_state_broadcaster', '--controller-manager', '/controller_manager' ], ) spawn_joint_position_controller = Node( package="controller_manager", executable="spawner.py", arguments=["joint_position_controller", "-c", "/controller_manager"], ) spawn_mpc = IncludeLaunchDescription( PythonLaunchDescriptionSource([ os.path.join(get_package_share_directory('crane_x7_mpc'), 'launch'), '/crane_x7_mpc.launch.py' ]), ) return LaunchDescription([ gazebo, spawn_robot_state_publisher, spawn_entity, spawn_controller_manager, spawn_joint_state_broadcaster, spawn_joint_position_controller, spawn_mpc, ])
def generate_launch_description() -> LaunchDescription: # Declare all launch arguments declared_arguments = generate_declared_arguments() # Get substitution for all arguments description_package = LaunchConfiguration("description_package") description_filepath = LaunchConfiguration("description_filepath") moveit_config_package = "panda_moveit_config" robot_type = LaunchConfiguration("robot_type") rviz_config = LaunchConfiguration("rviz_config") use_sim_time = LaunchConfiguration("use_sim_time") ign_verbosity = LaunchConfiguration("ign_verbosity") log_level = LaunchConfiguration("log_level") # URDF _robot_description_xml = Command([ PathJoinSubstitution([FindExecutable(name="xacro")]), " ", PathJoinSubstitution( [FindPackageShare(description_package), description_filepath]), " ", "name:=", robot_type, ]) robot_description = {"robot_description": _robot_description_xml} # SRDF _robot_description_semantic_xml = Command([ PathJoinSubstitution([FindExecutable(name="xacro")]), " ", PathJoinSubstitution([ FindPackageShare(moveit_config_package), "srdf", "panda.srdf.xacro", ]), " ", "name:=", robot_type, ]) robot_description_semantic = { "robot_description_semantic": _robot_description_semantic_xml } # List of included launch descriptions launch_descriptions = [ # Launch world with robot (configured for this example) IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution([ FindPackageShare("ign_moveit2_examples"), "launch", "default.launch.py", ])), launch_arguments=[ ("world_type", "follow_target"), ("robot_type", robot_type), ("rviz_config", rviz_config), ("use_sim_time", use_sim_time), ("ign_verbosity", ign_verbosity), ("log_level", log_level), ], ), ] # List of nodes to be launched nodes = [ # Run the example node (C++) Node( package="ign_moveit2_examples", executable="ex_follow_target", output="log", arguments=["--ros-args", "--log-level", log_level], parameters=[ robot_description, robot_description_semantic, { "use_sim_time": use_sim_time }, ], ), ] return LaunchDescription(declared_arguments + launch_descriptions + nodes)
def generate_launch_description(): ap = argparse.ArgumentParser( prog='ros2 launch choirbot_examples formationcontrol.launch.py') ap.add_argument("-l", "--length", help="length of hexagon sides", default=3, type=float) ap.add_argument("-s", "--seed", help="seed for initial positions", default=5, type=float) # parse arguments (exception thrown on error) args, _ = ap.parse_known_args(sys.argv) L = float(args.length) # set rng seed np.random.seed(args.seed) # communication matrix N = 6 Adj = np.array([ # alternated zeros and ones [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0] ]) # generate matrix of desired inter-robot distances # adjacent robots have distance L # opposite robots have distance 2L W = np.array([[0, L, 0, 2 * L, 0, L], [L, 0, L, 0, 2 * L, 0], [0, L, 0, L, 0, 2 * L], [2 * L, 0, L, 0, L, 0], [0, 2 * L, 0, L, 0, L], [L, 0, 2 * L, 0, L, 0]]) # generate coordinates of hexagon with center in the origin a = L / 2 b = np.sqrt(3) * a P = np.array([[-b, a, 0], [0, 2.0 * a, 0], [b, a, 0], [b, -a, 0], [0, -2.0 * a, 0], [-b, -a, 0]]) # initial positions have a perturbation of at most L/3 P += np.random.uniform(-L / 3, L / 3, (6, 3)) # initialize launch description robot_launch = [] # launched after 10 sec (to let Gazebo open) launch_description = [] # launched immediately (will contain robot_launch) # add executables for each robot for i in range(N): in_neighbors = np.nonzero(Adj[:, i])[0].tolist() out_neighbors = np.nonzero(Adj[i, :])[0].tolist() weights = W[i, :].tolist() position = P[i, :].tolist() # guidance robot_launch.append( Node(package='choirbot_examples', node_executable='choirbot_formationcontrol_guidance', output='screen', node_namespace='agent_{}'.format(i), parameters=[{ 'agent_id': i, 'N': N, 'in_neigh': in_neighbors, 'out_neigh': out_neighbors, 'weights': weights }])) # controller robot_launch.append( Node(package='choirbot_examples', node_executable='choirbot_formationcontrol_controller', output='screen', node_namespace='agent_{}'.format(i), parameters=[{ 'agent_id': i }])) # turtlebot spawner launch_description.append( Node(package='choirbot_examples', node_executable='choirbot_turtlebot_spawner', output='screen', parameters=[{ 'namespace': 'agent_{}'.format(i), 'position': position }])) # include launcher for gazebo gazebo_launcher = os.path.join( get_package_share_directory('choirbot_examples'), 'gazebo.launch.py') launch_description.append( IncludeLaunchDescription( PythonLaunchDescriptionSource(gazebo_launcher))) # include delayed robot executables timer_action = TimerAction(period=10.0, actions=[LaunchDescription(robot_launch)]) launch_description.append(timer_action) return LaunchDescription(launch_description)
def generate_launch_description(): # Get the launch directory bringup_dir = get_package_share_directory('nav2_bringup') # Names and poses of the robots robots = [{ 'name': 'robot1', 'x_pose': 0.0, 'y_pose': 0.5, 'z_pose': 0.01 }, { 'name': 'robot2', 'x_pose': 0.0, 'y_pose': -0.5, 'z_pose': 0.01 }] # Simulation settings world = LaunchConfiguration('world') simulator = LaunchConfiguration('simulator') # On this example all robots are launched with the same settings map_yaml_file = LaunchConfiguration('map') params_file = LaunchConfiguration('params_file') bt_xml_file = LaunchConfiguration('bt_xml_file') rviz_config_file = LaunchConfiguration('rviz_config') log_settings = LaunchConfiguration('log_settings', default='true') # Declare the launch arguments declare_world_cmd = DeclareLaunchArgument( 'world', default_value=os.path.join(bringup_dir, 'worlds', 'world_only.model'), description='Full path to world file to load') declare_simulator_cmd = DeclareLaunchArgument( 'simulator', default_value='gazebo', description='The simulator to use (gazebo or gzserver)') 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_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_prefix('nav2_bt_navigator'), 'behavior_trees', 'navigate_w_replanning_and_recovery.xml'), description='Full path to the behavior tree xml file to use') declare_rviz_config_file_cmd = DeclareLaunchArgument( 'rviz_config', default_value=os.path.join(bringup_dir, 'rviz', 'nav2_namespaced_view.rviz'), description='Full path to the RVIZ config file to use') # Start Gazebo with plugin providing the robot spawing service start_gazebo_cmd = ExecuteProcess( cmd=[simulator, '--verbose', '-s', 'libgazebo_ros_factory.so', world], output='screen') # Define commands for spawing the robots into Gazebo spawn_robots_cmds = [] for robot in robots: spawn_robots_cmds.append( IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(bringup_dir, 'launch', 'spawn_robot_launch.py')), launch_arguments={ 'x_pose': TextSubstitution(text=str(robot['x_pose'])), 'y_pose': TextSubstitution(text=str(robot['y_pose'])), 'z_pose': TextSubstitution(text=str(robot['z_pose'])), 'robot_name': robot['name'], 'turtlebot_type': TextSubstitution(text='waffle') }.items())) # Define commands for launching the navigation instances nav_instances_cmds = [] for robot in robots: namespaced_rviz_config_file = ReplaceString( source_file=rviz_config_file, replacements={'<robot_namespace>': ('/' + robot['name'])}) group = GroupAction([ # TODO(orduno) Each `action.Node` within the `localization` and `navigation` launch # files has two versions, one with the required remaps and another without. # The `use_remappings` flag specifies which runs. # A better mechanism would be to have a PushNodeRemapping() action: # https://github.com/ros2/launch_ros/issues/56 # For more on why we're remapping topics, see the note below # PushNodeRemapping(remappings) # Instances use the robot's name for namespace PushRosNamespace(robot['name']), IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(bringup_dir, 'launch', 'nav2_tb3_simulation_launch.py')), launch_arguments={ #TODO(orduno) might not be necessary to pass the robot name 'namespace': robot['name'], 'map_yaml_file': map_yaml_file, 'use_sim_time': 'True', 'params_file': params_file, 'bt_xml_file': bt_xml_file, 'autostart': 'False', 'use_remappings': 'True', 'rviz_config_file': namespaced_rviz_config_file, 'use_simulator': 'False' }.items()), LogInfo(condition=IfCondition(log_settings), msg=['Launching ', robot['name']]), LogInfo(condition=IfCondition(log_settings), msg=[robot['name'], ' map yaml: ', map_yaml_file]), LogInfo(condition=IfCondition(log_settings), msg=[robot['name'], ' params yaml: ', params_file]), LogInfo(condition=IfCondition(log_settings), msg=[robot['name'], ' behavior tree xml: ', bt_xml_file]), LogInfo(condition=IfCondition(log_settings), msg=[ robot['name'], ' rviz config file: ', namespaced_rviz_config_file ]) ]) nav_instances_cmds.append(group) # A note on the `remappings` variable defined above and the fact it's passed as a node arg. # A few topics have fully qualified names (have a leading '/'), these need to be remapped # 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 # for multi-robot transforms: # https://github.com/ros/geometry2/issues/32 # https://github.com/ros/robot_state_publisher/pull/30 # Create the launch description and populate ld = LaunchDescription() # Declare the launch options ld.add_action(declare_simulator_cmd) ld.add_action(declare_world_cmd) ld.add_action(declare_map_yaml_cmd) ld.add_action(declare_params_file_cmd) ld.add_action(declare_bt_xml_cmd) ld.add_action(declare_rviz_config_file_cmd) # Add the actions to start gazebo, robots and simulations ld.add_action(start_gazebo_cmd) for spawn_robot_cmd in spawn_robots_cmds: ld.add_action(spawn_robot_cmd) for simulation_instance_cmd in nav_instances_cmds: ld.add_action(simulation_instance_cmd) return ld
def generate_launch_description(): # Get the launch directory marta_launch_dir = os.path.join( get_package_share_directory('marta_launch'), 'launch') rover_config_dir = get_package_share_directory('rover_config') # 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') default_bt_xml_filename = LaunchConfiguration('default_bt_xml_filename') autostart = LaunchConfiguration('autostart') # Launch configuration variables specific to simulation rviz_config_file = LaunchConfiguration('rviz_config_file') use_rviz = LaunchConfiguration('use_rviz') use_simulator = LaunchConfiguration('use_simulator') use_gazebo_gui = LaunchConfiguration('use_gazebo_gui') world_path = LaunchConfiguration('world_path') # 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(rover_config_dir, 'maps', 'tb3_world_big.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(rover_config_dir, 'config', 'nav2_params.yaml'), description= 'Full path to the ROS2 parameters file to use for all launchde 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_distance.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(rover_config_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_gazebo_gui_cmd = DeclareLaunchArgument( 'use_gazebo_gui', default_value='True', description='Whether to execute gzclient)') declare_use_rviz_cmd = DeclareLaunchArgument( 'use_rviz', default_value='True', description='Whether to start RVIZ') declare_world_path_cmd = DeclareLaunchArgument( 'world_path', # TODO(orduno) Switch back once ROS argument passing has been fixed upstream # https://github.com/ROBOTIS-GIT/turtlebot3_simulations/issues/91 # TURTLEBOT EXAMPLE # default_value=os.path.join(rover_config_dir, 'worlds', 'tb3_world.model'), # EMPTY WORLD default_value=os.path.join(rover_config_dir, 'worlds', 'empty.world'), description='Full path to world model file to load') # Specify the actions locomotion_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(marta_launch_dir, 'locomotion.launch.py'))) simulation_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(marta_launch_dir, 'simulation.launch.py'))) # Start Nav2 Stack bringup_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(marta_launch_dir, 'nav2_bringup_launch.py')), # 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, 'default_bt_xml_filename': default_bt_xml_filename, 'autostart': autostart }.items()) start_rviz_cmd = Node( condition=IfCondition(use_rviz), package='rviz2', executable='rviz2', name='rviz2', # Use this option to see all output from rviz: # output='screen', # Use this option to supress messages of missing tfs, # at startup of rviz and gazebo: output={'stdout': 'log'}, arguments=['-d', rviz_config_file], 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')))) # Create the launch description and populate return LaunchDescription([ # Set env var to print messages colored. The ANSI color codes will appear in a log. SetEnvironmentVariable('RCUTILS_COLORIZED_OUTPUT', '1'), # Declare the launch options declare_namespace_cmd, declare_use_sim_time_cmd, declare_map_yaml_cmd, declare_params_file_cmd, declare_bt_xml_cmd, declare_autostart_cmd, declare_rviz_config_file_cmd, declare_use_simulator_cmd, declare_use_rviz_cmd, declare_use_gazebo_gui_cmd, declare_world_path_cmd, # Add any conditioned actions start_rviz_cmd, # Add other nodes and processes we need exit_event_handler, # Add the actions to launch all of the navigation nodes locomotion_cmd, simulation_cmd, bringup_cmd ])
def generate_launch_description(): # Input parameters declaration namespace = LaunchConfiguration('namespace') params_file = LaunchConfiguration('params_file') use_sim_time = LaunchConfiguration('use_sim_time') autostart = LaunchConfiguration('autostart') # Variables lifecycle_nodes = ['map_saver'] # Getting directories and launch-files bringup_dir = get_package_share_directory('nav2_bringup') slam_toolbox_dir = get_package_share_directory('slam_toolbox') slam_launch_file = os.path.join(slam_toolbox_dir, 'launch', 'online_sync_launch.py') # Create our own temporary YAML files that include substitutions param_substitutions = {'use_sim_time': use_sim_time} configured_params = RewrittenYaml(source_file=params_file, root_key=namespace, param_rewrites=param_substitutions, convert_types=True) # Declare the launch arguments declare_namespace_cmd = DeclareLaunchArgument( 'namespace', default_value='', description='Top-level namespace') 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_use_sim_time_cmd = DeclareLaunchArgument( 'use_sim_time', default_value='True', description='Use simulation (Gazebo) clock if true') declare_autostart_cmd = DeclareLaunchArgument( 'autostart', default_value='True', description='Automatically startup the nav2 stack') # Nodes launching commands start_map_saver_server_cmd = Node(package='nav2_map_server', executable='map_saver_server', output='screen', parameters=[configured_params]) start_lifecycle_manager_cmd = Node(package='nav2_lifecycle_manager', executable='lifecycle_manager', name='lifecycle_manager_slam', output='screen', parameters=[{ 'use_sim_time': use_sim_time }, { 'autostart': autostart }, { 'node_names': lifecycle_nodes }]) # If the provided param file doesn't have slam_toolbox params, we must remove the 'params_file' # LaunchConfiguration, or it will be passed automatically to slam_toolbox and will not load # the default file has_slam_toolbox_params = HasNodeParams(source_file=params_file, node_name='slam_toolbox') start_slam_toolbox_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource(slam_launch_file), launch_arguments={'use_sim_time': use_sim_time}.items(), condition=UnlessCondition(has_slam_toolbox_params)) start_slam_toolbox_cmd_with_params = IncludeLaunchDescription( PythonLaunchDescriptionSource(slam_launch_file), launch_arguments={ 'use_sim_time': use_sim_time, 'slam_params_file': params_file }.items(), condition=IfCondition(has_slam_toolbox_params)) ld = LaunchDescription() # Declare the launch options ld.add_action(declare_namespace_cmd) ld.add_action(declare_params_file_cmd) ld.add_action(declare_use_sim_time_cmd) ld.add_action(declare_autostart_cmd) # Running Map Saver Server ld.add_action(start_map_saver_server_cmd) ld.add_action(start_lifecycle_manager_cmd) # Running SLAM Toolbox (Only one of them will be run) ld.add_action(start_slam_toolbox_cmd) ld.add_action(start_slam_toolbox_cmd_with_params) return ld
def generate_launch_description(): use_sim_time = LaunchConfiguration('use_sim_time', default='true') nav2_bringup_dir = get_package_share_directory('nav2_bringup') nav2_launch_dir = os.path.join(nav2_bringup_dir, 'launch') amazon_gazebo_package_dir = get_package_share_directory('amazon_robot_gazebo') amazon_gazebo_package_launch_dir= os.path.join(amazon_gazebo_package_dir, 'launch') amazon_description_dir = get_package_share_directory('amazon_robot_description') this_launch_dir = os.path.dirname(os.path.realpath(__file__)) amazon_bringup_package_dir = get_package_share_directory('amazon_robot_bringup') spawn_robot = True # 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') default_bt_xml_filename = LaunchConfiguration('default_bt_xml_filename') 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 # Useful with multi robot 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') # Map declare_map_yaml_cmd = DeclareLaunchArgument( 'map', default_value=os.path.join(this_launch_dir, 'maps', 'map.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') # Navigation 2 parameters # Change accordingly declare_params_file_cmd = DeclareLaunchArgument( 'params_file', default_value=os.path.join(this_launch_dir, 'params', 'nav2_params.yaml'), description='Full path to the ROS2 parameters file to use for all launched nodes') # Navigation 2 default behaviour tree. Might need to change in the future 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_slam_cmd = DeclareLaunchArgument( 'slam', default_value='False', description='Whether run a SLAM') 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(nav2_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)') # Our own gazebo world from CustomRobots 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(amazon_gazebo_package_dir, 'worlds', 'amazon_warehouse' , 'amazon_robot.model'), description='Full path to world model file to load') # Default Nav2 actions # Specify the actions start_gazebo_server_cmd = ExecuteProcess( cmd=['gzserver', '--verbose', '-s', 'libgazebo_ros_factory.so', '-s' , 'libgazebo_ros_force_system.so' , world], cwd=[nav2_launch_dir], output='screen') start_gazebo_client_cmd = ExecuteProcess( cmd=['gzclient'], cwd=[nav2_launch_dir], output='screen') # Our own robot urdf from CustomRobot urdf = os.path.join(amazon_description_dir, 'urdf', 'amazon_robot_xacro_generated.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(nav2_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(nav2_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, 'default_bt_xml_filename': default_bt_xml_filename, 'autostart': autostart}.items()) if spawn_robot is True: spawn_robot_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource(os.path.join(amazon_bringup_package_dir, 'launch', 'spawn_tb3_launch.py')), launch_arguments={ 'x_pose': '0', 'y_pose': '0', 'z_pose': '0', 'robot_name': 'amazon_robot' }.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_bt_xml_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) if spawn_robot is True: ld.add_action(spawn_robot_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(): # 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') 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') # 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(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='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, 'map': map_yaml_file, 'use_sim_time': use_sim_time, 'params_file': params_file, 'bt_xml_file': bt_xml_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_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_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(): 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 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') 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') stdout_linebuf_envvar = SetEnvironmentVariable( 'RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '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 the launch arguments 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( '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='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, 'nav2_localization_launch.py')), 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, 'nav2_navigation_launch.py')), launch_arguments={ 'namespace': namespace, 'use_sim_time': use_sim_time, 'autostart': autostart, 'params_file': params_file, 'bt_xml_file': bt_xml_file, 'use_lifecycle_mgr': 'false', 'map_subscribe_transient_local': 'true' }.items()), Node(package='nav2_lifecycle_manager', node_executable='lifecycle_manager', node_name='lifecycle_manager', output='screen', parameters=[{ 'use_sim_time': use_sim_time }, { 'autostart': autostart }, { 'node_names': [ 'map_server', 'amcl', 'controller_server', 'planner_server', 'recoveries_server', 'bt_navigator', 'waypoint_follower' ] }]), ]) # 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_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(): map_yaml_file = os.getenv('TEST_MAP') filter_mask_file = os.getenv('TEST_MASK') world = os.getenv('TEST_WORLD') bt_navigator_xml = os.path.join( get_package_share_directory('nav2_bt_navigator'), 'behavior_trees', os.getenv('BT_NAVIGATOR_XML')) bringup_dir = get_package_share_directory('nav2_bringup') params_file = os.getenv('PARAMS_FILE') # Replace the `use_astar` setting on the params file param_substitutions = { 'planner_server.ros__parameters.GridBased.use_astar': os.getenv('ASTAR'), 'filter_mask_server.ros__parameters.yaml_filename': filter_mask_file, 'yaml_filename': filter_mask_file } configured_params = RewrittenYaml(source_file=params_file, root_key='', param_rewrites=param_substitutions, convert_types=True) context = LaunchContext() new_yaml = configured_params.perform(context) return LaunchDescription([ SetEnvironmentVariable('RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1'), # Launch gazebo server for simulation ExecuteProcess(cmd=[ 'gzserver', '-s', 'libgazebo_ros_init.so', '--minimal_comms', world ], output='screen'), # TODO(orduno) Launch the robot state publisher instead # using a local copy of TB3 urdf file Node(package='tf2_ros', executable='static_transform_publisher', output='screen', arguments=[ '0', '0', '0', '0', '0', '0', 'base_footprint', 'base_link' ]), Node( package='tf2_ros', executable='static_transform_publisher', output='screen', arguments=['0', '0', '0', '0', '0', '0', 'base_link', 'base_scan']), Node(package='nav2_lifecycle_manager', executable='lifecycle_manager', name='lifecycle_manager_filters', output='screen', parameters=[{ 'node_names': ['filter_mask_server', 'costmap_filter_info_server'] }, { 'autostart': True }]), # Nodes required for Costmap Filters configuration Node(package='nav2_map_server', executable='map_server', name='filter_mask_server', output='screen', parameters=[new_yaml]), Node(package='nav2_map_server', executable='costmap_filter_info_server', name='costmap_filter_info_server', output='screen', parameters=[new_yaml]), IncludeLaunchDescription(PythonLaunchDescriptionSource( os.path.join(bringup_dir, 'launch', 'bringup_launch.py')), launch_arguments={ 'namespace': '', 'use_namespace': 'False', 'map': map_yaml_file, 'use_sim_time': 'True', 'params_file': new_yaml, 'bt_xml_file': bt_navigator_xml, 'autostart': 'True' }.items()), ])
def generate_launch_description(): ld = LaunchDescription() pkg_rmua19_ignition_simulator = get_package_share_directory( 'rmua19_ignition_simulator') world_sdf_path = os.path.join(pkg_rmua19_ignition_simulator, 'resource', 'worlds', 'rmua19_world.sdf') robot_xmacro_path = os.path.join(pkg_rmua19_ignition_simulator, 'resource', 'xmacro', 'rmua19_standard_robot_a.sdf.xmacro') ign_config_path = os.path.join(pkg_rmua19_ignition_simulator, 'resource', 'ign', 'gui.config') robot_config = os.path.join(pkg_rmua19_ignition_simulator, 'config', 'base_params.yaml') # Gazebo launch gazebo = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(get_package_share_directory('ros_ign_gazebo'), 'launch', 'ign_gazebo.launch.py'), ), launch_arguments={ 'ign_args': world_sdf_path + ' -v 4 --gui-config ' + ign_config_path, }.items()) ld.add_action(gazebo) robot_names = ["red_standard_robot1"] # Spawn robot robot_macro = XMLMacro4sdf() robot_macro.set_xml_file(robot_xmacro_path) robot_macro.generate({'global_initial_color': 'red'}) robot_xml = robot_macro.to_string() spawn1 = Node(package='ros_ign_gazebo', executable='create', arguments=[ '-name', robot_names[0], '-x', '-3.5', '-y', '-2', '-z', '0.08', '-string', robot_xml ], output='screen') ld.add_action(spawn1) # robot base for each robot for robot_name in robot_names: robot_base = Node(package='rmoss_ign_base', executable='rmua19_robot_base', namespace=robot_name, parameters=[ robot_config, { 'robot_name': robot_name }, ], output='screen') robot_ign_bridge = Node( package='ros_ign_bridge', executable='parameter_bridge', namespace=robot_name, arguments=[ '/world/default/model/%s/link/front_industrial_camera/sensor/front_industrial_camera/image@sensor_msgs/msg/Image[ignition.msgs.Image' % (robot_name), '/world/default/model/%s/link/front_rplidar_a2/sensor/front_rplidar_a2/scan@sensor_msgs/msg/LaserScan[ignition.msgs.LaserScan' % (robot_name), ], remappings=[ ('/world/default/model/%s/link/front_industrial_camera/sensor/front_industrial_camera/image' % (robot_name), 'front_camera/image'), ('/world/default/model/%s/link/front_rplidar_a2/sensor/front_rplidar_a2/scan' % (robot_name), 'rplidar_a2/scan'), ], output='screen') ld.add_action(robot_base) ld.add_action(robot_ign_bridge) 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 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') # Launch configuration variables specific to simulation rviz_config_file = LaunchConfiguration('rviz_config_file') use_simulator = LaunchConfiguration('use_simulator') simulator = LaunchConfiguration('simulator') world = LaunchConfiguration('world') # Declare the launch arguments 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_prefix('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_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_simulator_cmd = DeclareLaunchArgument( 'simulator', default_value='gazebo', description='The simulator to use (gazebo or gzserver)') 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_cmd = ExecuteProcess( condition=IfCondition(use_simulator), cmd=[simulator, '-s', 'libgazebo_ros_init.so', world], 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( package='robot_state_publisher', node_executable='robot_state_publisher', node_name='robot_state_publisher', output='screen', parameters=[{ 'use_sim_time': use_sim_time }], arguments=[urdf]) # TODO(orduno) RVIZ crashing if launched as a node: https://github.com/ros2/rviz/issues/442 # Launching as node works after applying the change described on the github issue. # start_rviz_cmd = Node( # package='rviz2', # node_executable='rviz2', # node_name='rviz2', # arguments=['-d', rviz_config_file], # output='screen') start_rviz_cmd = ExecuteProcess(cmd=[ os.path.join(get_package_prefix('rviz2'), 'lib/rviz2/rviz2'), ['-d', rviz_config_file] ], cwd=[launch_dir], output='screen') 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={ 'map': map_yaml_file, 'use_sim_time': use_sim_time, 'params_file': params_file, 'bt_xml_file': bt_xml_file, 'autostart': autostart }.items()) # Create the launch description and populate ld = LaunchDescription() # Declare the launch options 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_rviz_config_file_cmd) ld.add_action(declare_use_simulator_cmd) ld.add_action(declare_simulator_cmd) ld.add_action(declare_world_cmd) # Add any actions to launch in simulation (conditioned on 'use_simulator') ld.add_action(start_gazebo_cmd) # Add other nodes and processes we need 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) ld.add_action(bringup_cmd) return ld
def test_include_launch_description_constructors(): """Test the constructors for IncludeLaunchDescription class.""" IncludeLaunchDescription(LaunchDescriptionSource(LaunchDescription())) IncludeLaunchDescription(LaunchDescriptionSource(LaunchDescription()), launch_arguments={'foo': 'FOO'}.items())
def generate_launch_description(): xacro_path = os.path.join(get_package_share_directory('dsr_description2'), 'xacro') # 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]) # 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 파일로 셋팅된다. ]) # gazebo2 gazebo = IncludeLaunchDescription( PythonLaunchDescriptionSource([ os.path.join(get_package_share_directory('gazebo_ros'), 'launch'), '/gazebo.launch.py' ]), ) spawn_entity = Node( package='gazebo_ros', executable='spawn_entity.py', arguments=['-topic', 'robot_description', '-entity', 'm1013'], output='screen') return LaunchDescription(args + [ static_tf, robot_state_publisher, rviz_node, gazebo, spawn_entity, dsr_control2, ])