Merge pull request #275 from jespersmith:feature/UnityFixes
PiperOrigin-RevId: 450975561 Change-Id: I06deabfa19dd7649cf465bfb529206266371d5cc
This commit is contained in:
@@ -24,6 +24,7 @@ public class MjGeomEditor : MjShapeComponentEditor {
|
|||||||
serializedObject.Update();
|
serializedObject.Update();
|
||||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("Mass"));
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("Mass"));
|
||||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("Density"));
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("Density"));
|
||||||
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("Settings"));
|
||||||
serializedObject.ApplyModifiedProperties();
|
serializedObject.ApplyModifiedProperties();
|
||||||
base.OnInspectorGUI();
|
base.OnInspectorGUI();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ namespace Mujoco {
|
|||||||
[Tooltip("Joint movement, in rad/sec. Read-only at play time.")]
|
[Tooltip("Joint movement, in rad/sec. Read-only at play time.")]
|
||||||
public float Velocity;
|
public float Velocity;
|
||||||
|
|
||||||
|
[Tooltip("The current joint angle without normalization, in radians. Read-only.")]
|
||||||
|
public double RawConfiguration;
|
||||||
|
|
||||||
[Tooltip("Joint settings.")]
|
[Tooltip("Joint settings.")]
|
||||||
public MjJointSettings Settings = MjJointSettings.Default;
|
public MjJointSettings Settings = MjJointSettings.Default;
|
||||||
|
|
||||||
@@ -42,7 +45,8 @@ namespace Mujoco {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override unsafe void OnSyncState(MujocoLib.mjData_* data) {
|
public override unsafe void OnSyncState(MujocoLib.mjData_* data) {
|
||||||
var qpos = (float)data->qpos[QposAddress];
|
RawConfiguration = data->qpos[QposAddress];
|
||||||
|
var qpos = (float)RawConfiguration;
|
||||||
Configuration = (qpos % (2 * Mathf.PI)) * Mathf.Rad2Deg;
|
Configuration = (qpos % (2 * Mathf.PI)) * Mathf.Rad2Deg;
|
||||||
Velocity = (float)data->qvel[DofAddress];
|
Velocity = (float)data->qvel[DofAddress];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ public class MjSiteVectorSensor : MjBaseSensor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override unsafe void OnSyncState(MujocoLib.mjData_* data) {
|
public override unsafe void OnSyncState(MujocoLib.mjData_* data) {
|
||||||
SensorReading = MjEngineTool.UnityVector3(data->sensordata, _sensorAddress);
|
Vector3 mjReading = new Vector3((float)data->sensordata[_sensorAddress], (float)data->sensordata[_sensorAddress + 1], (float)data->sensordata[_sensorAddress + 2]);
|
||||||
|
SensorReading = MjEngineTool.UnityVector3(mjReading);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ namespace Mujoco {
|
|||||||
// Advanced settings of MjGeom component.
|
// Advanced settings of MjGeom component.
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public struct MjGeomSettings {
|
public struct MjGeomSettings {
|
||||||
|
|
||||||
|
|
||||||
|
[Tooltip("Priority")]
|
||||||
|
public int Priority;
|
||||||
|
|
||||||
[Tooltip("Solver accuracy settings.")]
|
[Tooltip("Solver accuracy settings.")]
|
||||||
public GeomSolver Solver;
|
public GeomSolver Solver;
|
||||||
|
|
||||||
@@ -38,6 +43,9 @@ public struct MjGeomSettings {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public void FromMjcf(XmlElement mjcf) {
|
public void FromMjcf(XmlElement mjcf) {
|
||||||
|
|
||||||
|
Priority = (int) mjcf.GetFloatAttribute("priority", 0);
|
||||||
|
|
||||||
// Contact filtering settings.
|
// Contact filtering settings.
|
||||||
Filtering.Contype = (int)mjcf.GetFloatAttribute("contype", CollisionFiltering.Default.Contype);
|
Filtering.Contype = (int)mjcf.GetFloatAttribute("contype", CollisionFiltering.Default.Contype);
|
||||||
Filtering.Conaffinity = (int)mjcf.GetFloatAttribute(
|
Filtering.Conaffinity = (int)mjcf.GetFloatAttribute(
|
||||||
@@ -71,6 +79,8 @@ public struct MjGeomSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void ToMjcf(XmlElement mjcf) {
|
public void ToMjcf(XmlElement mjcf) {
|
||||||
|
mjcf.SetAttribute("priority", $"{Priority}");
|
||||||
|
|
||||||
// Contact filtering settings.
|
// Contact filtering settings.
|
||||||
mjcf.SetAttribute("contype", $"{Filtering.Contype}");
|
mjcf.SetAttribute("contype", $"{Filtering.Contype}");
|
||||||
mjcf.SetAttribute("conaffinity", $"{Filtering.Conaffinity}");
|
mjcf.SetAttribute("conaffinity", $"{Filtering.Conaffinity}");
|
||||||
|
|||||||
Reference in New Issue
Block a user