| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | using System; |
| | using System.Xml; |
| | using UnityEngine; |
| |
|
| | namespace Mujoco { |
| |
|
| | public abstract class MjBaseJoint : MjComponent { |
| | public override MujocoLib.mjtObj ObjectType => MujocoLib.mjtObj.mjOBJ_JOINT; |
| |
|
| | public int QposAddress { get; private set; } = -1; |
| | public int DofAddress { get; private set; } = -1; |
| | |
| | |
| | |
| | public MjBaseBody ParentBody { get; private set; } |
| |
|
| | |
| | |
| | |
| | |
| | public MjBaseBody GrandParentBody { get; private set; } |
| |
|
| | |
| | public void GetConnectedBodies(out MjBaseBody grandParent, out MjBaseBody parent) { |
| | parent = MjHierarchyTool.FindParentComponent<MjBaseBody>(this); |
| | if (parent != null) { |
| | grandParent = MjHierarchyTool.FindParentComponent<MjBaseBody>(parent); |
| | } else { |
| | grandParent = null; |
| | } |
| | } |
| |
|
| | protected override unsafe void OnBindToRuntime(MujocoLib.mjModel_* model, MujocoLib.mjData_* data) { |
| | QposAddress = model->jnt_qposadr[MujocoId]; |
| | DofAddress = model->jnt_dofadr[MujocoId]; |
| | } |
| |
|
| | protected void Start() { |
| | MjBaseBody grandparentBody, parentBody; |
| | GetConnectedBodies(out grandparentBody, out parentBody); |
| | GrandParentBody = grandparentBody; |
| | ParentBody = parentBody; |
| | if (ParentBody == null) { |
| | throw new Exception("The joint doesn't have a ParentBody."); |
| | } |
| | } |
| | } |
| | } |
| |
|