Skip to content

Commit 72436d6

Browse files
ahcordeiche033
andauthored
Perfomance metrics tutorial (#117)
* Included perfomance metrics tutorial Signed-off-by: ahcorde <ahcorde@gmail.com> * updated tutorial Signed-off-by: ahcorde <ahcorde@gmail.com> * Added feedback Signed-off-by: ahcorde <ahcorde@gmail.com> * update tutorial Signed-off-by: ahcorde <ahcorde@gmail.com> * remove numbers in real time update rate section, and added clarifications Signed-off-by: Ian Chen <ichen@osrfoundation.org> * Update tutorial Signed-off-by: ahcorde <ahcorde@gmail.com> Co-authored-by: Ian Chen <ichen@osrfoundation.org>
1 parent cdff63a commit 72436d6

File tree

1 file changed

+198
-0
lines changed

1 file changed

+198
-0
lines changed

performance_metrics/tutorial.md

+198
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
# Performance metrics
2+
3+
Gazebo 9 and Gazebo 11 publish a message called `/gazebo/performance_metrics` that allows to check the performance
4+
of each sensor in the world.
5+
6+
# Learn how to read the measurements
7+
8+
We are going to compare the results between physics (contact) and rendering (camera) based sensors and the differences
9+
when the `lockstep` flag is active.
10+
11+
## Camera
12+
13+
For the rendering-based sensor we are going to use the [camera_strict_rate.world](https://github.com/osrf/gazebo/blob/gazebo9/test/worlds/camera_strict_rate.world) world. It contains two cameras: a high-resolution (1280x720) high-frame-rate (500 fps) and a a low-resolution (320x240) low-frame-rate (30 fps) camera.
14+
15+
### Run the world without lockstep
16+
17+
With the `lockstep` flag deactivated there is no guarantee that the camera sensor update happens in the same iteration as the physics simulation. This means the `sim_update_rate` could not correspond with the real value defined in the world. Inspect the `sim_update_rate` field, it is likely unable to reach the specified 500 fps. The other low-resolution camera is able to reach the specified value. Take note of the `real time factor` it should be close to 1.0.
18+
19+
```bash
20+
real_time_factor: 0.99798848700000009
21+
sensor {
22+
name: "default::camera_model::link::camera_sensor"
23+
real_update_rate: 191.64276561974779
24+
sim_update_rate: 166.66666666666666
25+
fps: 213.16120910644531
26+
}
27+
sensor {
28+
name: "default::camera_model::link::camera_sensor_regular"
29+
real_update_rate: 31.1463905584825
30+
sim_update_rate: 30.3030303030303
31+
fps: 29.975315093994141
32+
}
33+
...
34+
real_time_factor: 0.9913419670000001
35+
sensor {
36+
name: "default::camera_model::link::camera_sensor"
37+
real_update_rate: 224.15729745202637
38+
sim_update_rate: 200
39+
fps: 213.16120910644531
40+
}
41+
sensor {
42+
name: "default::camera_model::link::camera_sensor_regular"
43+
real_update_rate: 31.294063018669757
44+
sim_update_rate: 31.25
45+
fps: 29.895561218261719
46+
}
47+
```
48+
49+
### Run the world with lockstep
50+
51+
With the `lockstep` flag activated the `sim_update_rate` must correspond with the real value
52+
defined in the world. In this case we expect the `sim_update_rate` to be equal to 500 for the high resolution camera
53+
and 30 for the low resolution camera. Then the `fps` value means that Gazebo is able to generate on average 337 frames in a *real second*.
54+
55+
The real time factor is likely less than 1.0. The exact number depends on your computing power. This shows that
56+
the sensor's update rate is strictly followed, and physics has slowed down in order to accommodate for the high update rate.
57+
58+
```bash
59+
real_time_factor: 0.5083145
60+
sensor {
61+
name: "default::camera_model::link::camera_sensor"
62+
real_update_rate: 254.39207924822054
63+
sim_update_rate: 500
64+
fps: 279.38592529296875
65+
}
66+
sensor {
67+
name: "default::camera_model::link::camera_sensor_regular"
68+
real_update_rate: 12.626295945654704
69+
sim_update_rate: 30.3030303030303
70+
fps: 16.778518676757812
71+
}
72+
```
73+
74+
## Contact sensor
75+
76+
For the physics-based sensors we are going to use the [contact_strict_rate.world](https://github.com/osrf/gazebo/blob/gazebo9/test/worlds/contact_strict_rate.world) world. It contains a contact sensor (1000 Hz).
77+
78+
In this case both world look pretty similar, even with this high update rate. Because the update loop
79+
is small in this case. This may vary with a more complex object
80+
81+
### Run the world without lockstep
82+
83+
```bash
84+
real_time_factor: 0.988433204
85+
sensor {
86+
name: "world_1::model_1::link_1::sensor_contact"
87+
real_update_rate: 964.34805249910789
88+
sim_update_rate: 1000
89+
}
90+
```
91+
92+
### Run the world with lockstep
93+
94+
```
95+
real_time_factor: 1.003396497
96+
sensor {
97+
name: "world_1::model_1::link_1::sensor_contact"
98+
real_update_rate: 1006.3885545442469
99+
sim_update_rate: 1000
100+
}
101+
```
102+
103+
## Real time update rate
104+
105+
We can modify the Real time update rate in the Physics Engine. In this case the Real time update rate is set to **10** which makes the simulation slower. As you may see the `sim_update_rate` in both cameras are the expected value 500 and 30. The `real_update_rate` and `fps` (average framerate per second in *real time*) are lower since the simulation is running slower than real time, and sometimes they are 0 if samples are taken during a period where no camera updates occurred.
106+
107+
### Run the world with lockstep
108+
109+
```bash
110+
real_time_factor: 0.010068691000000001
111+
sensor {
112+
name: "default::camera_model::link::camera_sensor"
113+
real_update_rate: 5.0011468129756835
114+
sim_update_rate: 500
115+
fps: 53.769622802734375
116+
}
117+
sensor {
118+
name: "default::camera_model::link::camera_sensor_regular"
119+
real_update_rate: 6.90647889204339e-310
120+
sim_update_rate: 3.8230348098869816e-171
121+
fps: 4.67267173345723e-310
122+
}
123+
124+
real_time_factor: 0.010036926
125+
sensor {
126+
name: "default::camera_model::link::camera_sensor"
127+
real_update_rate: 5.0083617102934195
128+
sim_update_rate: 500
129+
fps: 53.769622802734375
130+
}
131+
sensor {
132+
name: "default::camera_model::link::camera_sensor_regular"
133+
real_update_rate: 0.095422706503929658
134+
sim_update_rate: 30.3030303030303
135+
fps: 12.767441749572754
136+
}
137+
```
138+
139+
### Run the world without lockstep
140+
141+
Again in this case, where we run the world without `lockstep`, there is no guarantee that the camera sensor update happens
142+
in the same iteration as the physics simulation, the `real_update_rate` value is highly impacted, it should be
143+
close to 500 but in this case it's close to 5.
144+
145+
```bash
146+
real_time_factor: 0
147+
sensor {
148+
name: "default::camera_model::link::camera_sensor"
149+
real_update_rate: 5.33382822725157
150+
sim_update_rate: 1000
151+
fps: 52.516761779785156
152+
}
153+
sensor {
154+
name: "default::camera_model::link::camera_sensor_regular"
155+
real_update_rate: 0.29837649072676692
156+
sim_update_rate: 29.411764705882351
157+
fps: 9.8744449615478516
158+
}
159+
```
160+
161+
### max step size
162+
163+
The maximum time step size that can be taken by a variable time-step solver (such as simbody) during simulation.
164+
For physics engines with fixed-step solvers (like ODE), this is simply the time step size. The default value
165+
in Gazebo is 0.001 seconds.
166+
167+
When you choose the `update rate` of a sensor you need to take in account if you have enough precision
168+
defined in `max step size`. For example:
169+
170+
- 1/250 = 0.004 it's fine using the default value.
171+
- 1/400 = 0.0025. You will need to reduce the `max step size` to a number that is a factor of 0.0025, e.g. 0.0001, this will make the simulation slower. Changing this parameter has a side effect on the accuracy and speed of physics simulation, refer to this [tutorial](http://gazebosim.org/tutorials?tut=physics_params&cat=physics) for more information.
172+
173+
In the following traces we included a IMU sensor at 400Hz. You can see that the `sim_update_rate` does not correspond with the defined value
174+
because the `max step size` does not have enough precision.
175+
176+
```bash
177+
sensor {
178+
name: "world_1::model_1::link_1::sensor_contact"
179+
real_update_rate: 181.87525758083353
180+
sim_update_rate: 200
181+
}
182+
...
183+
sensor {
184+
name: "world_1::model_1::link_1::sensor_contact"
185+
real_update_rate: 252.94164813236739
186+
sim_update_rate: 333.33333333333331
187+
}
188+
```
189+
190+
If we modify the `max step size` to 0.0001, then you will see the right value.
191+
192+
```bash
193+
sensor {
194+
name: "world_1::model_1::link_1::sensor_contact"
195+
real_update_rate: 39.899370595408726
196+
sim_update_rate: 400
197+
}
198+
```

0 commit comments

Comments
 (0)