File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ public Vector3 Axis {
7979 return UnityHingeJoint . axis ;
8080 }
8181 set {
82+ _axis = value ;
8283 UnityHingeJoint . axis = value ;
8384 }
8485 }
@@ -92,6 +93,7 @@ public Vector3 Anchor {
9293 return UnityHingeJoint . anchor ;
9394 }
9495 set {
96+ _anchor = value ;
9597 UnityHingeJoint . anchor = value ;
9698 }
9799 }
@@ -112,6 +114,7 @@ public Rigidbody ConnectedBody {
112114 }
113115 set {
114116 if ( UnityHingeJoint . connectedBody != value ) {
117+ _connectedBody = value ;
115118 UnityHingeJoint . connectedBody = value ;
116119 }
117120
Original file line number Diff line number Diff line change @@ -150,11 +150,28 @@ public static ZOSimDocumentRoot Import(XmlDocument xmlDocument) {
150150
151151 // set transform
152152 if ( workingJoint != null ) {
153+ // set the transform
153154 XmlNode xmlOrigin = workingJoint . GetChildByName ( "origin" ) ;
154155 Tuple < Vector3 , Quaternion > transform = OriginXMLToUnity ( xmlOrigin ) ;
155156 linkChild . transform . localPosition = transform . Item1 ;
156157 linkChild . transform . localRotation = transform . Item2 ;
157158
159+ // add rigidbody components
160+ Rigidbody childRigidBody = linkChild . AddComponent < Rigidbody > ( ) ;
161+ Rigidbody parentRigidBody = linkParent . AddComponent < Rigidbody > ( ) ;
162+
163+ // add joints
164+ string jointType = workingJoint . Attributes [ "type" ] . Value ;
165+ if ( jointType == "revolute" ) {
166+
167+ ZOHingeJoint hingeJoint = linkParent . AddComponent < ZOHingeJoint > ( ) ;
168+ hingeJoint . ConnectedBody = childRigidBody ;
169+ hingeJoint . Anchor = transform . Item1 ;
170+
171+ XmlNode xmlAxis = workingJoint . GetChildByName ( "axis" ) ;
172+ hingeJoint . Axis = xmlAxis . Attributes [ "xyz" ] . Value . FromURDFStringToVector3 ( ) . Ros2Unity ( ) ;
173+ }
174+
158175 }
159176
160177
You can’t perform that action at this time.
0 commit comments