User Tools

Site Tools


teaching:se-kiba:manipulation-assignment:joint-space-controller

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
teaching:se-kiba:manipulation-assignment:joint-space-controller [2013/05/13 12:56] – [Getting a command inside] bartelsgteaching:se-kiba:manipulation-assignment:joint-space-controller [2016/05/19 09:19] (current) – external edit 127.0.0.1
Line 8: Line 8:
  
   * Create a new package for our controllers called iai_seminar_manipulation_controllers. Make sure it depends on the necessary pr2-interface packages.   * Create a new package for our controllers called iai_seminar_manipulation_controllers. Make sure it depends on the necessary pr2-interface packages.
-  * Create a new h-file for the controller in a suitable include-sub-directory, and add the minimally necessary function headers to comply with the controller interface. Choose a fitting name for the controller;)+  * Copy IAISeminarMultiJointPositionController.h for the controller in a suitable include-sub-directory.
   * Create the corresponding cpp-file in src, and add empty implementations for the functions declared in the h-file.   * Create the corresponding cpp-file in src, and add empty implementations for the functions declared in the h-file.
   * Add our still empty controller as a __regular__ library (NOT a controller plugin library) to the CMakeLists, and try compiling.   * Add our still empty controller as a __regular__ library (NOT a controller plugin library) to the CMakeLists, and try compiling.
Line 72: Line 72:
 ==== Adding a launch-file ==== ==== Adding a launch-file ====
 We will now add a launch-file to start our controllers automatically: We will now add a launch-file to start our controllers automatically:
-  * From the materials-directory, copy the file pr2_multi_joint_position_controllers.yaml into your launch directory.+  * From the materials-directory, copy the file pr2_multi_joint_position_controllers.yaml into the config directory of our controllers package.
   * Create a new launch-file with a name sounding like it starts the joint position controllers on the pr2.   * Create a new launch-file with a name sounding like it starts the joint position controllers on the pr2.
   * In this launch-file, Load the parameters given in the yaml-file.   * In this launch-file, Load the parameters given in the yaml-file.
Line 106: Line 106:
  
   * implement the command_callback to copy the new command from the msg inside our controller (using a double buffer and the mutex defined in the h-file)   * implement the command_callback to copy the new command from the msg inside our controller (using a double buffer and the mutex defined in the h-file)
-  * in the update, always read the current command from the double buffer (also guarded by the mutex), and copy the buffered command into the internal position_command_ +  * in the update, always read the current command from the double buffer (also guarded by the mutex), and copy the buffered command into the internal position_command_. Hint: Implement and use the method copy_from_command_buffer for this. It is supposed to be atomic... 
-  * +  * You can test your code by again echoing the state-topic of the controller and sending a new command from the console: 
 <code> <code>
 $ rostopic pub /l_arm_iai_joint_position_controller/command std_msgs/Float64MultiArray '{data: [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6]}' $ rostopic pub /l_arm_iai_joint_position_controller/command std_msgs/Float64MultiArray '{data: [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6]}'
Line 113: Line 114:
 ==== Using PIDs ==== ==== Using PIDs ====
  
 +For doing the actual control we will use the PID-controller implementation provided by Willow Garage. The h-file already declares a vector of such controllers. 
 +
 +  * In the init function: Create and push a new PID for every joint to this internal vector. 
 +  * Also in the init function: read the PID gains from the namespace of the controller. The yaml-file loaded in our launch-file already loads the gains onto the parameter server. Hint: The [[http://ros.org/doc/groovy/api/control_toolbox/html/classcontrol__toolbox_1_1Pid.html|PID class]] has a very useful init-function that reads the gain parameters from a given namespace. Try using it.
 +  * Throw a ROS-error if loading of the gains failed. This will warn you of initialization errors.
 ==== Filling in start ==== ==== Filling in start ====
  
-==== Doing something meaningful in stop ====+Now, we will fill the start-hook: 
 +  * Reset our double buffer for the command to something useful. 
 +  * Reset the PID (not the gains, though). 
 +  * Remember the starting time. Hint: You can get it from the [[http://www.ros.org/doc/api/pr2_mechanism_model/html/classpr2__mechanism__model_1_1RobotState.html|robot interface]]. 
 + 
  
 ==== Closing the loop ==== ==== Closing the loop ====
  
 +Finally, we will calculate the actual feedback control:
 +  * get the current time from the robot, calculate some delta-time. and remember the current time for the next control cycle
 +  * still: copy in the command from the double buffer
 +  * for every joint: calculate the error between actual and commanded position
 +  * for every joint: feed the error to the pid-controllers, and command their efforts to the joints of the robot
 +  * You can peek again [[http://ros.org/wiki/pr2_mechanism/Tutorials/Writing%20a%20realtime%20joint%20controller|here]].
 +  * As a last step: keep on publishing the current state of the controller.
 ==== Using our controller from ==== ==== Using our controller from ====
 +
 +TBD.
teaching/se-kiba/manipulation-assignment/joint-space-controller.1368449818.txt.gz · Last modified: 2016/05/19 09:18 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki