Background
This page provides a detailed guideline about how to use ROS to react to the armBOT. We suggest you to use the same procedure to do your own project with your own robot or other robots provided on our website.
Creating URDF files
The urdf file is an executable file used by ROS to describe the robot. There are many different ways to create a urdf file. Here we use the help of SolidWorks to translate the cad model into the urdf file. You can also create the urdf file by directly edit the code. This works well with a simple robot. See how to edit the code here.
When you have a robot with complicated geometry, it is better to get the urdf files translated from the cad model. Most robotic arms on this website have their cad model available on the Onshape website, you could also look into this free tool to translate the cad model in Onshape into urdf files.
If you are a Duke student, you can install the SolidWorks into your computer from the school. Click here to head to the instruction page.
For the first step, we need to download the urdf plugin provided by SolidWorks. Click here, you will be headed to the download page.
The second step is getting the cad model ready in your SolidWorks. For the armBOT, its assembly file can be downloaded from Thingiverse.com. You can also click here to see more about our armBOT project.
We suggest you try other robots provided by our website as well after finishing the whole project done to emphasize your learning. Here are some other robots:
This step is important and critical to creating a good urdf file for your robot. We are going to tell SolidWorks what are all joints locate and what are their rotating axis. See the urdf part of the Basic ROS Concept section on this page for more information about urdf.
We need one coordinate system as the global coordinate system. Then one coordinate system and one axis for every joint. Notice that the global coordinate decides how the robot sits in the world ground later in ROS’s simulation tools like RVIZ and Gazebo.
To add the coordinate and axis, please follow these steps: Insert>Reference Geometry>Cooedinate System or Axis
After inserting the coordinate systems and axis, we can start to output the urdf file for armBOT. Go to File>Export as URDF
After this step, a column will show up on the left.
We will have to define the base link first. Choose the global coordinate system you made on the last step as the global origin coordinate system. Click the link component window and then you can define what components will be taken as a base link by just clicking the corresponding parts of the cad model. For the number of child links, click the up button to add. Here we have only one child link. You can add more based on the structure of your robot later if you do this step for other robots.
The link tree diagram allows you to go to any links and define them. Click the new link you just created. This will be the next link to define. Similar to defining the base link, we have to define its coordinate system, link component, and the number of child links. Also here we will define the joint connecting link 1 and its parent link–base link. Choose the corresponding axis you created as the joint axis. Choose revolute as the joint type. All other links will be defined in the same way. Keep doing this until you have defined all the links and joints.
Once you are done defining all the links and joints, click the preview and export button. One window will show up and ask you to define the joint properties and the link properties. The Origin and Axis will be automatically filled. The property we have to define for every joint is the rotating limit. Notice, the unit for that property is the radius. Click next button after defining all the joints.
For the link properties, edit the corresponding properties you want. You can just skip this part and keep the default values. Click Export and Meshes and it will ask you to choose the place to store the generated files. Remember to change the file name as ROS does not allow Captional Characters.
Begin at this stage, we will start to work in Ubuntu 18.04 with ROS. If you have followed the learning suggestions listed on our ROS page and finished the basic tutorial provided by the ROS Wiki, then you should have a catkin workspace ready in your Ubuntu System.
If you haven’t done so yet, please follow the third part of this tutorial here to create a catkin workspace named as catkin_ws.
From the last stage, we had the armBOT’s urdf files ready. It is a file holder with several different files. This is what we called catkin package file in ROS. It does not only contain the urdf file but also other critical files. For more information about the catkin package, please click here.
Here we assume you follow the instruction suggestions on our ROS page, you should use the VMware Player to run the Ubuntu system. If you use the double system on one machine, you need to find other ways to transfer your files to your Ubuntu system. For the first place, open the package.xml file. Change the email address in it as a valid one.
The second place is the display.launch in the launch file holder. Change the False into Ture on the 6th line.
This step is easy, you just have to drag your urdf package to the catkin_ws/src file holder. The next step is compiling the workspace. Before you compile the workspace, we need to modify several places of our urdf package. Otherwise, you may have trouble in the later compiling.
You have to compile your workspace every time you add one package into it. Click here to see more about compiling workspace and source. Once you want to run a package in a new terminal, you have to source its locating workspace as well to tell ROS where the package is from. The next three lines of command will compile your catkin_ws and source it after typing into the terminal.
$cd ~/catkin_ws
$catkin_make
$source devel/setup.bash
Now we can view our robot in RVIZ to see if our urdf has any problem. You can continue to type the following command into the same terminal that you did the compiling and source. If you closed that terminal and opened a new one, do the cd command and source first.
$roslaunch [your urdf package name] display.launch
Then you will see an empty RVIZ world like below:
On the left up window, click the map button and change it to base_link. Then you will see the red warning part turn into green.
Then click the add button on the left down, and choose robot model. Then you will see armBOT in the RVIZ.
You will see another window called joint state publisher appeared as you roslaunch the rviz before. You could change the angle of different joints and observe the corresponding movement of the armBOT.
If you have made any mistakes at the before stages, then you might find your robot model moving undesirably. For example, you might find the joint limits should be changed. This stage could be skipped. But as a chance to check your previous work and correct the model before moving forward, it is suggested to be taken.
Now we are starting the main part of this stage–setting up Moveit!. Moveit! is a useful visual simulation tool. It is a plugin of RVIZ and is usually used for motion planning. You could click here to learn more about Moveit! from the official tutorial.
To start setting up Moveit! for armBOT, type the following command to launch the setup assistant in a new terminal:
$roslaunch moveit_setup_assistant setup_assistant.launch
Click on the create new Moveit configuration package and choose your own urdf file. Then click load files.
For the self-collisions part, click the generate collision matrix.
Go to virtual joints, click add virtual joint, and set the joint name as “world_joint”. Set the child link as “base_link” and the parent frame name as “world_frame”. On this step, we connect the armBOT with the world ground.
Next, go to Planning Groups. Click add the group. We will first define the arm part. Enter Group Name as arm. Choose kdl_kinematics_plugin/KDLKinematicsPlugin as the kinematics solver. Leave the Kin. Search Resolution and Kin. Search Timeout. We will keep them as default. You could change this part later when you need.
Now Click on virtual_joint, select all the joints you made for the arm. DO NOT INCLUDE THE JOINTS FOR GRIPPER. Now click on the > button to add these joints into the list of selected joints on the right. For this step, you could also define the group by adding link chians.
Click save and then click add group again. This time we will need to add the gripper group. I will leave this part for you to practice your learning about setting planning groups. The process is the same. Here is an example tutorial on the official website. You could use that as a reference.
Go to the robot pose, and click add pose. Here we will define the initial pose for our robot. Name the pose as init_pose and set the robot’s pose as any pose you like by setting the joint angels. Here I set the armBOT as lifting up straightly.
For the end effector, we have to tell Moveit! which planning group is our gripper. Click Add End Effector, and name the end effector as gripper. Choose the gripper group that you defined in the planning group step as the end effector. Choose the right parent link.
Go to the ROS Control part. After setting this part, we will get a package of controller interface. For more information about this part, click here.
Click on Add Controller, and name it as arm_controller. Choose position_controllers/JointPositionController for the controller type. Then click Add Planning Group Joints. Choose arm group and move it to the right side list.
The last part for us to set is Author Information. Type your name and email address.
At the current stage, the rest parts are not critical. For the Passive Joints part, we can tell Moveit! which joint we don’t want it to move in the later motion planning. For the 3D Perception, it will add a camera in RVIZ. For Gazebo Simulation, it will generate gazebo package for the robot. For more information about these parts, please click here.
The last part is Configuration Files. We will tell the Setup Assistant where we hope to store its generated files. Here I create an empty file holder in catkin_ws/src named as config_armBOT.
Moveit Setup
Exploring Moveit!
Once you have finished the Moveit! Setup Assistant settings, you can play your robot in Moveit! now.
Open a new terminal. Remember to source every time you open a new terminal. Use the roslaunch command to launch the corresponding file.
$source ~/catkin_ws/devel/setup.bash
$roslaunch [your configuration package name] demo.launch
In the opening window, you can start to do the motion planning for the armBOT. Moveit! has its own inverse dynamic solver inside it. What we need to do to set the start state and the target pose. We can do this in two ways.
The first method is reacting with the Moveit! window. On the left down section, we can set the start pose. We can choose which planning group we want to react to. By just dragging the green sphere we can move the gripper to our desired position. Click the plan button, you will see the motion planned for armBOT. In the future, if you connect the ROS with the physical armBOT or the armBOT in the gazebo, then click the plan and execute button, it will output the command to the physical armBOT or the simulated armBOT.
In some cases, we want our armBOT to move to a specific position precisely. In that case, it will be better to do the motion planning with specific coordinates of the gripper instead of just dragging it by us. To achieve that, we can use the Moveit! Interface provided on the official website here.
The Interface is a node that could be coded with Python or C++. This capability has several modules that allow you to do more than plans a path to a pose goal. Keep the module you need and delete the one you don’t.
Remember that we use the rosrun command to run a node. You can put your code inside the configuration package you made before or create a new empty ros package. Remember that the ros package is not just a file holder, learn more about ros package here.
Now you have learned how to use ROS to do the motion planning for armBOT. But this project has not finished yet. Here we provide several options for you to expand this project. We hope this could provide you a direction for your next step of exploring ROS.
As the first option, you can try to connect with the physical armBOT so you can finally achieve the goal of controlling armBOT with ROS. The armBOT project provided on our website uses the Arduino pad as the controller of the physical robot. By connecting Ardunio with ROS, we can output our motion plan to the physical robot.
The armBOT project provided on our website also includes the Computer Vision part. You can try to put the armBOT in the gazebo–another visual simulation. There you could use the camera capability from the ROS community to simulate the case that let armBOT pick a coke can and put it in the desired position automatically in gazebo.
What’s Next
This website is built by Yuhua Zhu, an MEng student at Duke Pratt School of Engineering, in 2020 Spring.
If you found any mistakes or have any doubts that you will contact us, please email Dr. Delagrammatikas:george.delagrammatikas@duke.edu