Target pose from pointcloud
Hi, I'm using ROS kinetic and PCL to find a target point. The aim is to use moveit to move to the target point/pose. I used pcl to create a concave hull and as shown in the code below, I publish the tf frame of the first point in the cloudhull. However, I'm lost at trying to get the pose as a geometrymsgs type or valid format for path planning in moveit. I can visualize the frame and get the coordinates, I want to know how to convert to a PoseStamped or PointStamped so i can use the point as a goal.
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_hull (new pcl::PointCloud<pcl::PointXYZ>);
pcl::ConcaveHull<pcl::PointXYZ> chull;
chull.setInputCloud (cloud_projected);
chull.setAlpha (0.1);
chull.reconstruct (*cloud_hull);
static tf::TransformBroadcaster br;
tf::Transform part_transform;
part_transform.setOrigin( tf::Vector3(cloud_hull->at(1).x, cloud_hull->at(1).y, cloud_hull->at(1).z) );
tf::Quaternion q;
q.setRPY(0, 0, 0);
part_transform.setRotation(q);
br.sendTransform(tf::StampedTransform(part_transform, ros::Time::now(), world_frame, "Potshell_outline"));
Here is an answer I was hoping to use, but I'm not sure how to get the header of the cloud_hull.
geometry_msgs::PointStamped pt;
geometry_msgs::PointStamped pt_transformed;
pt.header = myCloud->header;
pt.point.x = myCloud->points[1].x;
pt.point.y = myCloud->points[1].y;
pt.point.z = myCloud->points[1].z;
tf::TransformListener listener;
listener.transformPoint("target_frame", pt, pt_transformed);
if i use pt.header=cloud_hull->header;
I get no known conversion from pcl::PCLHeader
to std_msgs::Header_
Any help would be highly appreciated. In short, want to get the point coordinates in the cloud_hull as a PoseStamped
message to set as a target.
Thanks.
Asked by eymar13 on 2018-12-20 07:43:12 UTC
Answers
Technically a Point is not a Pose, it doesn't define any orientation information.
If you're happy to set a fixed orientation then this is do-able. You'll be better off creating the pose message directly, instead of creating a transform intermediary.
Regarding the header problem, you can't copy the whole header because, as you've found out, they are different formats. You'll need to copy the frame_id
member of the headers by itself. These are both std::string
objects so the copy will be fine.
Hope this helps.
Asked by PeteBlackerThe3rd on 2018-12-20 08:26:30 UTC
Comments
Thanks for the answer! Yes, I know the TF isn't necessary, but I'm not sure either how to create the pose in a format I can use to set the point as a target. For now, I just want that point's coordinates and then set the orientation by myself.
Asked by eymar13 on 2018-12-20 09:35:45 UTC
Have a look at the pose msg definition. You can set the XYZ of point for the position member and 0 0 0 1 for the orientation member.
Asked by PeteBlackerThe3rd on 2018-12-20 10:05:21 UTC
0 0 0 1 is the identity quaternion, equivalent to a RPY of (0 0 0)
Asked by PeteBlackerThe3rd on 2018-12-20 10:06:14 UTC
Comments