Skip to content

Commit

Permalink
Add headless mode to simulation-gazebo (#37)
Browse files Browse the repository at this point in the history
* Add headless mode to simulation-gazebo

`-s` and `-g` flags can be used to run gazebo server and GUI separately. `--headless` flag to python script adds ability to trigger `-s` behavior from the CLI.

* Add --headless description to README

* Update simulation-gazebo, flag -s is seperated onto its own line for readability

Co-authored-by: Frederik Markus <[email protected]>

---------

Co-authored-by: Frederik Markus <[email protected]>
  • Loading branch information
cbugk and frede791 authored Mar 27, 2024
1 parent 14d9c68 commit c3905a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ The following arguments can be passed:
`--overwrite` A boolean variable providing the ability to overwrite existing directories with new data.

`--dryrun` A boolean variable that can be set when running testcases. It will not provide any interactivity and will not start Gazebo simulation.

`--headless` A boolean variable providing the ability to run in headless (server-only) mode. This is the [mode of operation in macOS](https://gazebosim.org/docs/harmonic/getstarted#macos), and is more suitable for container use.
3 changes: 3 additions & 0 deletions simulation-gazebo
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def main():
parser.add_argument('--model_store', help='Path to model storage directory', required=False, default="~/.simulation-gazebo")
parser.add_argument('--overwrite', help='Overwrite existing model directories', required=False, default=False, action='store_true')
parser.add_argument('--dryrun', help='Test in dryrun. Do not launch gazebo', required=False, default=False, action='store_true')
parser.add_argument('--headless', help='Run Gazebo without GUI', required=False, default=False, action='store_true')

args = parser.parse_args()

Expand Down Expand Up @@ -90,6 +91,8 @@ def main():
print('> Launching gazebo simulation...')
if not args.dryrun:
cmd = f'GZ_SIM_RESOURCE_PATH={args.model_store}/models gz sim -r {args.model_store}/worlds/{args.world}.sdf'
if args.headless:
cmd = f'{cmd} -s'

if args.gz_partition:
cmd = f'GZ_PARTITION={args.gz_partition} {cmd}'
Expand Down

0 comments on commit c3905a7

Please sign in to comment.