FIRSTSim/modeling

To migrate your FIRST robot from CAD files into Gazebo, you will need to convert your files into a format that can be read by the Gazebo interface. This requires creating both the “mesh” files describing the shape of the robot in simulation, but also the parameters defining the movable joints, ranges of travel, and means of controlling the joints. This can be done in two ways – by manually converting the CAD files into mesh files and then assigning the joints and associated parameters, or by using an existing conversion tool, which currently only exists for Solidworks. For information on the Solidworks-to-URDF plugin, please visit the tutorial here. The rest of this tutorial defines the harder, but more flexible, path of manually creating your own robot file.

To explain the process, let’s start with a walkthrough of how the FTC_robot package was created, starting with a ProEngineer Creo model of the FTC Team 4220 (The Landroids) robot. As an oversimplification, this robot has a chassis, four movable wheels, and a lifting mechanism, in addition to a number of sensors (covered in the Gazebo tutorial here). This means that there are going to be at least 5 joints – one for the connection of each wheel to the chassis, and one for the lift mechanism. A sixth joint was eventually added to allow the scoop to pivot on the lifting arm, and to experiment with the stiffness of this rotary hinge. For a detailed overview of creating robot models with different joints, see the Gazebo tutorial here.

To migrate from ProEngineer Creo into the Gazebo “URDF” (Universal Robot Description File) format, you will need to create the mesh files for each “link”, and then specify the location and behavior of each “joint”. The first thing to do is to separate out the parts of the robot that need to be independent mesh files, and save them as stereolithography files (.STL extension). Creo has the option to export a part in this format, so separate out the chassis and save as an .STL file, then separate a single wheel and save as a different .STL file, and so on. If you want to get really fancy, you can try to individually model the rollers on the omni wheels of the robot – if you do, please post your results to the Gazebo community so we can add them! Once you have the mesh files, you have to rebuild them in URDF form to make them readable by Gazebo. To see how this looks, open up the existing ftc_robot description file, found here:

gedit /usr/share/ftcsim-0.1/models/ftc_robot/ftc_robot.sdf

Inside, you will see some overhead, and then things that make sense:

   false  0 0 .05 1.570796 0 0         model://FTC_Robot/meshes/chassis.stl 0.025400 0.025400 0.025400         model://FTC_Robot/meshes/chassis.stl 0.025400 0.025400 0.025400          gedit /usr/share/ftcsim-0.1/ros/ftcsim_utils/ftc_demo.launch ...

The beginning of the file lays out the file format, the name to be used by Gazebo, specifies whether it will be rigid in the Gazebo world or movable, and then starts assembling by placing the master “link” – the base component off of which other robot parts are attached, in this case the chassis. This structure follows a parent-child relationship; in our case, the chassis is the parent, the wheels and lifter are the children of the chassis, and the claw is the child of the lifter.

You will have to experiment with the positioning (and possibly the scaling) of each link in the model to get it placed exactly where you want relative to the previous link. This can be time consuming, and can be helped significantly by creating reference origin points back in Creo for each link and establishing their relative positioning. The descriptor lists orientation with respect to the world, for the parent link, or with respect to the parent link, for child links.

You will also need to describe some parameters about how your robot is constructed – the inertias and masses of each link, which can be obtained easily in Solidworks, and possibly in Creo as well. If you do not know the inertias of each link, ask one of your mentors how to calculate this, or make some assumptions – how accurate your robot will behave is determined by how accurately you model it.

Explore the SDF file further to see how child links are added, and how plugins (sensors and controllers) are added. You can steal the code for the webcam if you want to just copy the same parameters and only specify the camera location and basic parameters like resolution and refresh rate, or read through the Gazebo tutorials on how to create your own sensors, such as the ultrasonic, IR, and tactile sensors available in the FIRST Tech Challenge and FIRST Robotics Challenge kit of parts.

Lastly, you will need to create a controller plugin that governs how the links can be moved along the joints. For information on this, please see the Advanced Robot Controls Tutorial, which walks through how the FTC robot controller code is created and what it does.