Commit 527f7fa
EnvironmentPreload visualise static environments (gazebosim#3138)
## Summary
This PR fixes an issue where a static environment loaded by the EnvironmentPreload system would not display using the Environment Visualization Resolution and Point Cloud GUI widgets.
There is also a fix that prevents segmentation faults in the VisualizationTool caused by copying a DataFrame which may invalidate the session iterators.
## Details
Before this change, if the `<ignore_time>` element is added to the EnvironmentPreload system xml it is ignored when visualising the point cloud data.
```xml
<plugin
filename="gz-sim-environment-preload-system"
name="gz::sim::systems::EnvironmentPreload">
<data>environmental_data.csv</data>
<dimensions>
<ignore_time>1</ignore_time>
<time>timestamp</time>
<space>
<x>x</x>
<y>y</y>
<z>z</z>
</space>
</dimensions>
</plugin>
```
This means that if only the time zero data is provided, for example:
```bash
# environmental_data.csv - modified to only contain data for timestamp = 0
timestamp,humidity,x,y,z
0,80,-1,-1,-1
0,80,-1,-1, 1
0,80,-1, 1,-1
0,80,-1, 1, 1
0,90, 1,-1,-1
0,90, 1,-1, 1
0,90, 1, 1,-1
0,90, 1, 1, 1
```
the VisualizationTool would never display the point cloud data.
A workaround for this is to set a very large timestamp for a second copy of data. This is unsatisfactory because it doubles the size of the environment data required (which may be significant for large vector fields), and also requires a temporal interpolation when none is required, which results in a performance penalty.
The other fix is to pay attention to unintended copies when using the auto keyword to obtain aliases to the data frame objects. The main change is
```diff
- auto frame = _data->frame[this->pubs.begin()->first];
+ const auto &frame = _data->frame[this->pubs.begin()->first];
```
The problem is that the session iterators will in general be invalid for the copied frame, and this may result in a segmentation fault when they are dereferenced later in the code. In this particular case the check that the iterator was in range in the interpolation code failed resulting in a out of range access violation a few lines later. This type of error can be difficult to trace.
With this change, and some other related fixes to the environmental data system, large static vector fields can be loaded and viewed in the GUI. Below is an example for a wind field containing 64000 rows of data.
<img width="1312" height="940" alt="05-1-gz-wind-pc-x-axis" src="https://github.com/user-attachments/assets/72d9bd99-3640-456d-975a-9fc2d6387884" />
---------
Signed-off-by: Rhys Mainwaring <[email protected]>1 parent 2a1c354 commit 527f7fa
File tree
4 files changed
+65
-46
lines changed- examples/worlds
- src/systems/environment_preload
4 files changed
+65
-46
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
285 | | - | |
| 285 | + | |
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| |||
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
340 | | - | |
| 340 | + | |
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
| |||
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
352 | | - | |
| 352 | + | |
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| |||
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| 59 | + | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
59 | 70 | | |
60 | 71 | | |
61 | 72 | | |
62 | 73 | | |
63 | 74 | | |
64 | 75 | | |
65 | 76 | | |
| 77 | + | |
66 | 78 | | |
67 | 79 | | |
68 | 80 | | |
69 | 81 | | |
70 | | - | |
| 82 | + | |
71 | 83 | | |
72 | 84 | | |
73 | 85 | | |
| |||
82 | 94 | | |
83 | 95 | | |
84 | 96 | | |
85 | | - | |
86 | | - | |
| 97 | + | |
87 | 98 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
| 99 | + | |
| 100 | + | |
96 | 101 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
102 | 116 | | |
103 | 117 | | |
104 | 118 | | |
| |||
118 | 132 | | |
119 | 133 | | |
120 | 134 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
128 | 142 | | |
129 | 143 | | |
130 | 144 | | |
131 | | - | |
| 145 | + | |
132 | 146 | | |
133 | 147 | | |
134 | | - | |
| 148 | + | |
135 | 149 | | |
136 | 150 | | |
137 | | - | |
138 | | - | |
| 151 | + | |
| 152 | + | |
139 | 153 | | |
140 | 154 | | |
141 | 155 | | |
| |||
176 | 190 | | |
177 | 191 | | |
178 | 192 | | |
179 | | - | |
| 193 | + | |
180 | 194 | | |
181 | 195 | | |
182 | 196 | | |
183 | 197 | | |
184 | 198 | | |
185 | 199 | | |
186 | | - | |
187 | | - | |
188 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
189 | 203 | | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
194 | 208 | | |
195 | 209 | | |
196 | 210 | | |
| |||
199 | 213 | | |
200 | 214 | | |
201 | 215 | | |
202 | | - | |
| 216 | + | |
203 | 217 | | |
204 | 218 | | |
205 | | - | |
| 219 | + | |
206 | 220 | | |
207 | 221 | | |
208 | | - | |
209 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
210 | 225 | | |
211 | 226 | | |
212 | 227 | | |
213 | 228 | | |
214 | 229 | | |
215 | 230 | | |
216 | 231 | | |
217 | | - | |
| 232 | + | |
218 | 233 | | |
219 | 234 | | |
220 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
81 | 84 | | |
82 | 85 | | |
83 | 86 | | |
| |||
0 commit comments