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
+16 -4
View File
@@ -35,6 +35,10 @@ public static class MjEngineTool {
return name.Replace('/', '_');
}
public static string MakeLocaleInvariant(FormattableString interpolated) {
return FormattableString.Invariant(interpolated);
}
// Loads a model from the specified file.
// `filename` should contain an absolute path to the file.
public static unsafe MujocoLib.mjModel_* LoadModelFromFile(string fileName) {
@@ -190,11 +194,11 @@ public static class MjEngineTool {
}
public static string Vector3ToMjcf(Vector3 vec) {
return $"{vec.x} {vec.y} {vec.z}";
return MakeLocaleInvariant($"{vec.x} {vec.y} {vec.z}");
}
public static string QuaternionToMjcf(Quaternion quat) {
return $"{quat.w} {quat.x} {quat.y} {quat.z}";
return MakeLocaleInvariant($"{quat.w} {quat.x} {quat.y} {quat.z}");
}
// We can't use transform.localPosition because we allow arbitrary deep gameObject hierarchies
@@ -230,12 +234,20 @@ public static class MjEngineTool {
// Converts an array of floats to an Mjcf.
public static string ArrayToMjcf(float[] array) {
return String.Join(" ", array);
String ret = "";
foreach (float entry in array) {
ret += MakeLocaleInvariant($"{entry} ");
}
return ret.Substring(startIndex:0, length:ret.Length - 1);
}
// Converts a list of floats to an Mjcf.
public static string ListToMjcf(List<float> list) {
return String.Join(" ", list);
String ret = "";
foreach (float entry in list) {
ret += MakeLocaleInvariant($"{entry} ");
}
return ret.Substring(startIndex:0, length:ret.Length - 1);
}
// Generates an Mjcf of the specified component's transform.
+1 -1
View File
@@ -70,7 +70,7 @@ public class MjcfGenerationContext {
var optionMjcf = (XmlElement)mjcf.AppendChild(doc.CreateElement("option"));
optionMjcf.SetAttribute(
"gravity", MjEngineTool.Vector3ToMjcf(MjEngineTool.MjVector3(Physics.gravity)));
optionMjcf.SetAttribute("timestep", $"{Time.fixedDeltaTime}");
optionMjcf.SetAttribute("timestep", MjEngineTool.MakeLocaleInvariant($"{Time.fixedDeltaTime}"));
var sizeMjcf = (XmlElement)mjcf.AppendChild(doc.CreateElement("size"));
sizeMjcf.SetAttribute("nuser_sensor", $"{_nuserSensor}");