Version 2.1.2: Python bindings, OBJ assets support, bugfixes.

PiperOrigin-RevId: 434731612
Change-Id: I0cfda3e7a3d1c72036764986efc252ffa1b8c6b0
This commit is contained in:
Saran Tunyasuvunakool
2022-03-15 14:04:44 +00:00
parent 175d25cd9f
commit 3577e2cf8b
304 changed files with 23906 additions and 1013 deletions
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7d450c02683794ca6998862eebc97e43
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f98312e1fa23c4aa0a44050a7d76fc98
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6a18877f1d3c34909825953d015cc8cb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -44,7 +44,7 @@ namespace Mujoco {
MjEngineTool.PositionToMjcf(mjcf, this);
Settings.ToMjcf(mjcf);
mjcf.SetAttribute("range", $"0 {RangeUpper}");
mjcf.SetAttribute("range", MjEngineTool.MakeLocaleInvariant($"0 {RangeUpper}"));
return mjcf;
}
@@ -41,7 +41,7 @@ namespace Mujoco {
}
public void ToMjcf(XmlElement mjcf) {
mjcf.SetAttribute("armature", $"{Armature}");
mjcf.SetAttribute("armature", MjEngineTool.MakeLocaleInvariant($"{Armature}"));
Spring.ToMjcf(mjcf);
Solver.ToMjcf(mjcf);
}
@@ -62,10 +62,10 @@ namespace Mujoco {
public void ToMjcf(XmlElement mjcf) {
// Spring settings.
mjcf.SetAttribute("springref", $"{EquilibriumPose}");
mjcf.SetAttribute("springdamper", $"{TimeConstant} {DampingRatio}");
mjcf.SetAttribute("damping", $"{Damping}");
mjcf.SetAttribute("stiffness", $"{Stiffness}");
mjcf.SetAttribute("springref", MjEngineTool.MakeLocaleInvariant($"{EquilibriumPose}"));
mjcf.SetAttribute("springdamper", MjEngineTool.MakeLocaleInvariant($"{TimeConstant} {DampingRatio}"));
mjcf.SetAttribute("damping", MjEngineTool.MakeLocaleInvariant($"{Damping}"));
mjcf.SetAttribute("stiffness", MjEngineTool.MakeLocaleInvariant($"{Stiffness}"));
}
public void FromMjcf(XmlElement mjcf) {
@@ -102,7 +102,7 @@ namespace Mujoco {
}
public void ToMjcf(XmlElement element, string attributeName) {
element.SetAttribute(attributeName, $"{DMin} {DMax} {Width} {Midpoint} {Power}");
element.SetAttribute(attributeName, MjEngineTool.MakeLocaleInvariant($"{DMin} {DMax} {Width} {Midpoint} {Power}"));
}
}
@@ -122,7 +122,7 @@ namespace Mujoco {
}
public void ToMjcf(XmlElement element, string attributeName) {
element.SetAttribute(attributeName, $"{TimeConst} {DampRatio}");
element.SetAttribute(attributeName, MjEngineTool.MakeLocaleInvariant($"{TimeConst} {DampRatio}"));
}
}
@@ -153,9 +153,9 @@ namespace Mujoco {
ImpLimit.ToMjcf(mjcf, "solimplimit");
RefFriction.ToMjcf(mjcf, "solreffriction");
ImpFriction.ToMjcf(mjcf, "solimpfriction");
mjcf.SetAttribute("frictionloss", $"{FrictionLoss}");
mjcf.SetAttribute("frictionloss", MjEngineTool.MakeLocaleInvariant($"{FrictionLoss}"));
mjcf.SetAttribute("limited", $"{Limited}".ToLower());
mjcf.SetAttribute("margin", $"{Margin}");
mjcf.SetAttribute("margin", MjEngineTool.MakeLocaleInvariant($"{Margin}"));
}
public void FromMjcf(XmlElement mjcf) {
@@ -76,8 +76,8 @@ namespace Mujoco {
if (RangeLower > RangeUpper) {
throw new ArgumentException("Lower range value can't be bigger than Higher");
}
mjcf.SetAttribute("range", $"{RangeLower} {RangeUpper}");
mjcf.SetAttribute("ref", $"{Configuration}");
mjcf.SetAttribute("range", MjEngineTool.MakeLocaleInvariant($"{RangeLower} {RangeUpper}"));
mjcf.SetAttribute("ref", MjEngineTool.MakeLocaleInvariant($"{Configuration}"));
return mjcf;
}
+17 -17
View File
@@ -66,13 +66,13 @@ public class MjActuator : MjComponent {
mjcf.SetAttribute("forcelimited", $"{ForceLimited}".ToLowerInvariant());
mjcf.SetAttribute(
"ctrlrange",
$"{MjEngineTool.GetSorted(CtrlRange).x} {MjEngineTool.GetSorted(CtrlRange).y}");
MjEngineTool.MakeLocaleInvariant($"{MjEngineTool.GetSorted(CtrlRange).x} {MjEngineTool.GetSorted(CtrlRange).y}"));
mjcf.SetAttribute(
"forcerange",
$"{MjEngineTool.GetSorted(ForceRange).x} {MjEngineTool.GetSorted(ForceRange).y}");
MjEngineTool.MakeLocaleInvariant($"{MjEngineTool.GetSorted(ForceRange).x} {MjEngineTool.GetSorted(ForceRange).y}"));
mjcf.SetAttribute(
"lengthrange",
$"{MjEngineTool.GetSorted(LengthRange).x} {MjEngineTool.GetSorted(LengthRange).y}");
MjEngineTool.MakeLocaleInvariant($"{MjEngineTool.GetSorted(LengthRange).x} {MjEngineTool.GetSorted(LengthRange).y}"));
mjcf.SetAttribute("gear", MjEngineTool.ListToMjcf(Gear));
}
@@ -162,7 +162,7 @@ public class MjActuator : MjComponent {
public float Kp = 1.0f;
public void PositionToMjcf(XmlElement mjcf) {
mjcf.SetAttribute("kp", $"{Math.Abs(Kp)}");
mjcf.SetAttribute("kp", MjEngineTool.MakeLocaleInvariant($"{Math.Abs(Kp)}"));
}
public void PositionFromMjcf(XmlElement mjcf) {
Kp = mjcf.GetFloatAttribute("kp", defaultValue: 1.0f);
@@ -175,7 +175,7 @@ public class MjActuator : MjComponent {
public float Kv = 1.0f;
public void VelocityToMjcf(XmlElement mjcf) {
mjcf.SetAttribute("kv", $"{Math.Abs(Kv)}");
mjcf.SetAttribute("kv", MjEngineTool.MakeLocaleInvariant($"{Math.Abs(Kv)}"));
}
public void VelocityFromMjcf(XmlElement mjcf) {
Kv = mjcf.GetFloatAttribute("kv", defaultValue: 1.0f);
@@ -199,9 +199,9 @@ public class MjActuator : MjComponent {
public float[] Bias = new float[] { 0.0f, 0.0f, 0.0f };
public void CylinderToMjcf(XmlElement mjcf) {
mjcf.SetAttribute("timeconst", $"{CylinderTimeConst}");
mjcf.SetAttribute("area", $"{Math.Abs(Area)}");
mjcf.SetAttribute("diameter", $"{Math.Abs(Diameter)}");
mjcf.SetAttribute("timeconst", MjEngineTool.MakeLocaleInvariant($"{CylinderTimeConst}"));
mjcf.SetAttribute("area", MjEngineTool.MakeLocaleInvariant($"{Math.Abs(Area)}"));
mjcf.SetAttribute("diameter", MjEngineTool.MakeLocaleInvariant($"{Math.Abs(Diameter)}"));
mjcf.SetAttribute("bias", MjEngineTool.ArrayToMjcf(Bias));
}
@@ -246,16 +246,16 @@ public class MjActuator : MjComponent {
public float FvMax = 1.2f;
public void MuscleToMjcf(XmlElement mjcf) {
mjcf.SetAttribute("timeconst", $"{MuscleTimeConst[0]} {MuscleTimeConst[1]}");
mjcf.SetAttribute("timeconst", MjEngineTool.MakeLocaleInvariant($"{MuscleTimeConst[0]} {MuscleTimeConst[1]}"));
mjcf.SetAttribute(
"range", $"{MjEngineTool.GetSorted(Range).x} {MjEngineTool.GetSorted(Range).y}");
mjcf.SetAttribute("force", $"{Force}");
mjcf.SetAttribute("scale", $"{Scale}");
mjcf.SetAttribute("lmin", $"{LMin}");
mjcf.SetAttribute("lmax", $"{LMax}");
mjcf.SetAttribute("vmax", $"{VMax}");
mjcf.SetAttribute("fpmax", $"{FpMax}");
mjcf.SetAttribute("fvmax", $"{FvMax}");
"range", MjEngineTool.MakeLocaleInvariant($"{MjEngineTool.GetSorted(Range).x} {MjEngineTool.GetSorted(Range).y}"));
mjcf.SetAttribute("force", MjEngineTool.MakeLocaleInvariant($"{Force}"));
mjcf.SetAttribute("scale", MjEngineTool.MakeLocaleInvariant($"{Scale}"));
mjcf.SetAttribute("lmin", MjEngineTool.MakeLocaleInvariant($"{LMin}"));
mjcf.SetAttribute("lmax", MjEngineTool.MakeLocaleInvariant($"{LMax}"));
mjcf.SetAttribute("vmax", MjEngineTool.MakeLocaleInvariant($"{VMax}"));
mjcf.SetAttribute("fpmax", MjEngineTool.MakeLocaleInvariant($"{FpMax}"));
mjcf.SetAttribute("fvmax", MjEngineTool.MakeLocaleInvariant($"{FvMax}"));
}
public void MuscleFromMjcf(XmlElement mjcf) {
+12 -12
View File
@@ -291,14 +291,14 @@ public struct MjOptionStruct {
}
public XmlElement ToMjcf(XmlElement mjcf) {
mjcf.SetAttribute("impratio", $"{ImpRatio}");
mjcf.SetAttribute("impratio", MjEngineTool.MakeLocaleInvariant($"{ImpRatio}"));
mjcf.SetAttribute("magnetic", $"{Magnetic.x} {Magnetic.y} {Magnetic.z}");
mjcf.SetAttribute("wind", $"{Wind.x} {Wind.y} {Wind.z}");
mjcf.SetAttribute("magnetic", MjEngineTool.MakeLocaleInvariant($"{Magnetic.x} {Magnetic.y} {Magnetic.z}"));
mjcf.SetAttribute("wind", MjEngineTool.MakeLocaleInvariant($"{Wind.x} {Wind.y} {Wind.z}"));
mjcf.SetAttribute("density", $"{Density}");
mjcf.SetAttribute("viscosity", $"{Viscosity}");
mjcf.SetAttribute("o_margin", $"{OverrideMargin}");
mjcf.SetAttribute("density", MjEngineTool.MakeLocaleInvariant($"{Density}"));
mjcf.SetAttribute("viscosity", MjEngineTool.MakeLocaleInvariant($"{Viscosity}"));
mjcf.SetAttribute("o_margin", MjEngineTool.MakeLocaleInvariant($"{OverrideMargin}"));
OverrideSolRef.ToMjcf(mjcf, "o_solref");
OverrideSolImp.ToMjcf(mjcf, "o_solimp");
@@ -309,12 +309,12 @@ public struct MjOptionStruct {
mjcf.SetAttribute("jacobian", Jacobian.ToString());
mjcf.SetAttribute("solver", Solver.ToString());
mjcf.SetAttribute("iterations", $"{Iterations}");
mjcf.SetAttribute("tolerance", $"{Tolerance}");
mjcf.SetAttribute("noslip_iterations", $"{NoSlipIterations}");
mjcf.SetAttribute("noslip_tolerance", $"{NoSlipTolerance}");
mjcf.SetAttribute("mpr_iterations", $"{MprIterations}");
mjcf.SetAttribute("mpr_tolerance", $"{MprTolerance}");
mjcf.SetAttribute("iterations", MjEngineTool.MakeLocaleInvariant($"{Iterations}"));
mjcf.SetAttribute("tolerance", MjEngineTool.MakeLocaleInvariant($"{Tolerance}"));
mjcf.SetAttribute("noslip_iterations", MjEngineTool.MakeLocaleInvariant($"{NoSlipIterations}"));
mjcf.SetAttribute("noslip_tolerance", MjEngineTool.MakeLocaleInvariant($"{NoSlipTolerance}"));
mjcf.SetAttribute("mpr_iterations", MjEngineTool.MakeLocaleInvariant($"{MprIterations}"));
mjcf.SetAttribute("mpr_tolerance", MjEngineTool.MakeLocaleInvariant($"{MprTolerance}"));
var flags = (XmlElement)mjcf.AppendChild(
mjcf.OwnerDocument.CreateElement("flag"));
+1 -1
View File
@@ -43,7 +43,7 @@ public class MjInertial : MjComponent {
protected override XmlElement OnGenerateMjcf(XmlDocument doc) {
var mjcf = (XmlElement)doc.CreateElement("inertial");
MjEngineTool.PositionRotationToMjcf(mjcf, this);
mjcf.SetAttribute("mass", $"{Mass}");
mjcf.SetAttribute("mass", MjEngineTool.MakeLocaleInvariant($"{Mass}"));
mjcf.SetAttribute("diaginertia",
MjEngineTool.Vector3ToMjcf(MjEngineTool.MjExtents(DiagInertia)));
return mjcf;
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f9a0c761e9698497aba0a6c4d1774bd9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 00391142561004cc7befda5d7fcb3156
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -32,7 +32,7 @@ public class MjCapsuleShape : IMjShape {
" value of X and Y components.", transform);
}
mjcf.SetAttribute(
"size", $"{Radius * transform.lossyScale.x} {HalfHeight * transform.lossyScale.y}");
"size", MjEngineTool.MakeLocaleInvariant($"{Radius * transform.lossyScale.x} {HalfHeight * transform.lossyScale.y}"));
}
public void FromMjcf(XmlElement mjcf) {
@@ -32,7 +32,7 @@ public class MjCylinderShape : IMjShape {
" value of X and Y components.", transform);
}
mjcf.SetAttribute(
"size", $"{Radius * transform.lossyScale.x} {HalfHeight * transform.lossyScale.y}");
"size", MjEngineTool.MakeLocaleInvariant($"{Radius * transform.lossyScale.x} {HalfHeight * transform.lossyScale.y}"));
}
public void FromMjcf(XmlElement mjcf) {
@@ -64,9 +64,9 @@ public class MjGeom : MjShapeComponent {
protected override XmlElement OnGenerateMjcf(XmlDocument doc) {
var mjcf = (XmlElement)doc.CreateElement("geom");
if (Mass > 0) {
mjcf.SetAttribute("mass", $"{Mass}");
mjcf.SetAttribute("mass", MjEngineTool.MakeLocaleInvariant($"{Mass}"));
} else {
mjcf.SetAttribute("density", $"{Density}");
mjcf.SetAttribute("density", MjEngineTool.MakeLocaleInvariant($"{Density}"));
}
ShapeToMjcf(mjcf, transform);
MjEngineTool.PositionRotationToMjcf(mjcf, this);
@@ -78,15 +78,15 @@ public struct MjGeomSettings {
// Solver settings.
mjcf.SetAttribute("condim", $"{Solver.ConDim}");
mjcf.SetAttribute("solmix", $"{Solver.SolMix}");
mjcf.SetAttribute("solref", $"{Solver.SolRef.TimeConst} {Solver.SolRef.DampRatio}");
mjcf.SetAttribute("solmix", MjEngineTool.MakeLocaleInvariant($"{Solver.SolMix}"));
mjcf.SetAttribute("solref", MjEngineTool.MakeLocaleInvariant($"{Solver.SolRef.TimeConst} {Solver.SolRef.DampRatio}"));
mjcf.SetAttribute(
"solimp", $"{Solver.SolImp.DMin} {Solver.SolImp.DMax} {Solver.SolImp.Width}");
mjcf.SetAttribute("margin", $"{Solver.Margin}");
mjcf.SetAttribute("gap", $"{Solver.Gap}");
"solimp", MjEngineTool.MakeLocaleInvariant($"{Solver.SolImp.DMin} {Solver.SolImp.DMax} {Solver.SolImp.Width}"));
mjcf.SetAttribute("margin", MjEngineTool.MakeLocaleInvariant($"{Solver.Margin}"));
mjcf.SetAttribute("gap", MjEngineTool.MakeLocaleInvariant($"{Solver.Gap}"));
// Inertia and friction settings.
mjcf.SetAttribute("friction", $"{Friction.Sliding} {Friction.Torsional} {Friction.Rolling}");
mjcf.SetAttribute("friction", MjEngineTool.MakeLocaleInvariant($"{Friction.Sliding} {Friction.Torsional} {Friction.Rolling}"));
}
}
@@ -26,7 +26,7 @@ public class MjPlaneShape : IMjShape {
public void ToMjcf(XmlElement mjcf, Transform transform) {
var extents = new Vector3(Extents.x, Extents.y, 1.0f);
var scaledExtents = Vector3.Scale(extents, transform.lossyScale);
mjcf.SetAttribute("size", $"{scaledExtents.x} {scaledExtents.y} {scaledExtents.z}");
mjcf.SetAttribute("size", MjEngineTool.MakeLocaleInvariant($"{scaledExtents.x} {scaledExtents.y} {scaledExtents.z}"));
}
public void FromMjcf(XmlElement mjcf) {
@@ -32,7 +32,7 @@ public class MjSphereShape : IMjShape {
" component.\n Consider using Ellipsoid shape if you want to use non-uniform scaling.",
transform);
}
mjcf.SetAttribute("size", $"{Radius * transform.lossyScale.x}");
mjcf.SetAttribute("size", MjEngineTool.MakeLocaleInvariant($"{Radius * transform.lossyScale.x}"));
}
public void FromMjcf(XmlElement mjcf) {
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b58acb5cf1b8049acb79e46a0d8b851b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -51,9 +51,9 @@ public abstract class MjBaseTendon : MjComponent {
protected override XmlElement OnGenerateMjcf(XmlDocument doc) {
var mjcf = ToMjcf(doc);
Solver.ToMjcf(mjcf);
mjcf.SetAttribute("springlength", $"{SpringLength}");
mjcf.SetAttribute("damping", $"{Damping}");
mjcf.SetAttribute("stiffness", $"{Stiffness}");
mjcf.SetAttribute("springlength", MjEngineTool.MakeLocaleInvariant($"{SpringLength}"));
mjcf.SetAttribute("damping", MjEngineTool.MakeLocaleInvariant($"{Damping}"));
mjcf.SetAttribute("stiffness", MjEngineTool.MakeLocaleInvariant($"{Stiffness}"));
return mjcf;
}
@@ -57,13 +57,13 @@ public class MjFixedTendon : MjBaseTendon {
foreach (FixedTendonEntry fixedTendonEntry in JointList) {
var jointMjcf = doc.CreateElement("joint");
jointMjcf.SetAttribute("joint", fixedTendonEntry.Joint.MujocoName);
jointMjcf.SetAttribute("coef", $"{fixedTendonEntry.Coefficient}");
jointMjcf.SetAttribute("coef", MjEngineTool.MakeLocaleInvariant($"{fixedTendonEntry.Coefficient}"));
mjcf.AppendChild(jointMjcf);
}
if (RangeLower > RangeUpper) {
throw new ArgumentException("Lower range value can't be bigger than Higher");
}
mjcf.SetAttribute("range", $"{RangeLower} {RangeUpper}");
mjcf.SetAttribute("range", MjEngineTool.MakeLocaleInvariant($"{RangeLower} {RangeUpper}"));
return mjcf;
}
@@ -92,14 +92,14 @@ public class MjSpatialTendon : MjBaseTendon {
$"Exactly one of site/wrap geom/pulley {name} is required at each entry.");
}
elementMjcf = doc.CreateElement("pulley");
elementMjcf.SetAttribute("divisor", $"{spatialTendonEntry.PulleyDivisor}");
elementMjcf.SetAttribute("divisor", MjEngineTool.MakeLocaleInvariant($"{spatialTendonEntry.PulleyDivisor}"));
}
mjcf.AppendChild(elementMjcf);
}
if (RangeLower > RangeUpper) {
throw new ArgumentException("Lower range value can't be bigger than Higher");
}
mjcf.SetAttribute("range", $"{RangeLower} {RangeUpper}");
mjcf.SetAttribute("range", MjEngineTool.MakeLocaleInvariant($"{RangeLower} {RangeUpper}"));
return mjcf;
}