Skip to content

Commit

Permalink
Make rviz use sim time with TB3 demo (ros-navigation#4274)
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Najjar <tony.najjar.1997@gmail.com>
  • Loading branch information
tonynajjar authored Apr 24, 2024
1 parent fbec0fa commit 1f980a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions nav2_bringup/launch/rviz_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def generate_launch_description():
namespace = LaunchConfiguration('namespace')
use_namespace = LaunchConfiguration('use_namespace')
rviz_config_file = LaunchConfiguration('rviz_config')
use_sim_time = LaunchConfiguration('use_sim_time')

# Declare the launch arguments
declare_namespace_cmd = DeclareLaunchArgument(
Expand All @@ -57,13 +58,19 @@ def generate_launch_description():
description='Full path to the RVIZ config file to use',
)

declare_use_sim_time_cmd = DeclareLaunchArgument(
'use_sim_time',
default_value='false',
description='Use simulation (Gazebo) clock if true')

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

namespaced_rviz_config_file = ReplaceString(
Expand All @@ -77,6 +84,7 @@ def generate_launch_description():
executable='rviz2',
namespace=namespace,
arguments=['-d', namespaced_rviz_config_file],
parameters=[{'use_sim_time': use_sim_time}],
output='screen',
remappings=[
('/map', 'map'),
Expand Down Expand Up @@ -111,6 +119,7 @@ def generate_launch_description():
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)
Expand Down
1 change: 1 addition & 0 deletions nav2_bringup/launch/tb3_simulation_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def generate_launch_description():
launch_arguments={
'namespace': namespace,
'use_namespace': use_namespace,
'use_sim_time': use_sim_time,
'rviz_config': rviz_config_file,
}.items(),
)
Expand Down

0 comments on commit 1f980a1

Please sign in to comment.