Skip to content

Commit

Permalink
Merge pull request #694 from osrf/M1chaelM/gz_recording_args
Browse files Browse the repository at this point in the history
add command line argument for passing extra args to gz sim
  • Loading branch information
M1chaelM authored Jun 30, 2023
2 parents dc3d955 + a55091b commit da7aed4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
13 changes: 12 additions & 1 deletion vrx_gz/launch/competition.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def launch(context, *args, **kwargs):
robot = LaunchConfiguration('robot').perform(context)
headless = LaunchConfiguration('headless').perform(context).lower() == 'true'
robot_urdf = LaunchConfiguration('urdf').perform(context)
gz_paused = LaunchConfiguration('paused').perform(context).lower() == 'true'
extra_gz_args = LaunchConfiguration('extra_gz_args').perform(context)

launch_processes = []

Expand All @@ -46,7 +48,8 @@ def launch(context, *args, **kwargs):
models.append(m)

world_name, ext = os.path.splitext(world_name)
launch_processes.extend(vrx_gz.launch.simulation(world_name, headless))
launch_processes.extend(vrx_gz.launch.simulation(world_name, headless,
gz_paused, extra_gz_args))
world_name_base = os.path.basename(world_name)
launch_processes.extend(vrx_gz.launch.spawn(sim_mode, world_name_base, models, robot))

Expand Down Expand Up @@ -91,5 +94,13 @@ def generate_launch_description():
'urdf',
default_value='',
description='URDF file of the wam-v model. '),
DeclareLaunchArgument(
'paused',
default_value='False',
description='True to start the simulation paused. '),
DeclareLaunchArgument(
'extra_gz_args',
default_value='',
description='Additional arguments to be passed to gz sim. '),
OpaqueFunction(function=launch),
])
10 changes: 8 additions & 2 deletions vrx_gz/src/vrx_gz/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,16 @@
'follow_path2'
]

def simulation(world_name, headless=False):
gz_args = ['-v 4', '-r']
def simulation(world_name, headless=False, paused=False, extra_gz_args=''):
gz_args = ['-v 4']
if not paused:
gz_args.append('-r')

if headless:
gz_args.append('-s')

gz_args.append(extra_gz_args)

gz_args.append(f'{world_name}.sdf')

gz_sim = IncludeLaunchDescription(
Expand Down

0 comments on commit da7aed4

Please sign in to comment.