-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquadcopter_demo.sdf
More file actions
546 lines (509 loc) · 18 KB
/
Copy pathquadcopter_demo.sdf
File metadata and controls
546 lines (509 loc) · 18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
<?xml version="1.0" ?>
<!--
Quadcopter sensor demo for gz-camera-stream.
X3 UAV with velocity control, forward and downward cameras,
ground objects from Gazebo Fuel, and a tower overview camera.
All camera feeds are streamable via the CameraStream plugin.
Launch headless:
GZ_SIM_SYSTEM_PLUGIN_PATH=/opt/homebrew/lib \
gz sim -s -r --headless-rendering quadcopter_demo.sdf -v 4
Fly the quadcopter:
gz topic -t "/X3/gazebo/command/twist" -m gz.msgs.Twist \
-p "linear: {z: 0.5}"
Hover:
gz topic -t "/X3/gazebo/command/twist" -m gz.msgs.Twist -p " "
Or run the patrol script:
./fly_patrol.sh
-->
<sdf version="1.9">
<world name="quadcopter_demo">
<physics name="4ms" type="ignored">
<max_step_size>0.004</max_step_size>
<real_time_factor>1.0</real_time_factor>
</physics>
<!-- Core system plugins -->
<plugin
filename="gz-sim-physics-system"
name="gz::sim::systems::Physics">
</plugin>
<plugin
filename="gz-sim-user-commands-system"
name="gz::sim::systems::UserCommands">
</plugin>
<plugin
filename="gz-sim-scene-broadcaster-system"
name="gz::sim::systems::SceneBroadcaster">
</plugin>
<plugin
filename="gz-sim-sensors-system"
name="gz::sim::systems::Sensors">
<render_engine>ogre2</render_engine>
</plugin>
<!-- WebSocket server for viewer.html -->
<plugin
filename="gz-sim-websocket-server-system"
name="gz::sim::systems::WebsocketServer">
<publication_hz>30</publication_hz>
<port>9002</port>
<max_connections>-1</max_connections>
</plugin>
<!-- CameraStream - H.264 encoding to MediaMTX -->
<plugin
filename="gz-sim-camera-stream-system"
name="gz::sim::systems::CameraStream">
<topic>/stream/control</topic>
<default_bitrate>4000000</default_bitrate>
<default_fps>30</default_fps>
</plugin>
<!-- Scene -->
<scene>
<ambient>0.5 0.5 0.5 1.0</ambient>
<background>0.3 0.5 0.8 1.0</background>
<grid>false</grid>
</scene>
<!-- Sun -->
<light type="directional" name="sun">
<cast_shadows>true</cast_shadows>
<pose>0 0 50 0 0 0</pose>
<diffuse>1.0 0.95 0.9 1</diffuse>
<specular>0.5 0.5 0.5 1</specular>
<attenuation>
<range>1000</range>
<constant>0.9</constant>
<linear>0.01</linear>
<quadratic>0.001</quadratic>
</attenuation>
<direction>-0.5 0.3 -0.9</direction>
</light>
<!-- Ground plane -->
<model name="ground_plane">
<static>true</static>
<link name="link">
<collision name="collision">
<geometry>
<plane>
<normal>0 0 1</normal>
<size>200 200</size>
</plane>
</geometry>
</collision>
<visual name="visual">
<geometry>
<plane>
<normal>0 0 1</normal>
<size>200 200</size>
</plane>
</geometry>
<material>
<ambient>0.45 0.55 0.35 1</ambient>
<diffuse>0.45 0.55 0.35 1</diffuse>
<specular>0.1 0.1 0.1 1</specular>
</material>
</visual>
</link>
</model>
<!-- Landing pad -->
<model name="landing_pad">
<static>true</static>
<pose>0 0 0.01 0 0 0</pose>
<link name="link">
<visual name="pad">
<geometry>
<cylinder>
<radius>1.5</radius>
<length>0.02</length>
</cylinder>
</geometry>
<material>
<ambient>0.3 0.3 0.3 1</ambient>
<diffuse>0.3 0.3 0.3 1</diffuse>
</material>
</visual>
<visual name="h_bar1">
<pose>0 0 0.02 0 0 0</pose>
<geometry>
<box><size>0.15 1.0 0.01</size></box>
</geometry>
<material>
<ambient>0.9 0.9 0.0 1</ambient>
<diffuse>0.9 0.9 0.0 1</diffuse>
</material>
</visual>
<visual name="h_bar2">
<pose>0 0 0.02 0 0 1.5708</pose>
<geometry>
<box><size>0.15 0.6 0.01</size></box>
</geometry>
<material>
<ambient>0.9 0.9 0.0 1</ambient>
<diffuse>0.9 0.9 0.0 1</diffuse>
</material>
</visual>
</link>
</model>
<!-- ============================================================ -->
<!-- X3 UAV Quadcopter from Gazebo Fuel -->
<!-- ============================================================ -->
<include>
<uri>https://fuel.gazebosim.org/1.0/OpenRobotics/models/X3 UAV/4</uri>
<name>x3_uav</name>
<pose>0 0 0.2 0 0 0</pose>
<!-- Rotor 0 (CCW) -->
<plugin
filename="gz-sim-multicopter-motor-model-system"
name="gz::sim::systems::MulticopterMotorModel">
<robotNamespace>X3</robotNamespace>
<jointName>X3/rotor_0_joint</jointName>
<linkName>X3/rotor_0</linkName>
<turningDirection>ccw</turningDirection>
<timeConstantUp>0.0125</timeConstantUp>
<timeConstantDown>0.025</timeConstantDown>
<maxRotVelocity>800.0</maxRotVelocity>
<motorConstant>8.54858e-06</motorConstant>
<momentConstant>0.016</momentConstant>
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
<actuator_number>0</actuator_number>
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
<motorSpeedPubTopic>motor_speed/0</motorSpeedPubTopic>
<rotorVelocitySlowdownSim>10</rotorVelocitySlowdownSim>
<motorType>velocity</motorType>
</plugin>
<!-- Rotor 1 (CCW) -->
<plugin
filename="gz-sim-multicopter-motor-model-system"
name="gz::sim::systems::MulticopterMotorModel">
<robotNamespace>X3</robotNamespace>
<jointName>X3/rotor_1_joint</jointName>
<linkName>X3/rotor_1</linkName>
<turningDirection>ccw</turningDirection>
<timeConstantUp>0.0125</timeConstantUp>
<timeConstantDown>0.025</timeConstantDown>
<maxRotVelocity>800.0</maxRotVelocity>
<motorConstant>8.54858e-06</motorConstant>
<momentConstant>0.016</momentConstant>
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
<actuator_number>1</actuator_number>
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
<motorSpeedPubTopic>motor_speed/1</motorSpeedPubTopic>
<rotorVelocitySlowdownSim>10</rotorVelocitySlowdownSim>
<motorType>velocity</motorType>
</plugin>
<!-- Rotor 2 (CW) -->
<plugin
filename="gz-sim-multicopter-motor-model-system"
name="gz::sim::systems::MulticopterMotorModel">
<robotNamespace>X3</robotNamespace>
<jointName>X3/rotor_2_joint</jointName>
<linkName>X3/rotor_2</linkName>
<turningDirection>cw</turningDirection>
<timeConstantUp>0.0125</timeConstantUp>
<timeConstantDown>0.025</timeConstantDown>
<maxRotVelocity>800.0</maxRotVelocity>
<motorConstant>8.54858e-06</motorConstant>
<momentConstant>0.016</momentConstant>
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
<actuator_number>2</actuator_number>
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
<motorSpeedPubTopic>motor_speed/2</motorSpeedPubTopic>
<rotorVelocitySlowdownSim>10</rotorVelocitySlowdownSim>
<motorType>velocity</motorType>
</plugin>
<!-- Rotor 3 (CW) -->
<plugin
filename="gz-sim-multicopter-motor-model-system"
name="gz::sim::systems::MulticopterMotorModel">
<robotNamespace>X3</robotNamespace>
<jointName>X3/rotor_3_joint</jointName>
<linkName>X3/rotor_3</linkName>
<turningDirection>cw</turningDirection>
<timeConstantUp>0.0125</timeConstantUp>
<timeConstantDown>0.025</timeConstantDown>
<maxRotVelocity>800.0</maxRotVelocity>
<motorConstant>8.54858e-06</motorConstant>
<momentConstant>0.016</momentConstant>
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
<actuator_number>3</actuator_number>
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
<motorSpeedPubTopic>motor_speed/3</motorSpeedPubTopic>
<rotorVelocitySlowdownSim>10</rotorVelocitySlowdownSim>
<motorType>velocity</motorType>
</plugin>
<!-- Velocity controller - accepts Twist commands -->
<plugin
filename="gz-sim-multicopter-control-system"
name="gz::sim::systems::MulticopterVelocityControl">
<robotNamespace>X3</robotNamespace>
<commandSubTopic>gazebo/command/twist</commandSubTopic>
<enableSubTopic>enable</enableSubTopic>
<comLinkName>X3/base_link</comLinkName>
<velocityGain>2.7 2.7 2.7</velocityGain>
<attitudeGain>2 3 0.15</attitudeGain>
<angularRateGain>0.4 0.52 0.18</angularRateGain>
<maximumLinearAcceleration>2 2 2</maximumLinearAcceleration>
<rotorConfiguration>
<rotor>
<jointName>X3/rotor_0_joint</jointName>
<forceConstant>8.54858e-06</forceConstant>
<momentConstant>0.016</momentConstant>
<direction>1</direction>
</rotor>
<rotor>
<jointName>X3/rotor_1_joint</jointName>
<forceConstant>8.54858e-06</forceConstant>
<momentConstant>0.016</momentConstant>
<direction>1</direction>
</rotor>
<rotor>
<jointName>X3/rotor_2_joint</jointName>
<forceConstant>8.54858e-06</forceConstant>
<momentConstant>0.016</momentConstant>
<direction>-1</direction>
</rotor>
<rotor>
<jointName>X3/rotor_3_joint</jointName>
<forceConstant>8.54858e-06</forceConstant>
<momentConstant>0.016</momentConstant>
<direction>-1</direction>
</rotor>
</rotorConfiguration>
</plugin>
<!-- Odometry publisher -->
<plugin
filename="gz-sim-odometry-publisher-system"
name="gz::sim::systems::OdometryPublisher">
<dimensions>3</dimensions>
</plugin>
</include>
<!-- ============================================================ -->
<!-- Sensor pod - attached to UAV via fixed joint -->
<!-- ============================================================ -->
<model name="sensor_pod">
<pose>0 0 0.2 0 0 0</pose>
<link name="pod_link">
<inertial>
<mass>0.05</mass>
<inertia>
<ixx>0.0001</ixx><iyy>0.0001</iyy><izz>0.0001</izz>
</inertia>
</inertial>
<!-- Front-facing camera -->
<sensor name="front_camera" type="camera">
<pose>0.15 0 0 0 0 0</pose>
<camera>
<horizontal_fov>1.39626</horizontal_fov>
<image>
<width>1280</width>
<height>720</height>
</image>
<clip>
<near>0.1</near>
<far>500</far>
</clip>
</camera>
<always_on>1</always_on>
<update_rate>30</update_rate>
<visualize>false</visualize>
<topic>X3/front_camera</topic>
</sensor>
<!-- Downward-facing camera -->
<sensor name="down_camera" type="camera">
<pose>0 0 -0.05 0 1.5708 0</pose>
<camera>
<horizontal_fov>1.39626</horizontal_fov>
<image>
<width>640</width>
<height>480</height>
</image>
<clip>
<near>0.1</near>
<far>500</far>
</clip>
</camera>
<always_on>1</always_on>
<update_rate>15</update_rate>
<visualize>false</visualize>
<topic>X3/down_camera</topic>
</sensor>
</link>
</model>
<!-- Attach sensor pod to X3 UAV body -->
<joint name="sensor_pod_joint" type="fixed">
<parent>x3_uav::X3/base_link</parent>
<child>sensor_pod::pod_link</child>
</joint>
<!-- ============================================================ -->
<!-- Tower overview camera -->
<!-- ============================================================ -->
<model name="tower_camera">
<static>true</static>
<pose>-15 -15 12 0 0.4 0.78</pose>
<link name="link">
<visual name="visual">
<geometry><box><size>0.15 0.15 0.15</size></box></geometry>
<material>
<ambient>0.2 0.2 0.2 1</ambient>
<diffuse>0.2 0.2 0.2 1</diffuse>
</material>
</visual>
<sensor name="tower_camera" type="camera">
<camera>
<horizontal_fov>1.2</horizontal_fov>
<image>
<width>1280</width>
<height>720</height>
</image>
<clip>
<near>0.5</near>
<far>1000</far>
</clip>
</camera>
<always_on>1</always_on>
<update_rate>30</update_rate>
<visualize>false</visualize>
<topic>tower_camera</topic>
</sensor>
</link>
</model>
<!-- Camera tower structure -->
<model name="tower_structure">
<static>true</static>
<pose>-15 -15 0 0 0 0</pose>
<link name="link">
<visual name="pole">
<pose>0 0 6 0 0 0</pose>
<geometry>
<cylinder><radius>0.08</radius><length>12</length></cylinder>
</geometry>
<material>
<ambient>0.5 0.5 0.5 1</ambient>
<diffuse>0.5 0.5 0.5 1</diffuse>
</material>
</visual>
</link>
</model>
<!-- ============================================================ -->
<!-- Ground objects from Gazebo Fuel -->
<!-- ============================================================ -->
<include>
<uri>https://fuel.gazebosim.org/1.0/OpenRobotics/models/Gas Station</uri>
<name>gas_station</name>
<pose>20 10 0 0 0 0.5</pose>
</include>
<include>
<uri>https://fuel.gazebosim.org/1.0/OpenRobotics/models/Hatchback blue</uri>
<name>car_1</name>
<pose>15 -5 0 0 0 1.2</pose>
</include>
<include>
<uri>https://fuel.gazebosim.org/1.0/OpenRobotics/models/SUV</uri>
<name>suv_1</name>
<pose>22 8 0 0 0 -0.3</pose>
</include>
<include>
<uri>https://fuel.gazebosim.org/1.0/OpenRobotics/models/Pickup</uri>
<name>pickup_1</name>
<pose>-10 15 0 0 0 2.0</pose>
</include>
<!-- Simple structures for visual interest -->
<model name="warehouse">
<static>true</static>
<pose>-20 20 0 0 0 0.3</pose>
<link name="link">
<visual name="walls">
<pose>0 0 3 0 0 0</pose>
<geometry><box><size>12 8 6</size></box></geometry>
<material>
<ambient>0.6 0.6 0.55 1</ambient>
<diffuse>0.6 0.6 0.55 1</diffuse>
</material>
</visual>
<visual name="roof">
<pose>0 0 6.1 0 0 0</pose>
<geometry><box><size>12.5 8.5 0.2</size></box></geometry>
<material>
<ambient>0.4 0.3 0.25 1</ambient>
<diffuse>0.4 0.3 0.25 1</diffuse>
</material>
</visual>
<collision name="collision">
<pose>0 0 3 0 0 0</pose>
<geometry><box><size>12 8 6</size></box></geometry>
</collision>
</link>
</model>
<model name="water_tower">
<static>true</static>
<pose>25 -20 0 0 0 0</pose>
<link name="link">
<visual name="legs">
<pose>0 0 5 0 0 0</pose>
<geometry><cylinder><radius>0.15</radius><length>10</length></cylinder></geometry>
<material>
<ambient>0.5 0.5 0.5 1</ambient>
<diffuse>0.5 0.5 0.5 1</diffuse>
</material>
</visual>
<visual name="tank">
<pose>0 0 11 0 0 0</pose>
<geometry><cylinder><radius>2.0</radius><length>3</length></cylinder></geometry>
<material>
<ambient>0.3 0.4 0.6 1</ambient>
<diffuse>0.3 0.4 0.6 1</diffuse>
</material>
</visual>
<visual name="cap">
<pose>0 0 12.6 0 0 0</pose>
<geometry><sphere><radius>2.1</radius></sphere></geometry>
<material>
<ambient>0.3 0.4 0.6 1</ambient>
<diffuse>0.3 0.4 0.6 1</diffuse>
</material>
</visual>
</link>
</model>
<!-- Crates near landing pad -->
<model name="crate_1">
<static>true</static>
<pose>3 2 0.4 0 0 0.2</pose>
<link name="link">
<visual name="visual">
<geometry><box><size>0.8 0.8 0.8</size></box></geometry>
<material>
<ambient>0.6 0.45 0.25 1</ambient>
<diffuse>0.6 0.45 0.25 1</diffuse>
</material>
</visual>
</link>
</model>
<model name="crate_2">
<static>true</static>
<pose>3.5 2.8 0.3 0 0 -0.4</pose>
<link name="link">
<visual name="visual">
<geometry><box><size>0.6 0.6 0.6</size></box></geometry>
<material>
<ambient>0.55 0.4 0.2 1</ambient>
<diffuse>0.55 0.4 0.2 1</diffuse>
</material>
</visual>
</link>
</model>
<model name="crate_3">
<static>true</static>
<pose>3.2 2.3 1.0 0 0 0.6</pose>
<link name="link">
<visual name="visual">
<geometry><box><size>0.5 0.5 0.5</size></box></geometry>
<material>
<ambient>0.5 0.35 0.15 1</ambient>
<diffuse>0.5 0.35 0.15 1</diffuse>
</material>
</visual>
</link>
</model>
</world>
</sdf>