Skip to content

Commit

Permalink
Add headless and use_rviz LaunchConfigurations to demo launch files (#…
Browse files Browse the repository at this point in the history
…3527)

* Add headless and use_rviz LaunchConfigurations
in nav2_simple_commander demo launch files
for whether to start rviz or gzclient
to simplify their use in headless environments

* Fix headless logic to match tb3_simulation_launch.py
for launch arg consistency
  • Loading branch information
ruffsl authored and SteveMacenski committed Jun 9, 2023
1 parent 1efcdcf commit c1a2abd
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 9 deletions.
23 changes: 22 additions & 1 deletion nav2_simple_commander/launch/assisted_teleop_example_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import ExecuteProcess, IncludeLaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PythonExpression
from launch_ros.actions import Node


Expand All @@ -31,12 +33,28 @@ def generate_launch_description():
map_yaml_file = os.path.join(warehouse_dir, 'maps', '005', 'map.yaml')
world = os.path.join(python_commander_dir, 'warehouse.world')

# Launch configuration variables
use_rviz = LaunchConfiguration('use_rviz')
headless = LaunchConfiguration('headless')

# Declare the launch arguments
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)')

# start the simulation
start_gazebo_server_cmd = ExecuteProcess(
cmd=['gzserver', '-s', 'libgazebo_ros_factory.so', world],
cwd=[warehouse_dir], output='screen')

start_gazebo_client_cmd = ExecuteProcess(
condition=IfCondition(PythonExpression(['not ', headless])),
cmd=['gzclient'],
cwd=[warehouse_dir], output='screen')

Expand All @@ -52,6 +70,7 @@ def generate_launch_description():
rviz_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(nav2_bringup_dir, 'launch', 'rviz_launch.py')),
condition=IfCondition(use_rviz),
launch_arguments={'namespace': '',
'use_namespace': 'False'}.items())

Expand All @@ -69,6 +88,8 @@ def generate_launch_description():
output='screen')

ld = LaunchDescription()
ld.add_action(declare_use_rviz_cmd)
ld.add_action(declare_simulator_cmd)
ld.add_action(start_gazebo_server_cmd)
ld.add_action(start_gazebo_client_cmd)
ld.add_action(start_robot_state_publisher_cmd)
Expand Down
23 changes: 22 additions & 1 deletion nav2_simple_commander/launch/follow_path_example_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import ExecuteProcess, IncludeLaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PythonExpression
from launch_ros.actions import Node


Expand All @@ -30,12 +32,28 @@ def generate_launch_description():
map_yaml_file = os.path.join(warehouse_dir, 'maps', '005', 'map.yaml')
world = os.path.join(python_commander_dir, 'warehouse.world')

# Launch configuration variables
use_rviz = LaunchConfiguration('use_rviz')
headless = LaunchConfiguration('headless')

# Declare the launch arguments
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)')

# start the simulation
start_gazebo_server_cmd = ExecuteProcess(
cmd=['gzserver', '-s', 'libgazebo_ros_factory.so', world],
cwd=[warehouse_dir], output='screen')

start_gazebo_client_cmd = ExecuteProcess(
condition=IfCondition(PythonExpression(['not ', headless])),
cmd=['gzclient'],
cwd=[warehouse_dir], output='screen')

Expand All @@ -51,6 +69,7 @@ def generate_launch_description():
rviz_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(nav2_bringup_dir, 'launch', 'rviz_launch.py')),
condition=IfCondition(use_rviz),
launch_arguments={'namespace': '',
'use_namespace': 'False'}.items())

Expand All @@ -68,6 +87,8 @@ def generate_launch_description():
output='screen')

ld = LaunchDescription()
ld.add_action(declare_use_rviz_cmd)
ld.add_action(declare_simulator_cmd)
ld.add_action(start_gazebo_server_cmd)
ld.add_action(start_gazebo_client_cmd)
ld.add_action(start_robot_state_publisher_cmd)
Expand Down
23 changes: 22 additions & 1 deletion nav2_simple_commander/launch/inspection_demo_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import ExecuteProcess, IncludeLaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PythonExpression
from launch_ros.actions import Node


Expand All @@ -30,12 +32,28 @@ def generate_launch_description():
map_yaml_file = os.path.join(warehouse_dir, 'maps', '005', 'map.yaml')
world = os.path.join(python_commander_dir, 'warehouse.world')

# Launch configuration variables
use_rviz = LaunchConfiguration('use_rviz')
headless = LaunchConfiguration('headless')

# Declare the launch arguments
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)')

# start the simulation
start_gazebo_server_cmd = ExecuteProcess(
cmd=['gzserver', '-s', 'libgazebo_ros_factory.so', world],
cwd=[warehouse_dir], output='screen')

start_gazebo_client_cmd = ExecuteProcess(
condition=IfCondition(PythonExpression(['not ', headless])),
cmd=['gzclient'],
cwd=[warehouse_dir], output='screen')

Expand All @@ -51,6 +69,7 @@ def generate_launch_description():
rviz_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(nav2_bringup_dir, 'launch', 'rviz_launch.py')),
condition=IfCondition(use_rviz),
launch_arguments={'namespace': '',
'use_namespace': 'False'}.items())

Expand All @@ -68,6 +87,8 @@ def generate_launch_description():
output='screen')

ld = LaunchDescription()
ld.add_action(declare_use_rviz_cmd)
ld.add_action(declare_simulator_cmd)
ld.add_action(start_gazebo_server_cmd)
ld.add_action(start_gazebo_client_cmd)
ld.add_action(start_robot_state_publisher_cmd)
Expand Down
23 changes: 22 additions & 1 deletion nav2_simple_commander/launch/nav_through_poses_example_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import ExecuteProcess, IncludeLaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PythonExpression
from launch_ros.actions import Node


Expand All @@ -30,12 +32,28 @@ def generate_launch_description():
map_yaml_file = os.path.join(warehouse_dir, 'maps', '005', 'map.yaml')
world = os.path.join(python_commander_dir, 'warehouse.world')

# Launch configuration variables
use_rviz = LaunchConfiguration('use_rviz')
headless = LaunchConfiguration('headless')

# Declare the launch arguments
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)')

# start the simulation
start_gazebo_server_cmd = ExecuteProcess(
cmd=['gzserver', '-s', 'libgazebo_ros_factory.so', world],
cwd=[warehouse_dir], output='screen')

start_gazebo_client_cmd = ExecuteProcess(
condition=IfCondition(PythonExpression(['not ', headless])),
cmd=['gzclient'],
cwd=[warehouse_dir], output='screen')

Expand All @@ -51,6 +69,7 @@ def generate_launch_description():
rviz_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(nav2_bringup_dir, 'launch', 'rviz_launch.py')),
condition=IfCondition(use_rviz),
launch_arguments={'namespace': '',
'use_namespace': 'False'}.items())

Expand All @@ -68,6 +87,8 @@ def generate_launch_description():
output='screen')

ld = LaunchDescription()
ld.add_action(declare_use_rviz_cmd)
ld.add_action(declare_simulator_cmd)
ld.add_action(start_gazebo_server_cmd)
ld.add_action(start_gazebo_client_cmd)
ld.add_action(start_robot_state_publisher_cmd)
Expand Down
23 changes: 22 additions & 1 deletion nav2_simple_commander/launch/nav_to_pose_example_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import ExecuteProcess, IncludeLaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PythonExpression
from launch_ros.actions import Node


Expand All @@ -30,12 +32,28 @@ def generate_launch_description():
map_yaml_file = os.path.join(warehouse_dir, 'maps', '005', 'map.yaml')
world = os.path.join(python_commander_dir, 'warehouse.world')

# Launch configuration variables
use_rviz = LaunchConfiguration('use_rviz')
headless = LaunchConfiguration('headless')

# Declare the launch arguments
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)')

# start the simulation
start_gazebo_server_cmd = ExecuteProcess(
cmd=['gzserver', '-s', 'libgazebo_ros_factory.so', world],
cwd=[warehouse_dir], output='screen')

start_gazebo_client_cmd = ExecuteProcess(
condition=IfCondition(PythonExpression(['not ', headless])),
cmd=['gzclient'],
cwd=[warehouse_dir], output='screen')

Expand All @@ -51,6 +69,7 @@ def generate_launch_description():
rviz_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(nav2_bringup_dir, 'launch', 'rviz_launch.py')),
condition=IfCondition(use_rviz),
launch_arguments={'namespace': '',
'use_namespace': 'False'}.items())

Expand All @@ -68,6 +87,8 @@ def generate_launch_description():
output='screen')

ld = LaunchDescription()
ld.add_action(declare_use_rviz_cmd)
ld.add_action(declare_simulator_cmd)
ld.add_action(start_gazebo_server_cmd)
ld.add_action(start_gazebo_client_cmd)
ld.add_action(start_robot_state_publisher_cmd)
Expand Down
23 changes: 22 additions & 1 deletion nav2_simple_commander/launch/picking_demo_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import ExecuteProcess, IncludeLaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PythonExpression
from launch_ros.actions import Node


Expand All @@ -30,12 +32,28 @@ def generate_launch_description():
map_yaml_file = os.path.join(warehouse_dir, 'maps', '005', 'map.yaml')
world = os.path.join(python_commander_dir, 'warehouse.world')

# Launch configuration variables
use_rviz = LaunchConfiguration('use_rviz')
headless = LaunchConfiguration('headless')

# Declare the launch arguments
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)')

# start the simulation
start_gazebo_server_cmd = ExecuteProcess(
cmd=['gzserver', '-s', 'libgazebo_ros_factory.so', world],
cwd=[warehouse_dir], output='screen')

start_gazebo_client_cmd = ExecuteProcess(
condition=IfCondition(PythonExpression(['not ', headless])),
cmd=['gzclient'],
cwd=[warehouse_dir], output='screen')

Expand All @@ -51,6 +69,7 @@ def generate_launch_description():
rviz_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(nav2_bringup_dir, 'launch', 'rviz_launch.py')),
condition=IfCondition(use_rviz),
launch_arguments={'namespace': '',
'use_namespace': 'False'}.items())

Expand All @@ -68,6 +87,8 @@ def generate_launch_description():
output='screen')

ld = LaunchDescription()
ld.add_action(declare_use_rviz_cmd)
ld.add_action(declare_simulator_cmd)
ld.add_action(start_gazebo_server_cmd)
ld.add_action(start_gazebo_client_cmd)
ld.add_action(start_robot_state_publisher_cmd)
Expand Down
Loading

0 comments on commit c1a2abd

Please sign in to comment.