From 90c71bb28fbf01fd2f067049731d46b453fbec34 Mon Sep 17 00:00:00 2001 From: Joan Llobera Date: Tue, 18 Feb 2025 13:42:07 +0100 Subject: [PATCH 1/2] small change to fix the trouble importing the angles --- unity/Runtime/Components/Joints/MjBallJoint.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/unity/Runtime/Components/Joints/MjBallJoint.cs b/unity/Runtime/Components/Joints/MjBallJoint.cs index 1eca35ab29..e11738b7ed 100644 --- a/unity/Runtime/Components/Joints/MjBallJoint.cs +++ b/unity/Runtime/Components/Joints/MjBallJoint.cs @@ -31,10 +31,15 @@ protected override void OnParseMjcf(XmlElement mjcf) { transform.localPosition = MjEngineTool.UnityVector3(mjcf.GetVector3Attribute("pos", defaultValue: Vector3.zero)); - Settings.FromMjcf(mjcf); + var rangeValues = mjcf.GetFloatArrayAttribute("range", defaultValue: new float[] { 0, 0 }); // rangeValues[0] is always 0 for ball joints. + RangeUpper = rangeValues[1]; + if (!MjSceneImportSettings.AnglesInDegrees){ + rangeValues[1] *= Mathf.Rad2Deg; + } + Settings.FromMjcf(mjcf); } protected override XmlElement OnGenerateMjcf(XmlDocument doc) { From 4e681c717006ead19a2842051d471c68c06b4726 Mon Sep 17 00:00:00 2001 From: Joan Llobera Date: Tue, 18 Feb 2025 14:16:38 +0100 Subject: [PATCH 2/2] fixed the change in the previous commit, now it seems to be working --- unity/Runtime/Components/Joints/MjBallJoint.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/unity/Runtime/Components/Joints/MjBallJoint.cs b/unity/Runtime/Components/Joints/MjBallJoint.cs index e11738b7ed..3c9a7547d4 100644 --- a/unity/Runtime/Components/Joints/MjBallJoint.cs +++ b/unity/Runtime/Components/Joints/MjBallJoint.cs @@ -31,15 +31,16 @@ protected override void OnParseMjcf(XmlElement mjcf) { transform.localPosition = MjEngineTool.UnityVector3(mjcf.GetVector3Attribute("pos", defaultValue: Vector3.zero)); - + Settings.FromMjcf(mjcf); var rangeValues = mjcf.GetFloatArrayAttribute("range", defaultValue: new float[] { 0, 0 }); // rangeValues[0] is always 0 for ball joints. RangeUpper = rangeValues[1]; + if (!MjSceneImportSettings.AnglesInDegrees){ - rangeValues[1] *= Mathf.Rad2Deg; + RangeUpper *= Mathf.Rad2Deg; } - Settings.FromMjcf(mjcf); + } protected override XmlElement OnGenerateMjcf(XmlDocument doc) {