Hi all, this is my callback
void get_point_cloud(const sensor_msgs::PointCloud2 &img) {
sensor_msgs::PointCloud2 img1;
tf::TransformListener listener;
tf::StampedTransform transform;
listener.lookupTransform(img.header.frame_id, "odom", ros::Time(0), transform);
pcl_ros::transformPointCloud("odom", img, img1, listener);
pcl::PointCloud::Ptr cloud(new pcl::PointCloud);
pcl::fromROSMsg(img1, *cloud);
cv::Mat frame;
if (cloud->isOrganized()) {
frame = cv::Mat(cloud->height, cloud->width, CV_8UC3);
for (int h = 0; h < frame.rows; h++) {
for (int w = 0; w < frame.cols; w++) {
pcl::PointXYZRGBA point = cloud->at(w, h);
if (point.y > 0) {
Eigen::Vector3i rgb = point.getRGBVector3i();
frame.at(h, w)[0] = rgb[2];
frame.at(h, w)[1] = rgb[1];
frame.at(h, w)[2] = rgb[0];
} else {
frame.at(h, w)[0] = 0;
frame.at(h, w)[1] = 0;
frame.at(h, w)[2] = 0;
}
}
}
}
cv::imshow("frame", frame);
cv::waitKey(1);
}
I want to use PointCloud2 as laser for my slam package, when I try to convert `img` from `camera_depth_optical_frame` frame to `img1` from `odom` frame and then apply that coordinates on my Map
When I run this code I got
terminate called after throwing an instance of 'tf2::LookupException'
what(): "camera_depth_optical_frame" passed to lookupTransform argument target_frame does not exist.
what is the problem?? I can see `odom` frame in tf tree!!
And my other problem is:
when I don't use tf Transform and try to use only `img` data (from camera_depth_optical_frame), some points has `point.y < 0`!!!!
what does it means?? that points must has `point.y` bigger that 0!!!
↧