Skip to content

Commit

Permalink
re-add Rz component to planar joints
Browse files Browse the repository at this point in the history
  • Loading branch information
EzraBrooks committed Mar 28, 2024
1 parent 3f05762 commit 2ae8294
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions javascript/src/URDFClasses.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ class URDFJoint extends URDFBase {
break;

case 'planar':
this.jointValue = new Array(2).fill(0);
// Planar joints are, 3dof: position XY and rotation Z.
this.jointValue = new Array(3).fill(0);
this.axis = new Vector3(0, 0, 1);
break;

case 'floating':
Expand Down Expand Up @@ -292,8 +294,8 @@ class URDFJoint extends URDFBase {
// no-op if all values are identical to existing value or are null
if (this.jointValue.every((value, index) => values[index] === value || values[index] === null)) return didUpdate;

// Planar joints have two degrees of freedom: X distance, Y distance
const [posX, posY] = values;
// Planar joints have three degrees of freedom: X distance, Y distance, Z rotation.
const [posX, posY, rotZ] = values;

// Respect existing RPY when modifying the position of the X,Y axes
this.position.copy(this.origPosition);
Expand All @@ -304,11 +306,18 @@ class URDFJoint extends URDFBase {
didUpdate = true;
}
if (posY !== null) {
_tempAxis.set(1, 0, 0).applyEuler(this.rotation);
_tempAxis.set(0, 1, 0).applyEuler(this.rotation);
this.position.addScaledVector(_tempAxis, posY);
this.jointValue[1] = posY;
didUpdate = true;
}
if (rotZ !== null) {
this.quaternion
.setFromAxisAngle(this.axis, rotZ)
.premultiply(this.origQuaternion);
this.jointValue[2] = rotZ;
didUpdate = true;
}

this.matrixWorldNeedsUpdate = didUpdate;
return didUpdate;
Expand Down

0 comments on commit 2ae8294

Please sign in to comment.