Skip to content

Commit d0d0bc5

Browse files
committed
MotorPlugin: add motor example
Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
1 parent 7f94f28 commit d0d0bc5

1 file changed

Lines changed: 378 additions & 0 deletions

File tree

worlds/motor.sdf

Lines changed: 378 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,378 @@
1+
<?xml version="1.0" ?>
2+
<sdf version="1.10">
3+
<world name="motor">
4+
<physics name="1ms" type="ignore">
5+
<max_step_size>0.001</max_step_size>
6+
<real_time_factor>1.0</real_time_factor>
7+
</physics>
8+
9+
<plugin filename="gz-sim-physics-system"
10+
name="gz::sim::systems::Physics">
11+
</plugin>
12+
<plugin
13+
filename="gz-sim-sensors-system"
14+
name="gz::sim::systems::Sensors">
15+
<render_engine>ogre2</render_engine>
16+
</plugin>
17+
<plugin filename="gz-sim-user-commands-system"
18+
name="gz::sim::systems::UserCommands">
19+
</plugin>
20+
<plugin filename="gz-sim-scene-broadcaster-system"
21+
name="gz::sim::systems::SceneBroadcaster">
22+
</plugin>
23+
<plugin filename="gz-sim-imu-system"
24+
name="gz::sim::systems::Imu">
25+
</plugin>
26+
<plugin filename="gz-sim-navsat-system"
27+
name="gz::sim::systems::NavSat">
28+
</plugin>
29+
30+
<scene>
31+
<ambient>1.0 1.0 1.0</ambient>
32+
<background>0.8 0.8 0.8</background>
33+
<sky></sky>
34+
</scene>
35+
36+
<spherical_coordinates>
37+
<latitude_deg>-35.363262</latitude_deg>
38+
<longitude_deg>149.165237</longitude_deg>
39+
<elevation>584</elevation>
40+
<heading_deg>0</heading_deg>
41+
<surface_model>EARTH_WGS84</surface_model>
42+
</spherical_coordinates>
43+
44+
<light type="directional" name="sun">
45+
<cast_shadows>true</cast_shadows>
46+
<pose>0 0 10 0 0 0</pose>
47+
<diffuse>0.8 0.8 0.8 1</diffuse>
48+
<specular>0.8 0.8 0.8 1</specular>
49+
<attenuation>
50+
<range>1000</range>
51+
<constant>0.9</constant>
52+
<linear>0.01</linear>
53+
<quadratic>0.001</quadratic>
54+
</attenuation>
55+
<direction>-0.5 0.1 -0.9</direction>
56+
</light>
57+
58+
<model name="ground_plane">
59+
<static>true</static>
60+
<link name="link">
61+
<collision name="collision">
62+
<geometry>
63+
<plane>
64+
<normal>0 0 1</normal>
65+
<size>100 100</size>
66+
</plane>
67+
</geometry>
68+
<surface>
69+
<friction>
70+
<ode>
71+
<mu>1000</mu>
72+
<mu2>1000</mu2>
73+
</ode>
74+
</friction>
75+
</surface>
76+
</collision>
77+
<visual name="visual">
78+
<geometry>
79+
<plane>
80+
<normal>0 0 1</normal>
81+
<size>100 100</size>
82+
</plane>
83+
</geometry>
84+
<material>
85+
<ambient>0.8 0.8 0.8</ambient>
86+
<diffuse>0.8 0.8 0.8</diffuse>
87+
<specular>0.8 0.8 0.8</specular>
88+
</material>
89+
</visual>
90+
</link>
91+
</model>
92+
93+
<model name="motor">
94+
<pose degrees="true">0 0 0.005 0 0 0</pose>
95+
<link name="base_link">
96+
<inertial>
97+
<mass>10.0</mass>
98+
<inertia>
99+
<ixx>0.002166667</ixx>
100+
<ixy>0</ixy>
101+
<ixz>0</ixz>
102+
<iyy>0.002166667</iyy>
103+
<iyz>0</iyz>
104+
<izz>0.004166667</izz>
105+
</inertia>
106+
</inertial>
107+
<collision name="collision">
108+
<geometry>
109+
<box>
110+
<size>0.05 0.05 0.01</size>
111+
</box>
112+
</geometry>
113+
<surface>
114+
<friction>
115+
<ode>
116+
<mu>1000</mu>
117+
<mu2>1000</mu2>
118+
</ode>
119+
</friction>
120+
</surface>
121+
</collision>
122+
<visual name="visual">
123+
<geometry>
124+
<box>
125+
<size>0.05 0.05 0.01</size>
126+
</box>
127+
</geometry>
128+
<material>
129+
<ambient>0.2 0.2 0.2</ambient>
130+
<diffuse>0.2 0.2 0.2</diffuse>
131+
<specular>0.01 0.01 0.01</specular>
132+
</material>
133+
</visual>
134+
</link>
135+
136+
<link name="motor_link">
137+
<pose relative_to="base_link" degrees="true">0 0 0.0205 0 0 0</pose>
138+
<inertial>
139+
<mass>0.064</mass>
140+
<inertia>
141+
<ixx>8.19449E-06</ixx>
142+
<ixy>0</ixy>
143+
<ixz>0</ixz>
144+
<iyy>8.19449E-06</iyy>
145+
<iyz>0</iyz>
146+
<izz>6.13832E-06</izz>
147+
</inertia>
148+
</inertial>
149+
<collision name="collision">
150+
<geometry>
151+
<cylinder>
152+
<length>0.031</length>
153+
<radius>0.01385</radius>
154+
</cylinder>
155+
</geometry>
156+
</collision>
157+
<visual name="visual">
158+
<geometry>
159+
<cylinder>
160+
<length>0.031</length>
161+
<radius>0.01385</radius>
162+
</cylinder>
163+
</geometry>
164+
<material>
165+
<ambient>0 0 1</ambient>
166+
<diffuse>0 0 1</diffuse>
167+
<specular>0.01 0.01 0.01</specular>
168+
</material>
169+
</visual>
170+
</link>
171+
<joint name="motor_joint" type="revolute">
172+
<pose degrees="true">0 0 0 0 0 0</pose>
173+
<parent>base_link</parent>
174+
<child>motor_link</child>
175+
<axis>
176+
<xyz>0 0 1</xyz>
177+
<limit>
178+
<lower>-1.0e16</lower>
179+
<upper>1.0e16</upper>
180+
</limit>
181+
<dynamics>
182+
<damping>0.001</damping>
183+
</dynamics>
184+
</axis>
185+
</joint>
186+
187+
<link name="blade_1_link">
188+
<pose relative_to="motor_link" degrees="true">0.0635 0 0.018 0 0 0</pose>
189+
<inertial>
190+
<mass>0.0065</mass>
191+
<inertia>
192+
<ixx>2.30208E-07</ixx>
193+
<ixy>0</ixy>
194+
<ixz>0</ixz>
195+
<iyy>8.75008E-06</iyy>
196+
<iyz>0</iyz>
197+
<izz>8.95321E-06</izz>
198+
</inertia>
199+
</inertial>
200+
<collision name="collision">
201+
<geometry>
202+
<box>
203+
<size>0.127 0.02 0.005</size>
204+
</box>
205+
</geometry>
206+
</collision>
207+
<visual name="visual">
208+
<geometry>
209+
<box>
210+
<size>0.127 0.02 0.005</size>
211+
</box>
212+
</geometry>
213+
<material>
214+
<ambient>0.01 0.01 0.01</ambient>
215+
<diffuse>0.01 0.01 0.01</diffuse>
216+
<specular>0.01 0.01 0.01</specular>
217+
</material>
218+
</visual>
219+
</link>
220+
<joint name="blade_1_joint" type="revolute">
221+
<pose degrees="true">0 0 0 0 0 0</pose>
222+
<parent>motor_link</parent>
223+
<child>blade_1_link</child>
224+
<axis>
225+
<xyz>0 0 1</xyz>
226+
<limit>
227+
<lower>0</lower>
228+
<upper>0</upper>
229+
</limit>
230+
<dynamics>
231+
<damping>0.1</damping>
232+
</dynamics>
233+
</axis>
234+
</joint>
235+
236+
<link name="blade_2_link">
237+
<pose relative_to="motor_link" degrees="true">-0.0635 0 0.018 0 0 180</pose>
238+
<inertial>
239+
<mass>0.0065</mass>
240+
<inertia>
241+
<ixx>2.30208E-07</ixx>
242+
<ixy>0</ixy>
243+
<ixz>0</ixz>
244+
<iyy>8.75008E-06</iyy>
245+
<iyz>0</iyz>
246+
<izz>8.95321E-06</izz>
247+
</inertia>
248+
</inertial>
249+
<collision name="collision">
250+
<geometry>
251+
<box>
252+
<size>0.127 0.02 0.005</size>
253+
</box>
254+
</geometry>
255+
</collision>
256+
<visual name="visual">
257+
<geometry>
258+
<box>
259+
<size>0.127 0.02 0.005</size>
260+
</box>
261+
</geometry>
262+
<material>
263+
<ambient>0.01 0.01 0.01</ambient>
264+
<diffuse>0.01 0.01 0.01</diffuse>
265+
<specular>0.01 0.01 0.01</specular>
266+
</material>
267+
</visual>
268+
</link>
269+
<joint name="blade_2_joint" type="revolute">
270+
<pose degrees="true">0 0 0 0 0 0</pose>
271+
<parent>motor_link</parent>
272+
<child>blade_2_link</child>
273+
<axis>
274+
<xyz>0 0 1</xyz>
275+
<limit>
276+
<lower>0</lower>
277+
<upper>0</upper>
278+
</limit>
279+
<dynamics>
280+
<damping>0.1</damping>
281+
</dynamics>
282+
</axis>
283+
</joint>
284+
285+
<plugin name="gz::sim::systems::JointStatePublisher"
286+
filename="gz-sim-joint-state-publisher-system">
287+
</plugin>
288+
289+
<!-- <plugin name="gz::sim::systems::JointController"
290+
filename="gz-sim-joint-controller-system">
291+
<joint_name>motor_joint</joint_name>
292+
<initial_velocity>0.0</initial_velocity>
293+
<use_force_commands>1</use_force_commands>
294+
<use_actuator_msg>0</use_actuator_msg>
295+
<disable_braking>0</disable_braking>
296+
<topic>/motor_joint/cmd_vel</topic>
297+
<p_gain>0.20</p_gain>
298+
<i_gain>0</i_gain>
299+
<d_gain>0</d_gain>
300+
<i_max>0</i_max>
301+
<i_min>0</i_min>
302+
<cmd_max>2.5</cmd_max>
303+
<cmd_min>-2.5</cmd_min>
304+
</plugin> -->
305+
306+
<!--
307+
T-Motor 2216 920KV as used on a Hexsoon 450
308+
KV 920 RPM/V = KV 96 rad/s/V
309+
-->
310+
<plugin name="MotorPlugin" filename="MotorPlugin">
311+
<joint_name>motor_joint</joint_name>
312+
<use_actuator_msg>0</use_actuator_msg>
313+
<disable_braking>0</disable_braking>
314+
<topic>/motor_joint/cmd_vel</topic>
315+
<p_gain>0.01</p_gain>
316+
<i_gain>0.01</i_gain>
317+
<d_gain>0</d_gain>
318+
<i_max>1</i_max>
319+
<i_min>-1</i_min>
320+
<cmd_max>5.0</cmd_max>
321+
<cmd_min>-5.0</cmd_min>
322+
<voltage_bat>16.0</voltage_bat>
323+
<speed_constant>96</speed_constant>
324+
<torque_constant>53</torque_constant>
325+
<resistance>0.115</resistance>
326+
<no_load_current>0.8</no_load_current>
327+
</plugin>
328+
329+
<!-- lift-drag for ccw prop -->
330+
<plugin filename="gz-sim-lift-drag-system"
331+
name="gz::sim::systems::LiftDrag">
332+
<a0>0.3</a0>
333+
<alpha_stall>1.4</alpha_stall>
334+
<cla>4.2500</cla>
335+
<cda>0.10</cda>
336+
<cma>0.0</cma>
337+
<cla_stall>-0.025</cla_stall>
338+
<cda_stall>0.0</cda_stall>
339+
<cma_stall>0.0</cma_stall>
340+
<area>0.0013</area>
341+
<air_density>1.2041</air_density>
342+
<cp>0 0 0</cp>
343+
<forward>0 1 0</forward>
344+
<upward>0 0 1</upward>
345+
<link_name>blade_1_link</link_name>
346+
<visualize_forces>
347+
<visualize>1</visualize>
348+
<update_rate>1000</update_rate>
349+
<!-- <topic>/model/motor/link/blade_1_link/forces/lift_drag</topic> -->
350+
</visualize_forces>
351+
</plugin>
352+
<plugin filename="gz-sim-lift-drag-system"
353+
name="gz::sim::systems::LiftDrag">
354+
<a0>0.3</a0>
355+
<alpha_stall>1.4</alpha_stall>
356+
<cla>4.2500</cla>
357+
<cda>0.10</cda>
358+
<cma>0.0</cma>
359+
<cla_stall>-0.025</cla_stall>
360+
<cda_stall>0.0</cda_stall>
361+
<cma_stall>0.0</cma_stall>
362+
<area>0.0013</area>
363+
<air_density>1.2041</air_density>
364+
<cp>0 0 0</cp>
365+
<forward>0 1 0</forward>
366+
<upward>0 0 1</upward>
367+
<link_name>blade_2_link</link_name>
368+
<visualize_forces>
369+
<visualize>1</visualize>
370+
<update_rate>1000</update_rate>
371+
<!-- <topic>/model/motor/link/blade_2_link/forces/lift_drag</topic> -->
372+
</visualize_forces>
373+
</plugin>
374+
375+
</model>
376+
377+
</world>
378+
</sdf>

0 commit comments

Comments
 (0)