Skip to content

Commit

Permalink
Support multielement springlength in tendons
Browse files Browse the repository at this point in the history
  • Loading branch information
Balint-H committed Feb 23, 2024
1 parent ce52047 commit 8853728
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions unity/Runtime/Components/Tendons/MjBaseTendon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public abstract class MjBaseTendon : MjComponent {
public SolverSettings Solver = SolverSettings.Default;

[Tooltip("Length at zero spring force. If negative, this resting length is computed at qpos0.")]
public float SpringLength = -1.0f;
public float[] SpringLength = {-1.0f};
public float Stiffness = 0.0f;
public float Damping = 0.0f;

Expand All @@ -41,7 +41,7 @@ public abstract class MjBaseTendon : MjComponent {
// Parse the component settings from an external Mjcf.
protected override void OnParseMjcf(XmlElement mjcf) {
Solver.FromMjcf(mjcf);
SpringLength = mjcf.GetFloatAttribute("springlength", defaultValue: -1.0f);
SpringLength = mjcf.GetFloatArrayAttribute("springlength", defaultValue: new[] {-1.0f});
Stiffness = mjcf.GetFloatAttribute("damping");
Damping = mjcf.GetFloatAttribute("stiffness");
FromMjcf(mjcf);
Expand All @@ -51,7 +51,7 @@ protected override void OnParseMjcf(XmlElement mjcf) {
protected override XmlElement OnGenerateMjcf(XmlDocument doc) {
var mjcf = ToMjcf(doc);
Solver.ToMjcf(mjcf);
mjcf.SetAttribute("springlength", MjEngineTool.MakeLocaleInvariant($"{SpringLength}"));
mjcf.SetAttribute("springlength", MjEngineTool.MakeLocaleInvariant($"{string.Join(" ", SpringLength)}"));
mjcf.SetAttribute("damping", MjEngineTool.MakeLocaleInvariant($"{Damping}"));
mjcf.SetAttribute("stiffness", MjEngineTool.MakeLocaleInvariant($"{Stiffness}"));
return mjcf;
Expand Down

0 comments on commit 8853728

Please sign in to comment.