Skip to content

Commit 568410a

Browse files
authored
Update sdf plugins to use actuator_number. (#1976)
Signed-off-by: Benjamin Perseghetti <[email protected]>
1 parent 13aedfd commit 568410a

9 files changed

+53
-42
lines changed

examples/worlds/multicopter_velocity_control.sdf

+10-10
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ You can use the velocity controller and command linear velocity and yaw angular
117117
<motorConstant>8.54858e-06</motorConstant>
118118
<momentConstant>0.016</momentConstant>
119119
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
120-
<motorNumber>0</motorNumber>
120+
<actuator_number>0</actuator_number>
121121
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
122122
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
123123
<motorSpeedPubTopic>motor_speed/0</motorSpeedPubTopic>
@@ -137,7 +137,7 @@ You can use the velocity controller and command linear velocity and yaw angular
137137
<motorConstant>8.54858e-06</motorConstant>
138138
<momentConstant>0.016</momentConstant>
139139
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
140-
<motorNumber>1</motorNumber>
140+
<actuator_number>1</actuator_number>
141141
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
142142
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
143143
<motorSpeedPubTopic>motor_speed/1</motorSpeedPubTopic>
@@ -157,7 +157,7 @@ You can use the velocity controller and command linear velocity and yaw angular
157157
<motorConstant>8.54858e-06</motorConstant>
158158
<momentConstant>0.016</momentConstant>
159159
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
160-
<motorNumber>2</motorNumber>
160+
<actuator_number>2</actuator_number>
161161
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
162162
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
163163
<motorSpeedPubTopic>motor_speed/2</motorSpeedPubTopic>
@@ -177,7 +177,7 @@ You can use the velocity controller and command linear velocity and yaw angular
177177
<motorConstant>8.54858e-06</motorConstant>
178178
<momentConstant>0.016</momentConstant>
179179
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
180-
<motorNumber>3</motorNumber>
180+
<actuator_number>3</actuator_number>
181181
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
182182
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
183183
<motorSpeedPubTopic>motor_speed/3</motorSpeedPubTopic>
@@ -247,7 +247,7 @@ You can use the velocity controller and command linear velocity and yaw angular
247247
<motorConstant>1.269e-05</motorConstant>
248248
<momentConstant>0.016754</momentConstant>
249249
<commandSubTopic>command/motor_speed</commandSubTopic>
250-
<motorNumber>0</motorNumber>
250+
<actuator_number>0</actuator_number>
251251
<rotorDragCoefficient>2.0673e-04</rotorDragCoefficient>
252252
<rotorDragCoefficient>0</rotorDragCoefficient>
253253
<rollingMomentCoefficient>0</rollingMomentCoefficient>
@@ -267,7 +267,7 @@ You can use the velocity controller and command linear velocity and yaw angular
267267
<motorConstant>1.269e-05</motorConstant>
268268
<momentConstant>0.016754</momentConstant>
269269
<commandSubTopic>command/motor_speed</commandSubTopic>
270-
<motorNumber>1</motorNumber>
270+
<actuator_number>1</actuator_number>
271271
<rotorDragCoefficient>2.0673e-04</rotorDragCoefficient>
272272
<rotorDragCoefficient>0</rotorDragCoefficient>
273273
<rollingMomentCoefficient>0</rollingMomentCoefficient>
@@ -287,7 +287,7 @@ You can use the velocity controller and command linear velocity and yaw angular
287287
<motorConstant>1.269e-05</motorConstant>
288288
<momentConstant>0.016754</momentConstant>
289289
<commandSubTopic>command/motor_speed</commandSubTopic>
290-
<motorNumber>2</motorNumber>
290+
<actuator_number>2</actuator_number>
291291
<rotorDragCoefficient>2.0673e-04</rotorDragCoefficient>
292292
<rotorDragCoefficient>0</rotorDragCoefficient>
293293
<rollingMomentCoefficient>0</rollingMomentCoefficient>
@@ -307,7 +307,7 @@ You can use the velocity controller and command linear velocity and yaw angular
307307
<motorConstant>1.269e-05</motorConstant>
308308
<momentConstant>0.016754</momentConstant>
309309
<commandSubTopic>command/motor_speed</commandSubTopic>
310-
<motorNumber>3</motorNumber>
310+
<actuator_number>3</actuator_number>
311311
<rotorDragCoefficient>2.0673e-04</rotorDragCoefficient>
312312
<rotorDragCoefficient>0</rotorDragCoefficient>
313313
<rollingMomentCoefficient>0</rollingMomentCoefficient>
@@ -327,7 +327,7 @@ You can use the velocity controller and command linear velocity and yaw angular
327327
<motorConstant>1.269e-05</motorConstant>
328328
<momentConstant>0.016754</momentConstant>
329329
<commandSubTopic>command/motor_speed</commandSubTopic>
330-
<motorNumber>4</motorNumber>
330+
<actuator_number>4</actuator_number>
331331
<rotorDragCoefficient>2.0673e-04</rotorDragCoefficient>
332332
<rotorDragCoefficient>0</rotorDragCoefficient>
333333
<rollingMomentCoefficient>0</rollingMomentCoefficient>
@@ -347,7 +347,7 @@ You can use the velocity controller and command linear velocity and yaw angular
347347
<motorConstant>1.269e-05</motorConstant>
348348
<momentConstant>0.016754</momentConstant>
349349
<commandSubTopic>command/motor_speed</commandSubTopic>
350-
<motorNumber>5</motorNumber>
350+
<actuator_number>5</actuator_number>
351351
<rotorDragCoefficient>2.0673e-04</rotorDragCoefficient>
352352
<rotorDragCoefficient>0</rotorDragCoefficient>
353353
<rollingMomentCoefficient>0</rollingMomentCoefficient>

examples/worlds/quadcopter.sdf

+4-4
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
<motorConstant>8.54858e-06</motorConstant>
9494
<momentConstant>0.016</momentConstant>
9595
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
96-
<motorNumber>0</motorNumber>
96+
<actuator_number>0</actuator_number>
9797
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
9898
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
9999
<motorSpeedPubTopic>motor_speed/0</motorSpeedPubTopic>
@@ -113,7 +113,7 @@
113113
<motorConstant>8.54858e-06</motorConstant>
114114
<momentConstant>0.016</momentConstant>
115115
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
116-
<motorNumber>1</motorNumber>
116+
<actuator_number>1</actuator_number>
117117
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
118118
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
119119
<motorSpeedPubTopic>motor_speed/1</motorSpeedPubTopic>
@@ -133,7 +133,7 @@
133133
<motorConstant>8.54858e-06</motorConstant>
134134
<momentConstant>0.016</momentConstant>
135135
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
136-
<motorNumber>2</motorNumber>
136+
<actuator_number>2</actuator_number>
137137
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
138138
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
139139
<motorSpeedPubTopic>motor_speed/2</motorSpeedPubTopic>
@@ -153,7 +153,7 @@
153153
<motorConstant>8.54858e-06</motorConstant>
154154
<momentConstant>0.016</momentConstant>
155155
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
156-
<motorNumber>3</motorNumber>
156+
<actuator_number>3</actuator_number>
157157
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
158158
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
159159
<motorSpeedPubTopic>motor_speed/3</motorSpeedPubTopic>

src/systems/ackermann_steering/AckermannSteering.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,10 @@ void AckermannSteering::Configure(const Entity &_entity,
259259
if (_sdf->HasElement("use_actuator_msg") &&
260260
_sdf->Get<bool>("use_actuator_msg"))
261261
{
262-
if (_sdf->HasElement("actuatorNumber"))
262+
if (_sdf->HasElement("actuator_number"))
263263
{
264264
this->dataPtr->actuatorNumber =
265-
_sdf->Get<int>("actuatorNumber");
265+
_sdf->Get<int>("actuator_number");
266266
this->dataPtr->useActuatorMsg = true;
267267
if (!this->dataPtr->steeringOnly)
268268
{
@@ -271,7 +271,7 @@ void AckermannSteering::Configure(const Entity &_entity,
271271
}
272272
else
273273
{
274-
gzerr << "Please specify an actuatorNumber" <<
274+
gzerr << "Please specify an actuator_number" <<
275275
"to use Actuator position message control." << std::endl;
276276
}
277277
}

src/systems/ackermann_steering/AckermannSteering.hh

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ namespace systems
4545
/// `<use_actuator_msg>` is True, uses defaults topic name "/actuators".
4646
///
4747
/// `<use_actuator_msg>` True to enable the use of actutor message
48-
/// for steering angle command. Relies on `<actuatorNumber>` for the
48+
/// for steering angle command. Relies on `<actuator_number>` for the
4949
/// index of the position actuator and defaults to topic "/actuators".
5050
///
51-
/// `<actuatorNumber>` used with `<use_actuator_commands>` to set
51+
/// `<actuator_number>` used with `<use_actuator_commands>` to set
5252
/// the index of the steering angle position actuator.
5353
///
5454
/// `<steer_p_gain>`: Float used to control the steering angle P gain.

src/systems/multicopter_motor_model/MulticopterMotorModel.cc

+21-10
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ class gz::sim::systems::MulticopterMotorModelPrivate
157157
/// \brief Sampling time (from motor_model.hpp).
158158
public: double samplingTime = 0.01;
159159

160-
/// \brief Index of motor on multirotor_base.
161-
public: int motorNumber = 0;
160+
/// \brief Index of motor in Actuators msg on multirotor_base.
161+
public: int actuatorNumber = 0;
162162

163163
/// \brief Turning direction of the motor.
164164
public: int turningDirection = turning_direction::kCw;
@@ -283,11 +283,22 @@ void MulticopterMotorModel::Configure(const Entity &_entity,
283283
return;
284284
}
285285

286-
if (sdfClone->HasElement("motorNumber"))
287-
this->dataPtr->motorNumber =
286+
if (sdfClone->HasElement("actuator_number"))
287+
{
288+
this->dataPtr->actuatorNumber =
289+
sdfClone->GetElement("actuator_number")->Get<int>();
290+
}
291+
else if (sdfClone->HasElement("motorNumber"))
292+
{
293+
this->dataPtr->actuatorNumber =
288294
sdfClone->GetElement("motorNumber")->Get<int>();
295+
gzwarn << "<motorNumber> is depricated, "
296+
<< "please use <actuator_number>.\n";
297+
}
289298
else
290-
gzerr << "Please specify a motorNumber.\n";
299+
{
300+
gzerr << "Please specify a actuator_number.\n";
301+
}
291302

292303
if (sdfClone->HasElement("turningDirection"))
293304
{
@@ -512,9 +523,9 @@ void MulticopterMotorModelPrivate::UpdateForcesAndMoments(
512523

513524
if (msg.has_value())
514525
{
515-
if (this->motorNumber > msg->velocity_size() - 1)
526+
if (this->actuatorNumber > msg->velocity_size() - 1)
516527
{
517-
gzerr << "You tried to access index " << this->motorNumber
528+
gzerr << "You tried to access index " << this->actuatorNumber
518529
<< " of the Actuator velocity array which is of size "
519530
<< msg->velocity_size() << std::endl;
520531
return;
@@ -523,13 +534,13 @@ void MulticopterMotorModelPrivate::UpdateForcesAndMoments(
523534
if (this->motorType == MotorType::kVelocity)
524535
{
525536
this->refMotorInput = std::min(
526-
static_cast<double>(msg->velocity(this->motorNumber)),
537+
static_cast<double>(msg->velocity(this->actuatorNumber)),
527538
static_cast<double>(this->maxRotVelocity));
528539
}
529540
// else if (this->motorType == MotorType::kPosition)
530541
else // if (this->motorType == MotorType::kForce) {
531542
{
532-
this->refMotorInput = msg->velocity(this->motorNumber);
543+
this->refMotorInput = msg->velocity(this->actuatorNumber);
533544
}
534545
}
535546

@@ -554,7 +565,7 @@ void MulticopterMotorModelPrivate::UpdateForcesAndMoments(
554565
double motorRotVel = jointVelocity->Data()[0];
555566
if (motorRotVel / (2 * GZ_PI) > 1 / (2 * this->samplingTime))
556567
{
557-
gzerr << "Aliasing on motor [" << this->motorNumber
568+
gzerr << "Aliasing on motor [" << this->actuatorNumber
558569
<< "] might occur. Consider making smaller simulation time "
559570
"steps or raising the rotorVelocitySlowdownSim param.\n";
560571
}

test/worlds/ackermann_steering_only_actuators.sdf

+1-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@
365365
<right_steering_joint>front_right_wheel_steering_joint</right_steering_joint>
366366
<steering_only>true</steering_only>
367367
<use_actuator_msg>true</use_actuator_msg>
368-
<actuatorNumber>0</actuatorNumber>
368+
<actuator_number>0</actuator_number>
369369
<steer_p_gain>10.0</steer_p_gain>
370370
<steering_limit>0.5</steering_limit>
371371
<wheel_base>1.0</wheel_base>

test/worlds/odometry_publisher_3d.sdf

+4-4
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
<motorConstant>8.54858e-06</motorConstant>
274274
<momentConstant>0.016</momentConstant>
275275
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
276-
<motorNumber>0</motorNumber>
276+
<actuator_number>0</actuator_number>
277277
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
278278
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
279279
<motorSpeedPubTopic>motor_speed/0</motorSpeedPubTopic>
@@ -293,7 +293,7 @@
293293
<motorConstant>8.54858e-06</motorConstant>
294294
<momentConstant>0.016</momentConstant>
295295
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
296-
<motorNumber>1</motorNumber>
296+
<actuator_number>1</actuator_number>
297297
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
298298
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
299299
<motorSpeedPubTopic>motor_speed/1</motorSpeedPubTopic>
@@ -313,7 +313,7 @@
313313
<motorConstant>8.54858e-06</motorConstant>
314314
<momentConstant>0.016</momentConstant>
315315
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
316-
<motorNumber>2</motorNumber>
316+
<actuator_number>2</actuator_number>
317317
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
318318
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
319319
<motorSpeedPubTopic>motor_speed/2</motorSpeedPubTopic>
@@ -333,7 +333,7 @@
333333
<motorConstant>8.54858e-06</motorConstant>
334334
<momentConstant>0.016</momentConstant>
335335
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
336-
<motorNumber>3</motorNumber>
336+
<actuator_number>3</actuator_number>
337337
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
338338
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
339339
<motorSpeedPubTopic>motor_speed/3</motorSpeedPubTopic>

test/worlds/quadcopter.sdf

+4-4
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
<motorConstant>8.54858e-06</motorConstant>
263263
<momentConstant>0.016</momentConstant>
264264
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
265-
<motorNumber>0</motorNumber>
265+
<actuator_number>0</actuator_number>
266266
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
267267
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
268268
<motorSpeedPubTopic>motor_speed/0</motorSpeedPubTopic>
@@ -282,7 +282,7 @@
282282
<motorConstant>8.54858e-06</motorConstant>
283283
<momentConstant>0.016</momentConstant>
284284
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
285-
<motorNumber>1</motorNumber>
285+
<actuator_number>1</actuator_number>
286286
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
287287
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
288288
<motorSpeedPubTopic>motor_speed/1</motorSpeedPubTopic>
@@ -302,7 +302,7 @@
302302
<motorConstant>8.54858e-06</motorConstant>
303303
<momentConstant>0.016</momentConstant>
304304
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
305-
<motorNumber>2</motorNumber>
305+
<actuator_number>2</actuator_number>
306306
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
307307
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
308308
<motorSpeedPubTopic>motor_speed/2</motorSpeedPubTopic>
@@ -322,7 +322,7 @@
322322
<motorConstant>8.54858e-06</motorConstant>
323323
<momentConstant>0.016</momentConstant>
324324
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
325-
<motorNumber>3</motorNumber>
325+
<actuator_number>3</actuator_number>
326326
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
327327
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
328328
<motorSpeedPubTopic>motor_speed/3</motorSpeedPubTopic>

test/worlds/quadcopter_velocity_control.sdf

+4-4
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
<motorConstant>8.54858e-06</motorConstant>
263263
<momentConstant>0.016</momentConstant>
264264
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
265-
<motorNumber>0</motorNumber>
265+
<actuator_number>0</actuator_number>
266266
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
267267
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
268268
<motorSpeedPubTopic>motor_speed/0</motorSpeedPubTopic>
@@ -282,7 +282,7 @@
282282
<motorConstant>8.54858e-06</motorConstant>
283283
<momentConstant>0.016</momentConstant>
284284
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
285-
<motorNumber>1</motorNumber>
285+
<actuator_number>1</actuator_number>
286286
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
287287
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
288288
<motorSpeedPubTopic>motor_speed/1</motorSpeedPubTopic>
@@ -302,7 +302,7 @@
302302
<motorConstant>8.54858e-06</motorConstant>
303303
<momentConstant>0.016</momentConstant>
304304
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
305-
<motorNumber>2</motorNumber>
305+
<actuator_number>2</actuator_number>
306306
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
307307
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
308308
<motorSpeedPubTopic>motor_speed/2</motorSpeedPubTopic>
@@ -322,7 +322,7 @@
322322
<motorConstant>8.54858e-06</motorConstant>
323323
<momentConstant>0.016</momentConstant>
324324
<commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
325-
<motorNumber>3</motorNumber>
325+
<actuator_number>3</actuator_number>
326326
<rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
327327
<rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
328328
<motorSpeedPubTopic>motor_speed/3</motorSpeedPubTopic>

0 commit comments

Comments
 (0)