From 56b30d9d15bcb5bba24230229c2edc057b35d613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Hodossy?= Date: Thu, 11 Jan 2024 16:09:06 +0000 Subject: [PATCH] Check the autolimits attribute before assigning default values for joint limitedness --- unity/Runtime/Components/Joints/MjJointSettings.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/unity/Runtime/Components/Joints/MjJointSettings.cs b/unity/Runtime/Components/Joints/MjJointSettings.cs index f2f3d72e..1b9e87e9 100644 --- a/unity/Runtime/Components/Joints/MjJointSettings.cs +++ b/unity/Runtime/Components/Joints/MjJointSettings.cs @@ -164,7 +164,14 @@ namespace Mujoco { RefFriction.FromMjcf(mjcf, "solreffriction"); ImpFriction.FromMjcf(mjcf, "solimpfriction"); FrictionLoss = mjcf.GetFloatAttribute("frictionloss", 0.0f); - Limited = mjcf.GetBoolAttribute("limited", false); + + bool defaultLimited = false; + if (mjcf.OwnerDocument.GetElementsByTagName("compiler")[0] is not XmlElement + compilerElement || !compilerElement.GetBoolAttribute("autolimits").Equals("false")) { + defaultLimited = mjcf.HasAttribute("range"); + } + + Limited = mjcf.GetBoolAttribute("limited", defaultLimited); Margin = mjcf.GetFloatAttribute("margin", defaultValue: 0.0f); } }