From a2a9ee921abf8d2a342dd011e653934052d6f2bd Mon Sep 17 00:00:00 2001 From: rafal-gorecki Date: Thu, 7 Nov 2024 10:59:40 +0100 Subject: [PATCH] Move RViz arg --- husarion_ugv_gazebo/launch/simulation.launch.py | 11 +++++++++++ panther_description/launch/rviz.launch.py | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/husarion_ugv_gazebo/launch/simulation.launch.py b/husarion_ugv_gazebo/launch/simulation.launch.py index cf34f986..34da7dc9 100644 --- a/husarion_ugv_gazebo/launch/simulation.launch.py +++ b/husarion_ugv_gazebo/launch/simulation.launch.py @@ -16,6 +16,7 @@ from launch import LaunchDescription from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription +from launch.conditions import IfCondition from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import ( EnvironmentVariable, @@ -45,6 +46,14 @@ def generate_launch_description(): description="Add namespace to all launched nodes.", ) + use_rviz = LaunchConfiguration("use_rviz") + declare_use_rviz_arg = DeclareLaunchArgument( + "use_rviz", + default_value="True", + description="Run RViz simultaneously.", + choices=["True", "true", "False", "false"], + ) + namespaced_gz_gui = ReplaceString( source_file=gz_gui, replacements={"{namespace}": namespace}, @@ -69,6 +78,7 @@ def generate_launch_description(): ] ) ), + condition=IfCondition(use_rviz), ) simulate_robots = IncludeLaunchDescription( @@ -86,6 +96,7 @@ def generate_launch_description(): actions = [ declare_gz_gui, declare_namespace_arg, + declare_use_rviz_arg, # Sets use_sim_time for all nodes started below (doesn't work for nodes started from ignition gazebo) SetUseSimTime(True), gz_sim, diff --git a/panther_description/launch/rviz.launch.py b/panther_description/launch/rviz.launch.py index 8f0cb3e2..b194341c 100644 --- a/panther_description/launch/rviz.launch.py +++ b/panther_description/launch/rviz.launch.py @@ -17,7 +17,6 @@ from launch import LaunchDescription from launch.actions import DeclareLaunchArgument -from launch.conditions import IfCondition from launch.substitutions import ( EnvironmentVariable, LaunchConfiguration, @@ -47,14 +46,6 @@ def generate_launch_description(): description="RViz configuration file.", ) - use_rviz = LaunchConfiguration("use_rviz") - declare_use_rviz_arg = DeclareLaunchArgument( - "use_rviz", - default_value="True", - description="Run RViz simultaneously.", - choices=["True", "true", "False", "false"], - ) - use_sim = LaunchConfiguration("use_sim") declare_use_sim_arg = DeclareLaunchArgument( "use_sim", @@ -75,13 +66,11 @@ def generate_launch_description(): executable="rviz2", namespace=namespace, arguments=["-d", rviz_config], - condition=IfCondition(use_rviz), ) actions = [ declare_namespace_arg, declare_rviz_config_arg, - declare_use_rviz_arg, declare_use_sim_arg, SetParameter(name="use_sim_time", value=use_sim), rviz_node,