Description: This tutorial teaches you how to write a joint space controller that can be executed in the realtime loop of pr2_controller_manager Tutorial Level: BEGINNER Next Tutorial: Running a realtime joint controller PomocSpisTreści 1. Introduction 2. Writing the code 1. The code 2. The code explained 3. Compiling the code 4. Register your controller as a plugin
Introduction
To understand this and the follow-on tutorials, you should be familiar with the documentation for a. pr2_controller_interface, which provides the code interface, i.e. how your code will be called. b. pr2_mechanism_model and in particular JointState, which provides access to the joint position sensors and joint torque commands. c. pr2_controller_manager, which load/start/stops and generally administers the execution of realtime code.
Writing the code
First, let's create a package where you'll build your controller. The package needs to depend on the pr2_controller_interface, the pr2_mechanism_model and the pluginlib. The controller interface package contains the base class for all controllers, the pr2_mechanism_model provides access to the robot joints, and the pluginlib package allows us to add our own controller as a plugin into the controller manager
$ roscd ros_pkg_tutorials $ roscreate-pkg my_controller_pkg pr2_controller_interface pr2_mechanism_model pluginlib $ roscd my_controller_pkg
And let's already build all the dependencies of our new package:
$ rosmake
The code
Now, inside our new package, create the directory include, then include/my_controller_pkg, fire up your editor, create a file called include/my_controller_pkg/my_controller_file.h and copy paste the following code into this file: Ustaw numery liniiUstaw numery linii
1 2 3 4 5 6 #include #include namespace my_controller_ns{ class MyControllerClass: public pr2_controller_interface::Controller
7 8 9 10 11 12 13 14 15 16 17 18 19
{ private: