File tree Expand file tree Collapse file tree 4 files changed +11
-9
lines changed
Runtime/UrdfComponents/UrdfJoints Expand file tree Collapse file tree 4 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ public enum JointTypes
3434 Planar
3535 }
3636
37+ public int xAxis = 0 ;
38+
3739#if UNITY_2020_1_OR_NEWER
3840 protected UnityEngine . ArticulationBody unityJoint ;
3941 protected Vector3 axisofMotion ;
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ public override float GetPosition() // Check Units
4242 {
4343
4444#if UNITY_2020_1_OR_NEWER
45- return unityJoint . jointPosition [ 0 ] ;
45+ return unityJoint . jointPosition [ xAxis ] ;
4646#else
4747 return - ( ( HingeJoint ) unityJoint ) . angle * Mathf . Deg2Rad ;
4848#endif
@@ -55,7 +55,7 @@ public override float GetPosition() // Check Units
5555 public override float GetVelocity ( )
5656 {
5757 #if UNITY_2020_1_OR_NEWER
58- return unityJoint . velocity [ 0 ] ;
58+ return unityJoint . velocity [ xAxis ] ;
5959 #else
6060 return - ( ( HingeJoint ) unityJoint ) . velocity * Mathf . Deg2Rad ;
6161 #endif
@@ -68,7 +68,7 @@ public override float GetVelocity()
6868 public override float GetEffort ( )
6969 {
7070 #if UNITY_2020_1_OR_NEWER
71- return unityJoint . jointForce [ 0 ] ;
71+ return unityJoint . jointForce [ xAxis ] ;
7272 #else
7373 return - ( ( HingeJoint ) unityJoint ) . motor . force ;
7474 #endif
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ public static UrdfJoint Create(GameObject linkObject)
6060 public override float GetPosition ( )
6161 {
6262 #if UNITY_2020_1_OR_NEWER
63- return unityJoint . jointPosition [ 3 ] ;
63+ return unityJoint . jointPosition [ xAxis ] ;
6464 #else
6565 return Vector3 . Dot ( unityJoint . transform . localPosition - unityJoint . connectedAnchor , unityJoint . axis ) ;
6666 #endif
@@ -73,7 +73,7 @@ public override float GetPosition()
7373 public override float GetVelocity ( )
7474 {
7575#if UNITY_2020_1_OR_NEWER
76- return unityJoint . velocity [ 3 ] ;
76+ return unityJoint . velocity [ xAxis ] ;
7777#else
7878 return float . NaN ;
7979#endif
@@ -86,7 +86,7 @@ public override float GetVelocity()
8686 public override float GetEffort ( )
8787 {
8888#if UNITY_2020_1_OR_NEWER
89- return unityJoint . jointForce [ 3 ] ;
89+ return unityJoint . jointForce [ xAxis ] ;
9090#else
9191 return float . NaN ;
9292#endif
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ public static UrdfJoint Create(GameObject linkObject)
4747 public override float GetPosition ( )
4848 {
4949 #if UNITY_2020_1_OR_NEWER
50- return ( ( ArticulationBody ) unityJoint ) . jointPosition [ 0 ] * Mathf . Deg2Rad ;
50+ return ( ( ArticulationBody ) unityJoint ) . jointPosition [ xAxis ] * Mathf . Deg2Rad ;
5151#else
5252 return - ( ( HingeJoint ) unityJoint ) . angle * Mathf . Deg2Rad ;
5353#endif
@@ -60,7 +60,7 @@ public override float GetPosition()
6060 public override float GetVelocity ( )
6161 {
6262 #if UNITY_2020_1_OR_NEWER
63- return ( ( ArticulationBody ) unityJoint ) . jointVelocity [ 0 ] * Mathf . Deg2Rad ;
63+ return ( ( ArticulationBody ) unityJoint ) . jointVelocity [ xAxis ] * Mathf . Deg2Rad ;
6464 #else
6565 return - ( ( HingeJoint ) unityJoint ) . velocity * Mathf . Deg2Rad ;
6666 #endif
@@ -73,7 +73,7 @@ public override float GetVelocity()
7373 public override float GetEffort ( )
7474 {
7575 #if UNITY_2020_1_OR_NEWER
76- return unityJoint . jointForce [ 0 ] ;
76+ return unityJoint . jointForce [ xAxis ] ;
7777 #else
7878 return - ( ( HingeJoint ) unityJoint ) . motor . force ;
7979 #endif
You can’t perform that action at this time.
0 commit comments