Tree frames tf
Hi,
This is my scenario:
In a node I publish the webcam image and retrieve the coordinates x,y when the user clicks on the screen. After I publish the coordinates.
void my_mouse_callback( int event, int x, int y, int flags, void* param ){
switch( event ){
case CV_EVENT_MOUSEMOVE:
break;
case CV_EVENT_LBUTTONDOWN:
break;
case CV_EVENT_LBUTTONUP:
//publicamos x e y
geometry_msgs::PointStamped pixel;
pixel.header.frame_id = "webcam";
pixel.header.stamp = ros::Time();
pixel.point.x = x;
pixel.point.y = y;
pixel.point.z = 0.0;
pub.publish(pixel);
break;
}
}
In the other node I subscribe to the coordinates and I calculate the ray of pixel with projectPixelTo3dRay().
void point_callback(const geometry_msgs::PointStampedConstPtr& p){
tf::TransformListener listener;
cv::Point2d pixel(p->point.x,p->point.y);
ROS_INFO("Pixel (%.f,%.f)",pixel.x,pixel.y);
cv::Point3d ray=model.projectPixelTo3dRay(pixel);
ROS_INFO("ray.x: %.5f ray.y: %.5f ray.z: %.5f\n",ray.x,ray.y,ray.z);
}
As the camera is on the table, I want to calculate 3d point in the world with Z=0. I want to use tf, but do not know how to create the tree to make the transformations.
What tree should I create?
World-->base_camera-->optic_centre
World-->camera
...
Thanks