Ask Your Question

Target pose from pointcloud [closed]

asked 2018-12-20 06:43:12 -0600

eymar13 gravatar image

updated 2018-12-20 08:52:25 -0600

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 cloud_hull. However, I'm lost at trying to get the pose as a geometry_msgs 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);
    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.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by eymar13
close date 2020-01-09 08:41:28.709674

1 Answer

Sort by ยป oldest newest most voted

answered 2018-12-20 07:26:30 -0600

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.

edit flag offensive delete link more


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.

eymar13 gravatar image eymar13  ( 2018-12-20 08:35:45 -0600 )edit

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.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-12-20 09:05:21 -0600 )edit

0 0 0 1 is the identity quaternion, equivalent to a RPY of (0 0 0)

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-12-20 09:06:14 -0600 )edit

Question Tools

1 follower


Asked: 2018-12-20 06:43:12 -0600

Seen: 432 times

Last updated: Dec 20 '18