Skip to content

Commit 3402968

Browse files
committed
Swarm: update notes
Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
1 parent 474a9fe commit 3402968

1 file changed

Lines changed: 165 additions & 0 deletions

File tree

scripts/CopterSwarm.md

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,172 @@ python ./src/ardupilot_gazebo/scripts/copter_swarm.py --world runway --model iri
142142
Statically defined models
143143

144144
- IMU sensor causing segmentation fault
145+
- Fix - add check before dereferencing pointer Imu.cc, ImuPrivate::AddSensor, L:233
146+
- Why is this not raising an exception in the non-distributed case?
147+
-
145148

146149
Dynamically defined models
147150

148151
- Not found on secondary
152+
153+
SITL Swarm
154+
155+
- Not working for `--count 1` - error loading params?
156+
157+
Gazebo
158+
159+
- What happens to the socket when a level is unloaded?
160+
161+
Levels
162+
163+
- Don't work well if non-performer entities are loaded dynamically
164+
- GUI crashed as levels loaded / unloaded (repeatable?)
165+
- Level tiles loading and unloading correctly if defined statically
166+
167+
Test 1:
168+
169+
```bash
170+
ros2-ardupilot % gz sim -v4 -s -r --levels runway.sdf
171+
```
172+
173+
- number of copters: 1
174+
- dynamically load copters: no
175+
- dynamically load performers: no
176+
- number of levels: 25
177+
- dynamically load level visuals: no
178+
- distributed: no
179+
- number of secondaries: 0
180+
- status: ok
181+
182+
Test 2:
183+
184+
```bash
185+
gz sim -v4 -s -r --levels --network-role primary --network-secondaries 0 runway.sdf
186+
```
187+
188+
- number of copters: 1
189+
- dynamically load copters: no
190+
- dynamically load performers: no
191+
- number of levels: 25
192+
- dynamically load level visuals: no
193+
- distributed: yes
194+
- number of secondaries: 0
195+
- status: ok
196+
197+
Test 3:
198+
199+
```bash
200+
gz sim -v4 -s -r --levels --network-role primary --network-secondaries 1 runway.sdf
201+
```
202+
203+
```bash
204+
gz sim -v4 -s -r --levels --network-role secondary runway.sdf
205+
```
206+
207+
- number of copters: 1
208+
- dynamically load copters: no
209+
- dynamically load performers: no
210+
- number of levels: 25
211+
- dynamically load level visuals: no
212+
- distributed: yes
213+
- number of secondaries: 1
214+
- status: fail
215+
216+
primary
217+
218+
```bash
219+
(2025-11-04 19:53:15.353) [debug] [SystemManager.cc:80] Loaded system [ArduPilotPlugin] for entity [43]
220+
...
221+
(2025-11-04 19:53:15.980) [info] [ArduPilotPlugin.cc:1147] Found IMU sensor with name [iris_with_standoffs::imu_link::imu_sensor]
222+
(2025-11-04 19:53:15.980) [debug] [ArduPilotPlugin.cc:1161] Computed IMU topic to be: world/runway/model/iris_with_ardupilot_1/model/iris_with_standoffs/link/imu_link/sensor/imu_sensor/imu
223+
```
224+
225+
secondary
226+
227+
```bash
228+
SocketUDP Bind failed: Address already in use
229+
(2025-11-04 19:53:15.877) [error] [ArduPilotPlugin.cc:1282] [iris_with_ardupilot_1] failed to bind with 127.0.0.1:9002 aborting plugin.
230+
...
231+
(2025-11-04 19:53:16.598) [warning] [ArduPilotPlugin.cc:1568] Incorrect protocol magic 255 should be 18458
232+
```
233+
234+
Sockets are going to present a problem - we cannot load a model twice using the same port. The binding occurs at model load, even though the entity is not loaded, the plugin is bound.
235+
236+
Need to seek an alternative approach...
237+
238+
- Use a proxy model to load the plugin, but assign outputs to the actual model.
239+
- Still have the same problem - the model is loaded into all `gz sim instances`
240+
- unless we also have two separate worlds, one with the proxy, and one without
241+
- issue is that the entity ids will then be different - so inconsistent.
242+
243+
- Alternative settings for UDP sockets?
244+
- Can use `SO_REUSEPORT` and allow multiple sockets to bind to the same port, however this causes other errors at runtime, as processes where the entity is unloaded continue to send (invalid) data.
245+
- Can we check if an entity is loaded, and disable the plugin if that is the case?
246+
- Or use an entirely gz-transport based approach (c.f. PX4).
247+
248+
249+
250+
How does PX4 manage this?
251+
252+
- PX4-Autopilot/src/modules/simulation/gz_bridge/GZBridge.hpp
253+
254+
GZBridge:
255+
256+
Interface
257+
258+
- Class `GZBridge` constructed with world and model names.
259+
- Subscriptions to topics
260+
- Clock
261+
- PoseIno
262+
- Imu
263+
- Mag
264+
- Odometry
265+
- LaserScan
266+
- DistanceSensor
267+
- AirSpeed
268+
- AirPressure
269+
- NavSat
270+
- OpticalFlow
271+
- Mixing interface objects are used for
272+
- Motors
273+
- Servos
274+
- Wheels (why different to motors?)
275+
- Gimbal
276+
- Facility for adding noise (why not just use physics engine?)
277+
- Separate object to handle one gimbal
278+
279+
Implementation
280+
281+
- init
282+
- subscribe to all topics
283+
- Run
284+
- updates parameters
285+
- subscribeXXX
286+
- Only support one IMU and must be on /link/base_link/sensor/imu_sensor/imu
287+
- ditto magnetometer
288+
- similarly for other sensors which have hardcoded link and sensor names
289+
- clockCallback
290+
- keeps PX4 RT clock synchronised with the sim time
291+
- sensor callbacks
292+
- Read messages, update devices directly
293+
- Can't see any mechanism for maintaining lockstep?
294+
295+
MixingInterfaceESC : OutputModuleInterface
296+
297+
Interface
298+
299+
- MixingOutput _mixing_output
300+
301+
- init
302+
- fixed topic name /{model_name}/command/motor_speed
303+
- updateOutputs
304+
- publish gz::msg::Actuators
305+
306+
## Notes
307+
308+
- Change iris_with_ardupilot to use JointController
309+
- Publish commands from the ArduPilotPlugin
310+
- Topic name /model/{model}/joint/{joint_name}/cmd_vel
311+
- Consider using /model/{model}/joint/{joint_name}/command/motor_speed to standardise (PX4)?
312+
- A
313+

0 commit comments

Comments
 (0)