Simulating the robotic arm using V-REP and ROS

In the previous chapter, we used Gazebo to import and simulate the seven-DOF arm designed in Chapter 3, Working with 3D Robot Modeling in ROS. Here, we will do the same thing using V-REP. The first step to simulate our seven-DOF arm is to import it in the simulation scene. V-REP allows you to import new robots using URDF files; for this reason, we must convert the xacro model of the arm in a URDF file, saving the generated URDF file in the URDF folder of the vrep_demo_pkg package:

$ rosrun xacro xacro seven_dof_arm.xacro -inorder > /path/to/vrep_demo_pkg/urdf/seven_dof_arm.urdf

We can now import the robot model using the URDF import plugin. Select from the main drop-down menu the entry Plugins | URDF import and press the import button, choosing the default import options from the dialog window. Finally, select the desired file to import and the seven-DOF arm will appear in the scene:

Figure 10: Simulation of seven-DOF arm in V-REP

All the components of the robot are now imported into the scene, as we can see from the Scene hierarchy panel, in which are reported the set of robot joints and links defined in the URDF file.

Even if the robot has been correctly imported, is not ready to be controlled yet. To actuate the robot, we need to enable all robot motors from the Joint Dynamic Properties panel. Until the motor is disabled, it is not possible to move it during the simulation. To enable the motor of a joint, open the Scene object proprieties panel, selecting its entry from the main drop-down menu: ToolsScene object proprieties. You can also open this dialog with a double-click on an object icon in the scene hierarchy. From this new window, open the dynamic properties dialog and enable the motor and the control loop of the joint, selecting the controller type. By default, the motor is controlled via a PID, as shown in the following figure:

Figure 11: Scene Object Proprieties and Joint Dynamic Proprieties dialogs

To increase the performance of the control loop, PID gains should be properly tuned. After enabling motors and control loops for all robot joints, we can check that everything has been configured correctly. Run the simulation and set a target position from the Scene Object Proprieties panel.

Here is an example of moving the fourth joint to 1.0 radians:

Figure 12: Moving a joint of the arm from V-REP Object Proprieties dialog.