[ros-users] Interpolating Point_Cloud

Radu Bogdan Rusu rusu at willowgarage.com
Fri Nov 26 18:35:15 UTC 2010


Nicolas, I'm not sure I understand what you're trying to do. You have two XYZ points coming from 2 laser measurements, 
and you want to put more points between them on the line that connects them?

I don't think that we have a node for this, as it's a very simple operation, but you could do something as silly as:

  ////////////////////////////////////////////////////////////////////////////////
  /** \brief Sample points on a line (formed from p1 and p2) using a given
    * resolution <res>
    * \param p1 the first point
    * \param p2 the second point
    * \param res the resolution of the line
    * \param pts the resultant points
    */
  int
    samplePointsOnLine (Point p1, Point p2, double res, PointCloud &pts)
  {
    Eigen3::Vector4f dp = p2.getVector4fMap () - p1.getVector4fMap ();
    // Compute the distance between the two points
    double dist = dp.norm ();
    dp.normalize ();

    Eigen3::Vector4f axis_x (1.0, 0.0, 0.0, 0.0), axis_y (0.0, 1.0, 0.0, 0.0), axis_z (0.0, 0.0, 1.0, 0.0);
    // Compute the axis increments
    double dx = res * dp.dot (axis_x);
    double dy = res * dp.dot (axis_y);
    double dz = res * dp.dot (axis_z);

    int nr_pts = dist / res;
    if (nr_pts < 1)
      return (0);

    pts.points.resize (nr_pts);
    pts.width = nr_pts; pts.height = 1;
    for (int m = 0; m < nr_pts; ++m)
    {
      pts.points[m].x = (m + 1) * dx + p1.x;
      pts.points[m].y = (m + 1) * dy + p1.y;
      pts.points[m].z = (m + 1) * dz + p1.z;
    }
    return (nr_pts);
  }


Cheers,
Radu.


On 11/26/2010 08:25 AM, Nicolás Alvarez Picco wrote:
> Hi!!
>
> I am working with LaserScan data which I have transformed into Point cloud, now I want to interpolate between two of
> that points, with a first order interpolation will be fine. The thing is that maybe there is node that make that
> interpolation. Someone knows about that??
>
> Thanks!!
>
> Nicolas
>
>
>
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users



More information about the ros-users mailing list