Skip to content

Commit d04197f

Browse files
committed
Fix Brakes added to the second axis of a Hinge2Joint being applied to the non-transformed axis.
1 parent ac8a683 commit d04197f

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

docs/reference/changelog-r2024.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ Released on December **th, 2023.
1414
- Fixed length of arrays returned by `getPose()` in Java ([#6556](https://github.com/cyberbotics/webots/pull/6556)).
1515
- Fixed length of arrays returned by `CameraRecognitionObject.getColors()` in Java ([#6564](https://github.com/cyberbotics/webots/pull/6564)).
1616
- Fixed handling of device objects with the same name in the controller API ([#6579](https://github.com/cyberbotics/webots/pull/6579)).
17+
- Fixed `Brake`s added to the second axis of a `Hinge2Joint` being applied to the non-transformed axis ([#6584](https://github.com/cyberbotics/webots/pull/6584)).

src/webots/nodes/WbHinge2Joint.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,11 @@ void WbHinge2Joint::applyToOdeSpringAndDampingConstants(dBodyID body, dBodyID pa
295295
dJointSetAMotorNumAxes(mSpringAndDamperMotor, numberOfAxes);
296296
dJointSetAMotorMode(mSpringAndDamperMotor, dAMotorUser);
297297

298+
applyToOdeAxis();
299+
298300
// Axis dependent settings
299-
const WbMatrix4 &m4 = upperPose()->matrix();
300301
if (mSpringAndDampingConstantsAxis1On) {
301302
const double clamped = WbMathsUtilities::normalizeAngle(mOdePositionOffset);
302-
const WbVector3 &a1 = m4.sub3x3MatrixDot(axis());
303-
dJointSetAMotorAxis(mSpringAndDamperMotor, 0, 1, a1.x(), a1.y(), a1.z());
304303
dJointSetAMotorAngle(mSpringAndDamperMotor, 0, 0.0);
305304
dJointSetAMotorParam(mSpringAndDamperMotor, dParamLoStop, clamped);
306305
dJointSetAMotorParam(mSpringAndDamperMotor, dParamHiStop, clamped);
@@ -310,16 +309,13 @@ void WbHinge2Joint::applyToOdeSpringAndDampingConstants(dBodyID body, dBodyID pa
310309

311310
if (mSpringAndDampingConstantsAxis2On) {
312311
const double clamped2 = WbMathsUtilities::normalizeAngle(mOdePositionOffset2);
313-
const WbVector3 &a2 = m4.sub3x3MatrixDot(axis2());
314312
if (bothAxes) { // axes 0 and 1 of the AMotorAngle are enabled
315-
dJointSetAMotorAxis(mSpringAndDamperMotor, 1, 1, a2.x(), a2.y(), a2.z());
316313
dJointSetAMotorAngle(mSpringAndDamperMotor, 1, 0.0);
317314
dJointSetAMotorParam(mSpringAndDamperMotor, dParamLoStop2, clamped2);
318315
dJointSetAMotorParam(mSpringAndDamperMotor, dParamHiStop2, clamped2);
319316
dJointSetAMotorParam(mSpringAndDamperMotor, dParamStopCFM2, cfm2);
320317
dJointSetAMotorParam(mSpringAndDamperMotor, dParamStopERP2, erp2);
321318
} else { // only axis 0 of the AMotorAngle is enabled
322-
dJointSetAMotorAxis(mSpringAndDamperMotor, 0, 1, a2.x(), a2.y(), a2.z());
323319
dJointSetAMotorAngle(mSpringAndDamperMotor, 0, 0.0);
324320
dJointSetAMotorParam(mSpringAndDamperMotor, dParamLoStop, clamped2);
325321
dJointSetAMotorParam(mSpringAndDamperMotor, dParamHiStop, clamped2);

0 commit comments

Comments
 (0)