Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[multirobot - Part4] Multiple robot control via RVIZ - Fix merge #1178

Merged
merged 1 commit into from
Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion nav2_bringup/bringup/launch/nav2_multi_tb3_simulation_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
from ament_index_python.packages import get_package_prefix
from ament_index_python.packages import get_package_share_directory

from nav2_common.launch import ReplaceString

from launch import LaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.actions import (DeclareLaunchArgument, IncludeLaunchDescription,
Expand All @@ -47,6 +49,7 @@ def generate_launch_description():
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
Expand Down Expand Up @@ -77,6 +80,11 @@ def generate_launch_description():
'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],
Expand All @@ -99,6 +107,10 @@ def generate_launch_description():
# 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.
Expand All @@ -123,6 +135,7 @@ def generate_launch_description():
'bt_xml_file': bt_xml_file,
'autostart': 'False',
'use_remappings': 'True',
'rviz_config_file': namespaced_rviz_config_file,
'use_simulator': 'False'}.items()),

LogInfo(
Expand All @@ -136,7 +149,10 @@ def generate_launch_description():
msg=[robot['name'], ' params yaml: ', params_file]),
LogInfo(
condition=IfCondition(log_settings),
msg=[robot['name'], ' behavior tree xml: ', bt_xml_file])
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)
Expand All @@ -158,6 +174,7 @@ def generate_launch_description():
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)
Expand Down
Loading