Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pause run tutorial #2383

Merged
merged 4 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions tutorials/pause_run_simulation.md
azeey marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
\page pause_run_simulation Pause and Run simulation

The TODO Gazebo transport API is exposed to allow starting and stopping the simulation.
Ryanf55 marked this conversation as resolved.
Show resolved Hide resolved
It's possible to call this API using the command line or through the GUI.

To repeat this demo, run the `default` world:
```bash
gz sim default.sdf
```

## Transport API

When Gazebo is run headless, this is an easy way to start the simulation.

To pause and play over the transport API, we should call the service `/world/<world_name>/control` and fill the request message type
`gz.msgs.WorldControl`. This service returns a `gz.msgs.Boolean` with the status of the request (true means everything was fine, false otherwise).

The `WorldControl` message contains a `pause` field for starting and stopping the simulation.

To start the simulation:

```bash
gz service -s /world/default/control --reqtype gz.msgs.WorldControl --reptype gz.msgs.Boolean --timeout 3000 --req 'pause: false'
```

To pause the simulation:

```bash
gz service -s /world/default/control --reqtype gz.msgs.WorldControl --reptype gz.msgs.Boolean --timeout 3000 --req 'pause: true'
```

When paused, time will stop in Gazebo, and the physics will not be running.

To check the current state of the simulator, check the `paused` field in `/stats` like so:
```bash
gz topic --echo --topic /stats -n 1
```
If the simulator is currently paused but was running before, we would see something similar to this:
```text
sim_time {
sec: 8
nsec: 707000000
}
real_time {
sec: 8
nsec: 824323281
}
iterations: 8707
real_time_factor: 0.998022916602211
```


## GUI

We included a button in the `World Control` plugin allowing to start and stop the simulation from the GUI.

@image html files/pause_run_simulation/gui_pause_run.png
7 changes: 6 additions & 1 deletion tutorials/reset_simulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ The Reset Gazebo transport API is exposed to allow resetting simulation to time
It's possible to call this API using the command line or through the GUI.
In addition to the API, we have also expanded the simulation system API with a Reset interface.

To repeat this demo, run the `default` world:
```bash
gz sim default.sdf
azeey marked this conversation as resolved.
Show resolved Hide resolved
```

## Reset interface

System authors may now choose to implement the Reset interface to have a more intelligent
Expand All @@ -16,7 +21,7 @@ Follow the tutorial \subpage createsystemplugins to see how to support Reset by
## Transport API

To invoke reset over transport API, we should call the service `/world/<world_name>/control` and fill the request message type
`gz.msgs.WorldControl`. This service returns a `gz.msgs.Boolean` with the status of the reset (true means everything was fine, false otherwise)
`gz.msgs.WorldControl`. This service returns a `gz.msgs.Boolean` with the status of the reset (true means everything was fine, false otherwise).

The `WorldControl` message now contains a `reset` field for resetting the world:

Expand Down
Loading