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

feat(realtime_factor): pass use_sim_time to Autoware #1207

Merged
merged 24 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5d86907
use_sim_time used in concealer initialization
pawellech1 Mar 5, 2024
57a3f92
doc(time): add realtime_factor doc
dmoszynski Jul 30, 2024
50e32fa
Merge branch 'master' into doc/RJD-1273-add-realtime-factor-doc
dmoszynski Jul 30, 2024
6e359a1
doc(scenario_test_runnrer): fix spell and link
dmoszynski Jul 30, 2024
b487ff2
Merge remote-tracking branch 'origin/master' into fix/use-sim-time-fo…
dmoszynski Jul 30, 2024
69bc2a3
doc(simulator_test_runner): add EOF to RealtimeFactor
dmoszynski Jul 30, 2024
da85edf
feat(params): set use_sim_time default as True
dmoszynski Jul 30, 2024
03d8c35
Merge remote-tracking branch 'origin/doc/RJD-1273-add-realtime-factor…
dmoszynski Jul 30, 2024
4b1a8d9
doc(scenario_test_runner): adapt doc to changes in use_sim_time
dmoszynski Jul 30, 2024
f7a1d7c
doc(scenario_test_runner): add EOF to RealtimeFactor
dmoszynski Jul 30, 2024
ce60f16
Merge branch 'master' into fix/use-sim-time-for-real-time-factor-control
dmoszynski Aug 1, 2024
eba515a
Merge branch 'master' into fix/use-sim-time-for-real-time-factor-control
dmoszynski Aug 13, 2024
7c71fa0
Revert "feat(params): set use_sim_time default as True"
dmoszynski Aug 26, 2024
0b6f784
Merge branch 'master' into fix/use-sim-time-for-real-time-factor-control
dmoszynski Aug 26, 2024
0dee3c5
feat(use_sim_time): set default as false
dmoszynski Aug 26, 2024
501f664
feat(doc): adapt doc to use_sim_time default as False
dmoszynski Aug 26, 2024
c272592
Merge branch 'master' into fix/use-sim-time-for-real-time-factor-control
dmoszynski Aug 26, 2024
616cfb2
Merge branch 'master' into fix/use-sim-time-for-real-time-factor-control
dmoszynski Aug 27, 2024
4cf7898
Merge branch 'master' into fix/use-sim-time-for-real-time-factor-control
dmoszynski Aug 28, 2024
c41eab5
Merge branch 'master' into fix/use-sim-time-for-real-time-factor-control
HansRobo Aug 30, 2024
b734f9e
ref(doc): change ss2 to scenario_simulator_v2
dmoszynski Aug 30, 2024
b07aef9
doc(realtimefactor): fix inconsistencies
dmoszynski Sep 2, 2024
e73f960
Merge branch 'master' into fix/use-sim-time-for-real-time-factor-control
dmoszynski Sep 2, 2024
8be541e
Merge branch 'master' into fix/use-sim-time-for-real-time-factor-control
HansRobo Sep 3, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/custom_spell.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"TESTRANDOMIZER",
"travelling",
"Tschirnhaus",
"walltime",
"xerces",
"xercesc",
"yamacir-kit"
Expand Down
Binary file added docs/image/realtime_factor/panel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/realtime_factor/slider.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/image/realtime_factor/video.mp4
Binary file not shown.
1 change: 1 addition & 0 deletions docs/user_guide/scenario_test_runner/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ nav:
- Overview: ScenarioTestRunner.md
- ScenarioFormatConversion.md
- HowToWriteWorkflowFile.md
- RealtimeFactor.md
- Tips.md
78 changes: 78 additions & 0 deletions docs/user_guide/scenario_test_runner/RealtimeFactor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# How to use realtime factor

It is possible to modify the speed of simulation (the speed of time published on the /clock topic is not affected):

- from the start of the simulation (using parameter),
- during the simulation (using the GUI slider).

## Use parameter

- When you run simulations on the command line, add an `global_real_time_factor` parameter with a custom value (the default is 1.0).

```bash
ros2 launch scenario_test_runner scenario_test_runner.launch.py \
architecture_type:=awf/universe \
dmoszynski marked this conversation as resolved.
Show resolved Hide resolved
record:=false \
scenario:='$(find-pkg-share scenario_test_runner)/scenario/sample.yaml' \
sensor_model:=sample_sensor_kit \
vehicle_model:=sample_vehicle \
global_real_time_factor:="0.5"
```

- The smaller the value you specify, the slower the simulation will progress.

## Use slider on run time

- When the simulation is started you can add the `RViz` panel by clicking `Panels -> Add new panel` in the top left corner of RViz.

- Then in the pop up window please select `RealTimeFactorSliderPanel` and double click on it.

![Panel](../../image/realtime_factor/panel.png)

- Slider controlling the speed of simulation time should be visible on the left side of the screen.

![Slider](../../image/realtime_factor/slider.png)

- The process of adding the panel is also visible in the video:

<video width="1080" controls muted>
<source src="/image/realtime_factor/video.mp4" type="video/mp4">
</video>


## Configure `use_sim_time` parameter

Parameter `use_sim_time` of `openscenario_interpreter` is **false** by default and can be modified by passing it using command line.


```bash
ros2 launch scenario_test_runner scenario_test_runner.launch.py \
architecture_type:=awf/universe \
dmoszynski marked this conversation as resolved.
Show resolved Hide resolved
record:=false \
scenario:='$(find-pkg-share scenario_test_runner)/scenario/sample.yaml' \
sensor_model:=sample_sensor_kit \
vehicle_model:=sample_vehicle \
global_real_time_factor:="0.5" \
use_sim_time:=true
```

However, this impacts the time published on the `/clock` topic and the time used by `Autoware`.
Details are shown in the table below:

| use_sim_time launch parameter | /clock time published by scenario_simulator_v2 | AWF Autoware Time |
| ----------------------------- | ---------------------------------------------- | ---------------------- |
| false | walltime | walltime from /clock |
| true (default) | simulation | simulation from /clock |
dmoszynski marked this conversation as resolved.
Show resolved Hide resolved

Below are also some bullet points explaining the impact of the `use_sim_time` parameter on `scenario_simulator_v2` and `Autoware`:

- **`use_sim_time:=True` passed using command line (default value)**
- Both Autoware and scenario_simulator_v2 are launched with `use_sim_time=true`.
- Time published on `/clock` is the **simulation time** (starting from 0).
- Time published on `/clock` **can be** controlled by RViz plugin.
- Simulation time **can be** controlled by RViz plugin.
- **`use_sim_time:=False` passed using command line**
dmoszynski marked this conversation as resolved.
Show resolved Hide resolved
- Both Autoware and scenario_simulator_v2 are launched with `use_sim_time=false`.
- Time published on `/clock` is the **walltime**.
- Time published on `/clock` **cannot be** controlled by RViz plugin.
- Simulation time **can be** controlled by RViz plugin.
5 changes: 4 additions & 1 deletion simulation/traffic_simulator/src/entity/ego_entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ auto EgoEntity::makeFieldOperatorApplication(
: Configuration::Pathname(rviz_config).string()),
"scenario_simulation:=true", "use_foa:=false",
"perception/enable_traffic_light:=" +
std::string((architecture_type >= "awf/universe/20230906") ? "true" : "false"))
std::string((architecture_type >= "awf/universe/20230906") ? "true" : "false"),
"use_sim_time:=" +
std::string(
getParameter<bool>(node_parameters, "use_sim_time", false) ? "true" : "false"))
: std::make_unique<
concealer::FieldOperatorApplicationFor<concealer::AutowareUniverse>>();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def description():
namespace="simulation",
output="screen",
on_exit=ShutdownOnce(),
parameters=make_parameters() + [{"use_sim_time": True}],
parameters=make_parameters() + [{"use_sim_time": use_sim_time}],
condition=IfCondition(launch_simple_sensor_simulator),
),
# The `name` keyword overrides the name for all created nodes, so duplicated nodes appear.
Expand Down
Loading