From 7209367bde68613a435638e18b7f2515c0f41792 Mon Sep 17 00:00:00 2001 From: vidurvij-Unity Date: Tue, 1 Mar 2022 16:30:09 -0800 Subject: [PATCH 1/2] Changing maxVelocity API --- .../Runtime/UrdfComponents/UrdfJoints/UrdfJointContinuous.cs | 2 +- .../Runtime/UrdfComponents/UrdfJoints/UrdfJointPlanar.cs | 2 +- .../Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismatic.cs | 2 +- .../Runtime/UrdfComponents/UrdfJoints/UrdfJointRevolute.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointContinuous.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointContinuous.cs index 6a8d3f99..e8deb9f0 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointContinuous.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointContinuous.cs @@ -138,7 +138,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; diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPlanar.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPlanar.cs index 73299826..6be36c73 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPlanar.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPlanar.cs @@ -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 { diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismatic.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismatic.cs index 8e0ec91c..93e117d0 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismatic.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismatic.cs @@ -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 diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevolute.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevolute.cs index a79aad48..86bb8e87 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevolute.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevolute.cs @@ -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; From 0b28ec08020ab0f8c1815a2b89e60bd6630b9c1f Mon Sep 17 00:00:00 2001 From: vidurvij-Unity Date: Thu, 3 Mar 2022 01:41:27 -0800 Subject: [PATCH 2/2] Update tests for the new max velocity limit api --- .../UrdfComponents/UrdfJoints/UrdfJointContinuous.cs | 6 ++++++ .../Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismatic.cs | 2 +- .../Runtime/UrdfComponents/UrdfJoints/UrdfJointRevolute.cs | 2 +- .../UrdfComponents/UrdfJoints/UrdfJointPlanarTests.cs | 2 +- .../UrdfComponents/UrdfJoints/UrdfJointPrismaticTests.cs | 4 ++-- .../UrdfComponents/UrdfJoints/UrdfJointRevoluteTests.cs | 2 +- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointContinuous.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointContinuous.cs index e8deb9f0..c8347549 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointContinuous.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointContinuous.cs @@ -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); + } /// diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismatic.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismatic.cs index 93e117d0..3eb334ba 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismatic.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismatic.cs @@ -186,7 +186,7 @@ protected override Joint.Limit ExportLimitData() #if UNITY_2020_1_OR_NEWER ArticulationDrive drive = GetComponent().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 diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevolute.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevolute.cs index 86bb8e87..5582e464 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevolute.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevolute.cs @@ -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(); return new Joint.Limit( diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointPlanarTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointPlanarTests.cs index 2f4cfad5..b015b949 100644 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointPlanarTests.cs +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointPlanarTests.cs @@ -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); } diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismaticTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismaticTests.cs index 3c3de789..42332bdd 100644 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismaticTests.cs +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismaticTests.cs @@ -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); @@ -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); } diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevoluteTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevoluteTests.cs index a6dd2cd3..af3aa510 100644 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevoluteTests.cs +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevoluteTests.cs @@ -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); }