@@ -1079,7 +1079,7 @@ protected void BuildURDFVisuals(Transform visualTransform, XElement link, Vector
10791079
10801080 if ( geometry . HasElements ) {
10811081 // build origin
1082- Vector3 position = visualTransform . localPosition + anchorOffset ;
1082+ Vector3 position = visualTransform . localPosition + anchorOffset ;
10831083 Vector3 xyz = position . Unity2Ros ( ) ; //visualTransform.localPosition.Unity2Ros();
10841084 Vector3 rpy = new Vector3 ( - visualTransform . localEulerAngles . z * Mathf . Deg2Rad ,
10851085 visualTransform . localEulerAngles . x * Mathf . Deg2Rad ,
@@ -1191,9 +1191,10 @@ public static void BuildURDF(XElement robot, ZOSimOccurrence simOccurrence, Matr
11911191
11921192 simOccurrence . BuildURDFJoints ( robot , null , baseTransform , ref joints ) ;
11931193
1194+
11941195 // build links
11951196 HashSet < ZOSimOccurrence > links = new HashSet < ZOSimOccurrence > ( ) ;
1196- foreach ( URDFJoint joint in joints ) {
1197+ foreach ( URDFJoint joint in joints ) {
11971198 if ( links . Contains < ZOSimOccurrence > ( joint . Parent ) == false ) { // build parent link if not exist
11981199 Vector3 offset = - 1.0f * joint . ConnectedAnchor ;
11991200 if ( joints [ 0 ] == joint ) { // if base joint do not apply any offset to parent link
@@ -1208,6 +1209,30 @@ public static void BuildURDF(XElement robot, ZOSimOccurrence simOccurrence, Matr
12081209 links . Add ( joint . Child ) ;
12091210 }
12101211 }
1212+
1213+ if ( joints . Count == 0 ) { // if we don't have any joints then create a dummy world link and joint to first link
1214+
1215+ XElement link = new XElement ( "link" ) ;
1216+ link . SetAttributeValue ( "name" , "World" ) ;
1217+ robot . Add ( link ) ;
1218+
1219+ simOccurrence . BuildURDFLink ( robot , Vector3 . zero ) ;
1220+
1221+ XElement jointX = new XElement ( "joint" ) ;
1222+ jointX . SetAttributeValue ( "name" , $ "World_to_{ simOccurrence . Name } ") ;
1223+ jointX . SetAttributeValue ( "type" , "fixed" ) ;
1224+
1225+ XElement parentX = new XElement ( "parent" ) ;
1226+ parentX . SetAttributeValue ( "link" , "World" ) ;
1227+ jointX . Add ( parentX ) ;
1228+
1229+ XElement childX = new XElement ( "child" ) ;
1230+ childX . SetAttributeValue ( "link" , simOccurrence . Name ) ;
1231+ jointX . Add ( childX ) ;
1232+ robot . Add ( jointX ) ;
1233+
1234+ }
1235+
12111236 }
12121237
12131238 protected void BuildURDFJoints ( XElement robot , ZOSimOccurrence parent , Matrix4x4 worldJointMatrix , ref List < URDFJoint > joints ) {
0 commit comments