This is an old revision of the document!
Table of Contents
Setting our Executive
We will now create a package to hold our executive trigging the various arm motion controllers.
Creating the Package
First, you need to create an empty package called iai_seminar_manipulation_executive. Note: As we'll be using roscpp our new executive has to depend on roscpp. Don't forget to also add proper links to your documentation.
Setting up the ROS node
Before adding any functionality, you should set up an empty ROS node.
- In our executive package, create a sub-directory src.
- In src, create a main.cpp, include the basic ROS header-file <ros/ros.h>, and add a typical c/c++ main function.
- In the main itself, init ros and call your node manipulation_executive, get a NodeHandle, and spin.
- In our executive package, add an entry to the CMakeLists to build an executable. You can also call it manipulation_executive.
- Now you should be able to rosmake and rosrun the Node. It will not do anything but spin silently. However, you can already use various of the ROS commandline tools, e.g. rosnode list, rosnode info, etc., to analyze its behavior.
Note: Almost all information necessary to complete this step can be found here.
Adding a Launch-File
As a next step, add a launch-file to start our executive once in a launch sub-dir of the package. Please note that it is considered good-practice to provide users with launch-files for your nodes. This way, you can make sure that people know how to run your applications.
Moving the Arms (a first glance)
In this sub-task you will use existing ROS functionality to move both arms of our PR2. The interface used for this is action. Please re-visit the actionlib documentation and tutorials as actionlib is a very essential and powerful interface in ROS. Afterwards, have a look at the following tutorial – the solution to this sub-task looks similar to it.
Step-by-step instructions:
- In our executive package, add a sub-directory include with a nested sub-directory called like our package, i.e. iai_seminar_manipulation_executive –we will put our header files there. It is typical ROS practice to have header files in the include/<package-name> sub-directory of your package.
- Copy the header file RobotArm.h from the materials provided in your repository into our sub-directory for header-files.
- Within our existing sub-dir src, create the empty equivalent of RobotArm.h, RobotArm.cpp
- In RobotArm.cpp, include RobotArm.h and implement the minimally necessary function stubs of the functions that you still need to implement for RobotArm.h, i.e. return some valid value here.
- In the CMakeLists, add RobotArm.cpp as a necessary source file to build our executive executable.
- Add the necessary dependencies introduced by the includes of RobotArm.h. Reminder: in ROS the package names are usually called ros-<distro>-<package>, with us using fuerte as distribution.
- Try to compile.
If everything compiles, you are ready to get your hands dirty:
- Implement waitForActionServer(), initGoal(const std::vector<std::string>& …), and startTrajectory(pr2_controller_msgs::JointTrajectoryGoal& …)
- Include RobotArm.h in your main.cpp, instantiate an object of the class RobotArm, and use it to send a goal request to move the left arm of the robot to the action server. As testing data we provided the file left_arm_goals.yaml in the directory materials of the your repository. Use the data of the first goal configuration.
- Make sure that the name of the action client you are using resides in the namespace of your controller. Example: Let's consider when started your node has the name my_node (this is the name you provide in the launch-file). Let's further consider you wanna call your action arm_action. After starting your node you could then make the following test in the console:
$rostopic list < some topics> /my_node/arm_action/goal /my_node/arm_action/feedback /my_node/arm_action/status /my_node/arm_action/cancel < some other topics> $
As a last step, update your launch-file for your users:
- In your launch-file, add topic-remap from your relative topic arm_action to the global name of the joint trajectory action of the left arm.
- If you now launch our environment, and then launch your executive the left arm of the robot should move to the desired configuration.
Hints: You can peek here to know how to use the controller, and