-
Notifications
You must be signed in to change notification settings - Fork 70
Tutorial
In order to use the WhyCon system there are four required steps:
- Calibrate your camera
- Print the planar target(s)
- Set the working coordinate frame or axis (optional)
- Perform tracking
This is a step-by-step tutorial, for a detailed reference of the supplied ROS nodes, please look at the reference.
An example roslaunch is included with whycon, for easier use. Please tune this to your needs.
The camera to be used needs to be calibrated. To do so, follow the corresponding tutorial for monocular calibration under ROS, using the camera_calibration package.
WhyCon needs to receive calibrated images from the image_proc module. You can run this on the command line with:
ROS_NAMESPACE=camera rosrun image_proc image_proc
The supplied roslaunch file already includes this line.
In order to track the desired targets, it is necessary to use the supplied pattern. Inside the patterns
directory, you will find .pdf (for easy printing) and .svg (for easy editing using Inkscape or similar) files.
For this tutorial print the circle.pdf
file, on a A4 sheet without scaling. This pattern has inner and outer diameters corresponding to default parameters for whycon. The actual target starts within the thin outer line. While this outer white area is not for detection, it ensures that some white space will be surrounding the actual ring, which helps detection at shallow angles.
It is posible to print the target at any scale and even the outer and inner diameters can be modified if necessary. Simply measure these after printing and pass the corresponding parameters to the system.
The coordinates of the detected patterns, without any transformation, are computed with respect of the camera coordinate frame (X,Y,Z = width,height,depth). In some cases this is fine and therefore the user need not to worry about setting a particular reference frame. However, it may be necessary to define a particular point in space as the origin of a user defined frame. In this case, WhyCon can be used to perform an initial axis setting step.
Note: currently this is only implemented for a planar working space (e.g. ground plane for ground robots). In this case, the associated coordinate transform translates camera-centered 3D coordinates into 2D coordinates on a user-defined frame. This also increases precision greatly, so it is recommended in this cases. User-defined 3D frame setting will soon be added.
For this step, you will need four targets already printed. This targets need to be placed defining a rectangle on the floor (or on the plane you will be using). To define the axis, run the set_axis node which will start capturing frames:
rosrun whycon set_axis
Once you have the patterns set, initiate the detection by issuing the following service call:
rosservice call /set_axis/set
You can see the results on the image published by this node. After succesful detection, the computed transform will be saved to a file named "axis.yml" by default.
After performing this step, stop the node. The patterns used for this step can be removed, otherwise they will be later tracked (which may not be desired).
Important: do not move the camera once axis are defined, the system assumes the camera is fixed in this case.
To initiate tracking, launch the whycon node and observe the detection results on the published image. Also, you can use rviz to visualize all results. To track one target you should run:
rosrun whycon whycon _targets:=1