Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
4 changes: 2 additions & 2 deletions nav2_bringup/launch/cloned_multi_tb3_simulation_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def generate_launch_description():
declare_params_file_cmd = DeclareLaunchArgument(
'params_file',
default_value=os.path.join(
bringup_dir, 'params', 'nav2_multirobot_params_all.yaml'
bringup_dir, 'params', 'nav2_params.yaml'
),
description='Full path to the ROS2 parameters file to use for all launched nodes',
)
Expand All @@ -93,7 +93,7 @@ def generate_launch_description():

declare_rviz_config_file_cmd = DeclareLaunchArgument(
'rviz_config',
default_value=os.path.join(bringup_dir, 'rviz', 'nav2_namespaced_view.rviz'),
default_value=os.path.join(bringup_dir, 'rviz', 'nav2_default_view.rviz'),
description='Full path to the RVIZ config file to use.',
)

Expand Down
42 changes: 1 addition & 41 deletions nav2_bringup/launch/rviz_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, EmitEvent, RegisterEventHandler
from launch.conditions import IfCondition, UnlessCondition
from launch.event_handlers import OnProcessExit
from launch.events import Shutdown
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from nav2_common.launch import ReplaceString


def generate_launch_description():
Expand All @@ -32,7 +30,6 @@ def generate_launch_description():

# Create the launch configuration variables
namespace = LaunchConfiguration('namespace')
use_namespace = LaunchConfiguration('use_namespace')
rviz_config_file = LaunchConfiguration('rviz_config')
use_sim_time = LaunchConfiguration('use_sim_time')

Expand All @@ -46,12 +43,6 @@ def generate_launch_description():
),
)

declare_use_namespace_cmd = DeclareLaunchArgument(
'use_namespace',
default_value='false',
description='Whether to apply a namespace to the navigation stack',
)

declare_rviz_config_file_cmd = DeclareLaunchArgument(
'rviz_config',
default_value=os.path.join(bringup_dir, 'rviz', 'nav2_default_view.rviz'),
Expand All @@ -65,68 +56,37 @@ def generate_launch_description():

# Launch rviz
start_rviz_cmd = Node(
condition=UnlessCondition(use_namespace),
package='rviz2',
executable='rviz2',
namespace=namespace,
arguments=['-d', rviz_config_file],
output='screen',
parameters=[{'use_sim_time': use_sim_time}],
)

namespaced_rviz_config_file = ReplaceString(
source_file=rviz_config_file,
replacements={'<robot_namespace>': ('/', namespace)},
)

start_namespaced_rviz_cmd = Node(
condition=IfCondition(use_namespace),
package='rviz2',
executable='rviz2',
namespace=namespace,
arguments=['-d', namespaced_rviz_config_file],
parameters=[{'use_sim_time': use_sim_time}],
output='screen',
remappings=[
('/map', 'map'),
('/tf', 'tf'),
('/tf_static', 'tf_static'),
('/goal_pose', 'goal_pose'),
('/clicked_point', 'clicked_point'),
('/initialpose', 'initialpose'),
],
)

exit_event_handler = RegisterEventHandler(
condition=UnlessCondition(use_namespace),
event_handler=OnProcessExit(
target_action=start_rviz_cmd,
on_exit=EmitEvent(event=Shutdown(reason='rviz exited')),
),
)

exit_event_handler_namespaced = RegisterEventHandler(
condition=IfCondition(use_namespace),
event_handler=OnProcessExit(
target_action=start_namespaced_rviz_cmd,
on_exit=EmitEvent(event=Shutdown(reason='rviz exited')),
),
)

# 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_rviz_config_file_cmd)
ld.add_action(declare_use_sim_time_cmd)

# Add any conditioned actions
ld.add_action(start_rviz_cmd)
ld.add_action(start_namespaced_rviz_cmd)

# Add other nodes and processes we need
ld.add_action(exit_event_handler)
ld.add_action(exit_event_handler_namespaced)

return ld
6 changes: 3 additions & 3 deletions nav2_bringup/launch/unique_multi_tb3_simulation_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ def generate_launch_description():
declare_robot1_params_file_cmd = DeclareLaunchArgument(
'robot1_params_file',
default_value=os.path.join(
bringup_dir, 'params', 'nav2_multirobot_params_1.yaml'
bringup_dir, 'params', 'nav2_params.yaml'
),
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(
bringup_dir, 'params', 'nav2_multirobot_params_2.yaml'
bringup_dir, 'params', 'nav2_params.yaml'
),
description='Full path to the ROS2 parameters file to use for robot2 launched nodes',
)
Expand All @@ -120,7 +120,7 @@ def generate_launch_description():

declare_rviz_config_file_cmd = DeclareLaunchArgument(
'rviz_config',
default_value=os.path.join(bringup_dir, 'rviz', 'nav2_namespaced_view.rviz'),
default_value=os.path.join(bringup_dir, 'rviz', 'nav2_default_view.rviz'),
description='Full path to the RVIZ config file to use.',
)

Expand Down
Loading
Loading