What I’m after is being able to design a mechanical system in a high-level CAD system like Autodesk Fusion 360 (which is my preferred weapon of choice currently), and easily export that model to Mujoco for simulation:
What I really want to do is generate a cohort of Fusion 360 models using the parametric variable capabilities of Fusion 360, and simulate those in OpenAI Gym in bulk, as an experiment in geometry optimisation for robotic design:
This is a similar approach that OpenAI are taking in developing their human-like robot hand, with the geometry optimisation aspect.
There are some impedance mismatches but this post describes the success I’ve had with a simple model.
The Fusion 360 Model
The mechanical system I’m working with is a four-legged robot with 4 joints:
The model is parameterised in 5 variables:
There are several constraints on what model can be successfully converted:
- All coordinate planes are aligned to Global XYZ
- There’s one “root” body, defined by using the Fusion “ground” designation. This is the root body in the Mujoco simulation.
- Only a single level of children, connected to the root, is supported.
- Only “Revolute” joints are supported (as Mujoco “hinge” joints).
My long-term goal is to support a wider variety of model complexities and joint types.
There is some really weird behaviour w.r.t. the position of joints, for which I’ve posted on the Fusion forum: Weird joint origin behaviour
If you look at the code there’s a workaround based on the fillet radius, which is ugly, but works for now.
The code is on Github. The script in question is under
which can be loaded into Fusion 360 as a add-in.
The script will write the XML model to
Once the model has been written, there is a rendering script that will render the model using the Mujoco viewer from mujoco-py.
There’s also an option to not automatically run the simulation (useful for debugging the model):
Converting from one format to another is always perilous, since the domains aren’t necessarily well aligned, but (except for the joint origin bug I mentioned), I’m happy with where I am for now.
It’s good enough to create a cohort of models for simulation, and I will add more complexity to the converter over time.
The cohort generation code is also in the repo already, I will write a post about that next.
P.S. The code is good enough for a prototype, but is unlikely to support your model and doesn’t claim to be able to. (I don’t even know if anyone else in the world uses the Fusion and Mujoco combination).