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

[Unity plugin] Support multielement springlength in tendons #1438

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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
Loading