Note: This tutorial assumes that you have completed the previous tutorials: Writing a realtime Cartesian controller. |
Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. |
Running a realtime Cartesian controller
Description: This tutorial teaches you how to configure and run an existing Cartesian space controllerTutorial Level: ADVANCED
Contents
Introduction
In this tutorial we will run the controller created in the previous tutorial. This tutorial uses the gazebo simulator environment to run the controller, so you'll need some knowledge of gazebo. If you have never heard about gazebo, check out this tutorial first.
Starting the pr2 in Gazebo
So, let's get gazebo running first:
$ rosmake pr2_gazebo $ roslaunch gazebo_worlds empty_world.launch
You should see an empty gazebo world.
Now let's create a pr2 robot inside this world:
$ roslaunch pr2_gazebo pr2.launch
And your simulation world should look like this.
Configuring the Controller
The first step to running a controller is laying out its configuration on the parameter server. As explained in the tutorial about running a joint space controller, we can create a yaml file to do this. Create a file called cart_controller.yaml:
my_tutorial_controller_cart: type: MyControllerCart root_name: torso_lift_link tip_name: r_gripper_tool_frame
And also create a launch file for this controller, in a file called my_controller_cart.launch:
<launch> <rosparam file="$(find my_controller_cart_pkg)/cart_controller.yaml" command="load" /> <node pkg="pr2_controller_manager" type="spawner" args="my_tutorial_controller_cart" name="my_controller_cart_spawner" /> </launch>
Running the Controller
Before moving on we need to check if our controller got registered to the controller manager. To get the list of registered controllers, type:
$ rosrun pr2_controller_manager pr2_controller_manager list-types
Look in the output for our controller MyControllerCart. If it's there you're ready to load and start it.
Running
If everything looks good, let's try to run our controller:
$ roslaunch my_controller_cart.launch
You should see: "Loaded my_tutorial_controller". We can confirm that the controller is loaded with :
$ rosrun pr2_controller_manager pr2_controller_manager list
The right arm of the pr2 should start moving in a pretty nice Cartesian circle!