Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AIRO-1796 Change API used to set and query maximum, velocity of a joint. #190

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ protected override Joint ExportSpecificJointData(Joint joint)
#endif
return joint;
}

protected override Joint.Limit ExportLimitData()
{
ArticulationDrive drive = unityJoint.xDrive;
return new Joint.Limit(0, 0, drive.forceLimit, unityJoint.maxJointVelocity);
}


/// <summary>
Expand All @@ -138,7 +144,7 @@ protected override void AdjustMovement(Joint joint)
{
ArticulationDrive drive = unityJoint.xDrive;
drive.forceLimit = (float)(joint.limit.effort);
unityJoint.maxAngularVelocity = (float)(joint.limit.velocity);
unityJoint.maxJointVelocity = (float)(joint.limit.velocity);
drive.damping = unityJoint.xDrive.damping;
drive.stiffness = unityJoint.xDrive.stiffness;
unityJoint.xDrive = drive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ protected override void AdjustMovement(Joint joint)
unityJoint.xDrive = drive;
unityJoint.zDrive = drive;
unityJoint.yDrive = drive;
unityJoint.maxLinearVelocity = (float)joint.limit.velocity;
unityJoint.maxJointVelocity = (float)joint.limit.velocity;
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ protected override void AdjustMovement(Joint joint) // Test this function
drive.lowerLimit = (float)joint.limit.lower;
drive.forceLimit = (float)joint.limit.effort;
#if UNITY_2020_2_OR_NEWER
unityJoint.maxLinearVelocity = (float)joint.limit.velocity;
unityJoint.maxJointVelocity = (float)joint.limit.velocity;
#elif UNITY_2020_1
maxLinearVelocity = (float)joint.limit.velocity;
#endif
Expand Down Expand Up @@ -186,7 +186,7 @@ protected override Joint.Limit ExportLimitData()
#if UNITY_2020_1_OR_NEWER
ArticulationDrive drive = GetComponent<ArticulationBody>().xDrive;
#if UNITY_2020_2_OR_NEWER
return new Joint.Limit(drive.lowerLimit, drive.upperLimit, drive.forceLimit, unityJoint.maxLinearVelocity);
return new Joint.Limit(drive.lowerLimit, drive.upperLimit, drive.forceLimit, unityJoint.maxJointVelocity);
#elif UNITY_2020_1
return new Joint.Limit(drive.lowerLimit, drive.upperLimit, drive.forceLimit, maxLinearVelocity);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected override Joint.Limit ExportLimitData()
{
#if UNITY_2020_1_OR_NEWER
ArticulationDrive drive = unityJoint.xDrive;
return new Joint.Limit(drive.lowerLimit * Mathf.Deg2Rad, drive.upperLimit * Mathf.Deg2Rad, drive.forceLimit, unityJoint.maxAngularVelocity);
return new Joint.Limit(drive.lowerLimit * Mathf.Deg2Rad, drive.upperLimit * Mathf.Deg2Rad, drive.forceLimit, unityJoint.maxJointVelocity);
#else
HingeJointLimitsManager hingeJointLimits = GetComponent<HingeJointLimitsManager>();
return new Joint.Limit(
Expand Down Expand Up @@ -168,7 +168,7 @@ protected override void AdjustMovement(Joint joint)
drive.upperLimit = (float)(joint.limit.upper * Mathf.Rad2Deg);
drive.lowerLimit = (float)(joint.limit.lower * Mathf.Rad2Deg);
drive.forceLimit = (float)(joint.limit.effort);
unityJoint.maxAngularVelocity = (float)(joint.limit.velocity);
unityJoint.maxLinearVelocity = (float)(joint.limit.velocity);
drive.damping = unityJoint.xDrive.damping;
drive.stiffness = unityJoint.xDrive.stiffness;
unityJoint.xDrive = drive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void ImportJointData_SpecificLimit_Succeeds()
Assert.AreEqual(6, articulationBody.xDrive.forceLimit);
Assert.AreEqual(6, articulationBody.yDrive.forceLimit);
Assert.AreEqual(6, articulationBody.zDrive.forceLimit);
Assert.AreEqual(7, articulationBody.maxLinearVelocity);
Assert.AreEqual(7, articulationBody.maxJointVelocity);

Object.DestroyImmediate(baseObject);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void ImportJointData_SpecificAixs_Succeeds()
Assert.AreEqual(4, articulationBody.xDrive.lowerLimit);
Assert.AreEqual(5, articulationBody.xDrive.upperLimit);
Assert.AreEqual(6, articulationBody.xDrive.forceLimit);
Assert.AreEqual(7, articulationBody.maxLinearVelocity);
Assert.AreEqual(7, articulationBody.maxJointVelocity);
Assert.AreEqual(8, articulationBody.linearDamping);
Assert.AreEqual(8, articulationBody.angularDamping);
Assert.AreEqual(9, articulationBody.jointFriction);
Expand Down Expand Up @@ -138,7 +138,7 @@ public void ExportSpecificJointData_Succeeds()
Assert.AreEqual(articulationBody.xDrive.lowerLimit, joint.limit.lower);
Assert.AreEqual(articulationBody.xDrive.upperLimit, joint.limit.upper);
Assert.AreEqual(articulationBody.xDrive.forceLimit, joint.limit.effort);
Assert.AreEqual(articulationBody.maxLinearVelocity, joint.limit.velocity);
Assert.AreEqual(articulationBody.maxJointVelocity, joint.limit.velocity);

Object.DestroyImmediate(linkObject);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void ExportSpecificJointData_Succeeds()
Assert.AreEqual(articulationBody.xDrive.lowerLimit * Mathf.Deg2Rad, joint.limit.lower);
Assert.AreEqual(articulationBody.xDrive.upperLimit * Mathf.Deg2Rad, joint.limit.upper);
Assert.AreEqual(articulationBody.xDrive.forceLimit, joint.limit.effort);
Assert.AreEqual(articulationBody.maxAngularVelocity, joint.limit.velocity);
Assert.AreEqual(articulationBody.maxJointVelocity, joint.limit.velocity);

Object.DestroyImmediate(linkObject);
}
Expand Down