@@ -271,6 +271,7 @@ void JointFeatures::SetJointVelocity(
271
271
return ;
272
272
273
273
const auto *model = this ->ReferenceInterface <ModelInfo>(joint->model );
274
+
274
275
model->body ->getJointVelMultiDof (identifier->indexInBtModel )[_dof] =
275
276
static_cast <btScalar>(_value);
276
277
model->body ->wakeUp ();
@@ -287,11 +288,11 @@ void JointFeatures::SetJointAcceleration(
287
288
void JointFeatures::SetJointForce (
288
289
const Identity &_id, const std::size_t _dof, const double _value)
289
290
{
290
- const auto *joint = this ->ReferenceInterface <JointInfo>(_id);
291
+ auto *joint = this ->ReferenceInterface <JointInfo>(_id);
291
292
292
293
if (!std::isfinite (_value))
293
294
{
294
- gzerr << " Invalid joint velocity value [" << _value
295
+ gzerr << " Invalid joint force value [" << _value
295
296
<< " ] commanded on joint [" << joint->name << " DOF " << _dof
296
297
<< " ]. The command will be ignored\n " ;
297
298
return ;
@@ -301,7 +302,15 @@ void JointFeatures::SetJointForce(
301
302
if (!identifier)
302
303
return ;
303
304
304
- const auto *model = this ->ReferenceInterface <ModelInfo>(joint->model );
305
+ auto *model = this ->ReferenceInterface <ModelInfo>(joint->model );
306
+ auto *world = this ->ReferenceInterface <WorldInfo>(model->world );
307
+
308
+ // Disable velocity control by removing joint motor constraint
309
+ if (joint->motor )
310
+ {
311
+ world->world ->removeMultiBodyConstraint (joint->motor .get ());
312
+ joint->motor .reset ();
313
+ }
305
314
306
315
// clamp the values
307
316
double force = std::clamp (_value,
0 commit comments