summaryrefslogtreecommitdiff
path: root/examples/pybullet/gym/pybullet_utils
diff options
context:
space:
mode:
authorerwincoumans <erwin.coumans@gmail.com>2018-11-21 11:07:05 -0800
committererwincoumans <erwin.coumans@gmail.com>2018-11-21 11:07:05 -0800
commitf93e4e45536a5090074c58b2d168555e812efa22 (patch)
tree21f39070420234a5089b5b4dd2209df77c9576a5 /examples/pybullet/gym/pybullet_utils
parent41e28e3587adacc14d0cba7b5b4833b4994bf901 (diff)
downloadbullet3-f93e4e45536a5090074c58b2d168555e812efa22.tar.gz
fix mjcf2urdf.py for Python 3 (utf) and don't export visuals (let it auto-convert from collision element)
Diffstat (limited to 'examples/pybullet/gym/pybullet_utils')
-rw-r--r--examples/pybullet/gym/pybullet_utils/examples/mjcf2urdf.py9
-rw-r--r--examples/pybullet/gym/pybullet_utils/urdfEditor.py12
2 files changed, 14 insertions, 7 deletions
diff --git a/examples/pybullet/gym/pybullet_utils/examples/mjcf2urdf.py b/examples/pybullet/gym/pybullet_utils/examples/mjcf2urdf.py
index c1e39745d..f7903262f 100644
--- a/examples/pybullet/gym/pybullet_utils/examples/mjcf2urdf.py
+++ b/examples/pybullet/gym/pybullet_utils/examples/mjcf2urdf.py
@@ -18,4 +18,11 @@ for o in objs:
humanoid = objs[o]
ed0 = ed.UrdfEditor()
ed0.initializeFromBulletBody(humanoid, p._client)
- ed0.saveUrdf(p.getBodyInfo(0)[1]+"_"+p.getBodyInfo(o)[0]+".urdf")
+ robotName = str(p.getBodyInfo(o)[1],'utf-8')
+ partName = str(p.getBodyInfo(o)[0], 'utf-8')
+
+ print("robotName=",robotName)
+ print("partName=",partName)
+
+ saveVisuals=False
+ ed0.saveUrdf(robotName+"_"+partName+".urdf", saveVisuals)
diff --git a/examples/pybullet/gym/pybullet_utils/urdfEditor.py b/examples/pybullet/gym/pybullet_utils/urdfEditor.py
index 6b05ce72c..3edca4596 100644
--- a/examples/pybullet/gym/pybullet_utils/urdfEditor.py
+++ b/examples/pybullet/gym/pybullet_utils/urdfEditor.py
@@ -273,7 +273,7 @@ class UrdfEditor(object):
file.write("\t\t</collision>\n")
- def writeLink(self, file, urdfLink):
+ def writeLink(self, file, urdfLink,saveVisuals):
file.write("\t<link name=\"")
file.write(urdfLink.link_name)
file.write("\">\n")
@@ -283,9 +283,9 @@ class UrdfEditor(object):
for v in urdfLink.urdf_visual_shapes:
if (v.geom_type == p.GEOM_CAPSULE):
hasCapsules = True
- if (not hasCapsules):
- for v in urdfLink.urdf_visual_shapes:
- self.writeVisualShape(file,v)
+ if (saveVisuals and not hasCapsules):
+ for v in urdfLink.urdf_visual_shapes:
+ self.writeVisualShape(file,v)
for c in urdfLink.urdf_collision_shapes:
self.writeCollisionShape(file,c)
file.write("\t</link>\n")
@@ -329,7 +329,7 @@ class UrdfEditor(object):
file.write(str)
file.write("\t</joint>\n")
- def saveUrdf(self, fileName):
+ def saveUrdf(self, fileName, saveVisuals=True):
file = open(fileName,"w")
file.write("<?xml version=\"0.0\" ?>\n")
file.write("<robot name=\"")
@@ -337,7 +337,7 @@ class UrdfEditor(object):
file.write("\">\n")
for link in self.urdfLinks:
- self.writeLink(file,link)
+ self.writeLink(file,link, saveVisuals)
for joint in self.urdfJoints:
self.writeJoint(file,joint)