How to open a solidworks model in gazebo ?

As a person who is new to gazebo and even ubuntu I have some basic questions.
I wanted to open a SOLIDWORKS created model in gazebo. According to information that I received from SOLIDWORKS sources, I downloaded SW2URDF add-in and used it to create a URDF file. Unfortunately I've got mixed information about opening a model in gazebo, I don't even know which format is the correct one: URDF, Collada (.dae), SDF (I don't know how to import my file as a SDF from SOLIDWORKS and don't know if its a possible thing or not).

After creating such file, what's the next step for opening my model?
Among the tutorials from gazebosim.org I found this one useful
but my problem is how should I use it. I tried to save an empty world file and use the syntax to add my file but I have a stupid problem which is how to open this world file after saving it?! And is this the right way to do such a thing?!

2 Answers

You can also do it all manually without the SW2URDF plugin for solidworks. It might be slower but you will understand more what's going on, and learn a lot in the process.
Also it will give you the knowledge to change and correct the files generated by SW2URDF plugin because not always works perfectly, or you may want to add special elements.

Here you have a video with an example for Robot Fish Naro:VIDEO EXAMPLE

Here you have a guide line of what should be done:

1) The correct formats to use in Gazebo are two: SDF or URDF. GAzebo comunity supports more SDFs while the ROS community tends to use URDF. Its basicaly because its easier to use certain packages with one or the other. URDF would be the way to go in my opnion for more ROS related topics.

2) The meshes that Gazebo normaly uses are: STL and DAE formats. STL is the most standard one and DAE will give you easy ways of having colours and textures.

3) You have to follow these steps:

3.1) Create a simple URDF with only geometric shapes. This way you can test all the controllers and programs that you need, without the hustle of Meshes. The geometric shapes should have the same basic dimensions as the meshes. It also makes the inertia calculations easier with geometric shapes. Otherwise you need to calculate the inertias of the meshes with Meshlab based on the points of the mesh.

3.2) Create the spawing launch files that start the robot state publisher and the controllers. This will publish the TFs that allow you to see the model in RVIZ.

3.3) Export the SoldWorks Models to STL by saving them in that format. In exporting options you can adjust the quality of the meshes, depending on your computing power and needs for precission in the models and collisions.

3.4) Now use Blender to import the STLs, adjust their origins, scale and add matterials/textures. Then export them as DAEs.

3.5) Replace the visuals of basic geometric shapes by the DAE meshes. You can also place them in the collisions tag. You can even export the STLs in different qualities, a simple one for the collision mesh, and the higher quality for the visuals.

To work with ROS, you have to create a urdf model, which references DAE files as meshes for robot parts. To create this URDF and DAE files, you could use SW2URDF plugin for solidworks. Although it is working, it may give you some unwanted surprises (like wrong paths and so on). Make sure you use latest SW2URDF and please note, that "official" SW2URDF is pretty old. Check its forks and what bugs are fixed there.

SW2URDF creates not only an URDF model, but a system of ROS packages, with a model.config, which might be used in Gazebo. AFAIK it even creates corresponding launch files to open your model in an empty world, But again, paths needs to be messed with. So, after checking your newly created ROS packages, you might start your model with roslaunch.

To actually be able to import your model into Gazebo, you have to add a directory, where the directory with model is placed, to the GAZEBO_MODEL_PATH environment variable. Best place to do it is in your .profile or .bashrc/.zshrc file.

Comments

thanks for your consideration.
Could you recommend any organized tutorial over this ? As I said I'm new to both ubuntu and gazebo so I actually don't know how should I add a directory and any further path that I should take after that, and I actually didn't found any useful tuturial :(
thanks again

Sorry, I can't. Actually I'm collecting material to write a bunch of tutorials myself. To little information over there. Best way to try it out - start small. Start with your own urdf/sdf and learn to use it. Then you'll know what to expect and how to interpret the output of SW2URDF