| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | using System; |
| | using System.Linq; |
| | using System.Xml; |
| | using UnityEngine; |
| |
|
| | namespace Mujoco { |
| | public class MjGeomQuaternionSensor : MjBaseSensor { |
| | public MjGeom Geom; |
| |
|
| | public Quaternion SensorReading { get; private set; } |
| |
|
| | protected override XmlElement ToMjcf(XmlDocument doc) { |
| | if (Geom == null) { |
| | throw new NullReferenceException("Missing a reference to a MjGeom."); |
| | } |
| | var mjcf = doc.CreateElement("framequat"); |
| | mjcf.SetAttribute("objtype", "geom"); |
| | mjcf.SetAttribute("objname", Geom.MujocoName); |
| | return mjcf; |
| | } |
| |
|
| | protected override void FromMjcf(XmlElement mjcf) { |
| | Geom = mjcf.GetObjectReferenceAttribute<MjGeom>("objname"); |
| | if (Geom == null) { |
| | throw new NullReferenceException("Missing a reference to a MjGeom."); |
| | } |
| | } |
| |
|
| | public override unsafe void OnSyncState(MujocoLib.mjData_* data) { |
| | SensorReading = MjEngineTool.UnityQuaternion(data->sensordata + _sensorAddress); |
| | } |
| | } |
| | } |
| |
|