Scale overall robot in XML file without editing XML #330
-
Can we scale the robot model in the XML file without editing the XML itself? like: mujoco.MjModel.from_xml_path(
file_name="path_to_xml",
globalScaling=10.0) my robot needs to be twice the size according to the bounding box in fusion360. (The box is the bounding box) EDIT: The bounding box was not correctly specified ImagesThis urdf export is from fusion with fusion2urdf exporter. This model is then converted to XML with compile.cc
Inertias, masses, joints, etc have been exported properly, but not the meshes, they are half the size |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 6 replies
-
That's a good question. At the C API level, the route to creating a MuJoCo mjModel always goes through XML. Once an mjModel is created, scaling like that can't be done through the API. That means that scaling like you suggest does need to happen by creating a modified XML file, even if we hide it behind an API. We've chosen to make the MuJoCo python bindings are a thin layer on top of the C APIs, so such functionality doesn't exist. Where it could live might be the PyMJCF sub-library in dm_control. Another thing we talked about was building a better For your case, I think the quickest route forward is to figure out why the export produces meshes of the wrong sizes, and make a fix either to fusion2urdf, or to MuJoCo's URDF importer, depending on the cause. |
Beta Was this translation helpful? Give feedback.
-
I have used fusion2urdf and then compile.cc to convert it to an XML relatively easily. However, upon conversion, the size of the robot in the urdf that was generated from fusion2urdf fit correctly when rendered in pybullet as was in the CAD software. When converting to XML using compile.cc, the generated xml file was half the size.(1/8th in volume). Although the masses and the inertias were exported correctly. Note: The box is the approximate bounding box of the robot |
Beta Was this translation helpful? Give feedback.
-
OK. Given the same URDF works in Bullet, it's likely that there's a problem with MuJoCo's URDF importer. Would you be able to share the generated URDF and maybe the assets? |
Beta Was this translation helpful? Give feedback.
-
I cannot give the source, however, I have replicated the same effect with a 4-bar mechanism. Here are the files: There is a script to launch it in pybullet as well as one in mujoco. In the produced XML (from <option gravity="0 0 0" collision="predefined" />
<worldbody> <!--within <worldbody>-->
<light diffuse=".5 .5 .5" pos="0 -2 2" dir="0 1 -1" />
<body pos="0 0 0">
<geom type="box" size="1.05 0.15 1.05" rgba="1 1 1 .3" />
</body>
</worldbody> |
Beta Was this translation helpful? Give feedback.
-
defines a box that is 2.1m x 2.1m x 0.3m, since the size attribute on Does that explain the problem? |
Beta Was this translation helpful? Give feedback.
<geom type="box" size="1.05 0.15 1.05" rgba="1 1 1 .3" />
defines a box that is 2.1m x 2.1m x 0.3m, since the size attribute on
geom
specifies half-size.Does that explain the problem?