Designing a virtual representation of a robot is not easy, but it has been greatly facilitated with the introduction of a SolidWorks extension SW2URDF by an amazing Stephen Brawner. This means that you can now design your robot in SolidWorks and directly export the assembly of links and joints into a ROS package with .STL meshes and URDF files and whatnot. Sounds too good to be true? Well it kind of is.
The workflow is very clearly described in the ROS website’s handy tutorial. And it may well be that it will work great for you in which case this post is a waste of your time. Good on you, you lucky bastard.
It seems to often be the case that the automatic workflow of the SW2URDF add-on fails. You have prepared your sweet sweet model, joined all the joints and named all the links, but upon pressing the magical “preview and export” button, the process generates a few joints and then the progress bar stops moving. Nothing new happens even when waiting for a rather long time.
This happened to me and a quick search on the internet revealed that this happened to a bunch of people before as well. And sadly no clear solution was being offered. But all is not lost, there is a workaround!
Digging a bit deeper (well not all that deep after all, it’s an issue raised on the package’s repository website), I have found a post by Ari Kapusta, referring to the same issue. And its solution! In a nutshell, it seems to be the automatic process generating joint origins and axes that is failing without raising an exception or warning. You can work around it if you follow my description (based on Ari’s comment).
- This procedure is assuming that you’re working with a Solid Works assembly of robot links and that you have already successfully installed the SW2URDF package. You can activate it with the ‘File > Export to URDF’. This will bring upon a menu where you can prepare names of all your joints and links and select the respective parts of the assembly.
- Having organised all the necessary information, you can proceed to activate the automatic process of joint definition and since you’re still reading, presumably fail at some point.
- Check which joint origins and axis have been generated and whether some of them seem correct. Presumably the last joint will have failed. Delete that result.
- All you have to do now is define all the remaining joints manually. It’s not hard to do. Following is a description that could help you in the process.
- Start by preparing guidelines withing the 3D sketch that was automatically generated. You will want to use a clever combination of construction lines akin to what you can see in the picture below. The two perpendicular construction lines that make not sense are remainder from the automatic process and you will need to delete them.
- Use the construction lines to define origin and axis of your joints as is your want. Try to keep the naming template generated by the automatic process and defined in the beginning of the process.
- When you’re done, go back to the ‘File > Export to URDF’ option. Now you will have a chance to select your predefined joints and axis instead of the automatic options.
- Run the ‘preview and export’ option again and you should through to the next option which is definition of kinetic properties and whatnot. When you’re done with that, you’re pretty much good to go!
Congratulations, you did it! And thanks to Ari for figuring this out!