## page was renamed from cob_calibration/Tutorials/Camera and Robot Calibration
## For instruction on writing tutorials
## http://www.ros.org/wiki/WritingTutorials
####################################
##FILL ME IN
####################################
## for a custom note with links:
## note = Currently this tutorial assumes you are using cob3-3
## for the canned note of "This tutorial assumes that you have completed the previous tutorials:" just add the links 
## note.0= [[cob_calibration/Tutorials/preparation|Prepare Care-O-bot 3 for calibration]]
## descriptive title for the tutorial
## title = Automatic Camera and Robot Calibration of Care-O-bot 3
## multi-line description to be displayed in search 
## description = This tutorial guides you through the automatic calibration of the cameras and kinematic components of the Care-O-bot 3.
## the next tutorial description (optional)
## next =
## links to next tutorial (optional)
## next.0.link=
## next.1.link=
## what level user is this tutorial for 
## level= AdvancedCategory
## keywords =
####################################

<<IncludeCSTemplate(TutorialCSHeaderTemplate)>>

<<TableOfContents(4)>>

=== Overview ===

This tutorial guides you through the automatic calibration of the cameras and kinematic components of the Care-O-bot 3. The calibration procedure is divided into two automated steps:

 1. '''Camera calibration:''' The stereo camera system of Care-O-bot is calibrated intrinsically.

 1. '''Kinematic robot calibration:''' This step performs extrinsic camera calibration (hand-eye calibration of the stereo camera and kinect) and estimates various kinematic parameters of the robot (position and orientation of arm and torso on the base of Care-O-bot). 



=== Prerequisites ===
 * roscore is running

 * Care-O-bot bringup software is running.

 * Cameras, head-axis, arm and torso are initialized and working.

 * Calibration pattern is attached to arm.

 * You created a temporary overlay of [[cob_calibration_data]]. The calibration results are stored in this unary stack. The overlay should be deleted again after the calibration process.



=== Running calibration ===

==== Collect data ====

start the data collection by calling 
 {{{
roslaunch cob_calibration_executive collect_robot_calibration_data.launch
}}}

This will start all needed nodes and services. The robot now moves to the sample positions calculated in step 6 of the configuration.

The progress can be seen by rostopic echo /calibration/data_collection/progress.

Wait until capture is finished (about 15 minutes) and stop it with CTRL-C. The bagfile with the measurement and the images for the camera calibration are stored in "/tmp/cal/".

==== Calibrate cameras ====

Stop bringup to speed up computation before starting the calibration.

Then execute to start the stereo camera calibration:
 {{{
roslaunch cob_camera_calibration calibrate_stereo.launch
}}}

The results will be stored in the calibration file specified in the "cameras.yaml" configuration file.

This step should take approximately 10 minutes.

For robots with only one calibrated camera this step is not required.

==== Calibrate robot ====

To calibrate the robot run:
{{{
roslaunch cob_robot_calibration run_robot_calibration.launch
}}}

The calculation takes about 15 minutes.

==== Update urdf ====

The following command updates the calibration offsets in the urdf:

{{{
roslaunch cob_robot_calibration update_calibration_urdf.launch
}}}

=== Verification of calibration result ===

 1. Restart bringup in order to use the new calibration result.

 1. Verify the calibration result with rviz by checking the kinect pointcloud while the arm with checkerboard is in front of the cameras. The point cloud should align with the simulated arm. You can also verify the position of the stereo cameras using rviz's Camera plugin to overlay RobotModel with camera image from both left and right camera.

 1. Remove the checkerboard from the arm and reattach the hand. (activate the emergency stop before attaching the schunk hand).

=== Commiting your results ===

 1. If the calibration result is satisfying commit the new calibration to git (cob_calibration_data) and push it to github. Create a pull request for ipa320/cob_calibration_data and ask your robot administrator to pull the new calibration to the robot for everybody.

 1. Once the pull request has been accepted and the calibration has been updated on the robot, you can remove your local overlay of cob_calibration_data.



## AUTOGENERATED DO NOT DELETE 
## TutorialCategory
## FILL IN THE STACK TUTORIAL CATEGORY HERE