ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

thanks for the answer.

i tried like this:

   geometry_msgs::PointStamped pt;
   geometry_msgs::PointStamped pt_transformed;
   pt.header = cloud_cluster->header;
   pt.point.x = point_x;
   pt.point.y = point_y;
   pt.point.z = point_z;

   tf::TransformListener listener;
   const std::string target_frame = "base_link";
   const std::string original_frame = "camera_rgb_optical_frame";
   const ros::Time time = ros::Time::now();
   listener.waitForTransform(target_frame, original_frame, time, ros::Duration(10.0));
   listener.transformPoint(target_frame, time, pt, original_frame, pt_transformed);

but i keep getting that the frame doesnt exist, although is then listed i the list of existing frames. that is the reason i tried with waitForTRansform, but it doesnt seem to take notice of it.

i tried with different frames, ros times, but nothing seems to work.

i tried to change the code to :

    tf::TransformListener listener;
    tf::StampedTransform transform;
    const std::string target_frame = "base_link";
    const std::string original_frame = "camera_rgb_optical_frame";
    const ros::Time time = ros::Time::now();
    listener.waitForTransform(target_frame, original_frame, time, ros::Duration(10.0));
    listener.lookupTransform(target_frame, original_frame, time, transform);


    goal_point_x=transform * point_x;
    goal_point_y=transform * point_y;
    goal_point_z=transform * point_z;

but then it says that the two frames are not connected

i also tried transforming the pointcloud resized to one point, but it also says that the frames doesnt exist, the code:

       cloud_cluster -> points.resize(1);

       tf::TransformListener listener;
       sensor_msgs::PointCloud2 pointCloud2;
       pcl::toROSMsg (*cloud_cluster, pointCloud2);
       sensor_msgs::PointCloud pointCloud;
       sensor_msgs::PointCloud pointCloudInFrame;
       sensor_msgs::convertPointCloud2ToPointCloud(pointCloud2,pointCloud);


       listener.waitForTransform("map", "camera_rgb_optical_frame", ros::Time(0), ros::Duration(50.0));
        listener.transformPointCloud("map",ros::Time(0),pointCloud,"camera_rgb_optical_frame", pointCloudInFrame);
       sensor_msgs::PointCloud2 pointCloud2InFrame;
      sensor_msgs::convertPointCloudToPointCloud2(pointCloudInFrame,pointCloud2InFrame);
       pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_cluster_in_frame (new pcl::PointCloud<pcl::PointXYZRGB>);
       pcl::fromROSMsg(pointCloud2InFrame,*cloud_cluster_in_frame);

thanks for the answer.

i tried like this:

   geometry_msgs::PointStamped pt;
   geometry_msgs::PointStamped pt_transformed;
   pt.header = cloud_cluster->header;
   pt.point.x = point_x;
   pt.point.y = point_y;
   pt.point.z = point_z;

   tf::TransformListener listener;
   const std::string target_frame = "base_link";
   const std::string original_frame = "camera_rgb_optical_frame";
   const ros::Time time = ros::Time::now();
   listener.waitForTransform(target_frame, original_frame, time, ros::Duration(10.0));
   listener.transformPoint(target_frame, time, pt, original_frame, pt_transformed);

but i keep getting that the frame doesnt exist, although is then listed i in the list of existing frames. that is the reason i tried with waitForTRansform, but it doesnt seem to take notice of it.

i tried with different frames, ros times, but nothing seems to work.

i tried to change the code to :

    tf::TransformListener listener;
    tf::StampedTransform transform;
    const std::string target_frame = "base_link";
    const std::string original_frame = "camera_rgb_optical_frame";
    const ros::Time time = ros::Time::now();
    listener.waitForTransform(target_frame, original_frame, time, ros::Duration(10.0));
    listener.lookupTransform(target_frame, original_frame, time, transform);


    goal_point_x=transform * point_x;
    goal_point_y=transform * point_y;
    goal_point_z=transform * point_z;

but then it says that the two frames are not connected

i also tried transforming the pointcloud resized to one point, but it also says that the frames doesnt dont exist, the code:

       cloud_cluster -> points.resize(1);

       tf::TransformListener listener;
       sensor_msgs::PointCloud2 pointCloud2;
       pcl::toROSMsg (*cloud_cluster, pointCloud2);
       sensor_msgs::PointCloud pointCloud;
       sensor_msgs::PointCloud pointCloudInFrame;
       sensor_msgs::convertPointCloud2ToPointCloud(pointCloud2,pointCloud);


       listener.waitForTransform("map", "camera_rgb_optical_frame", ros::Time(0), ros::Duration(50.0));
        listener.transformPointCloud("map",ros::Time(0),pointCloud,"camera_rgb_optical_frame", pointCloudInFrame);
       sensor_msgs::PointCloud2 pointCloud2InFrame;
      sensor_msgs::convertPointCloudToPointCloud2(pointCloudInFrame,pointCloud2InFrame);
       pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_cluster_in_frame (new pcl::PointCloud<pcl::PointXYZRGB>);
       pcl::fromROSMsg(pointCloud2InFrame,*cloud_cluster_in_frame);