Pointcloud2 not displayed, NaN values for position - ros3djs

asked 2021-03-22 09:50:49 -0500

SpaceTime gravatar image

updated 2021-03-22 11:40:23 -0500

Hello everyone,

I wanted to look into visualisation of robotic data in the web browser and found ros3djs which is part of the robot web tools. I am especially interested in displaying a pointcloud. For testing purposes I used a rosbag recorded on an xtion camera and played it in a loop.

The ros3djs repository has an example for visualizing a point cloud which you can find here: https://github.com/RobotWebTools/ros3...

I thought, that I only had to change two lines: namely the topic used and the different name for the fixed_frame.

var tfClient = new ROSLIB.TFClient({
  ros : ros,
  angularThres : 0.01,
  transThres : 0.01,
  rate : 10.0,
  // fixedFrame : '/camera_link'
  fixedFrame : '/base_link'
});

var cloudClient = new ROS3D.PointCloud2({
    ros: ros,
    tfClient: tfClient,
    rootObject: viewer.scene,
    // topic: '/camera/depth_registered/points',
    topic: '/xtion/depth_registered/points',
    material: { size: 0.05, color: 0xff00ff }
});

If I start all the things from the commandline that are mentioned in the example and then open the page in the browser, I see the "canvas" but no pointcloud. I have tested displaying the pointcloud in rviz and there it works just fine. When opening the console, I get the error:

THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values. This is true. If I take a look into the object, it says that "position" is an array with 30000 float32 values which are all NaN.

UPDATE: The NaN values are returned from the following lines with the getFloat

for(var i = 0; i < n; i++){ base = i * pointRatio * msg.point_step; this.points.positions.array[3i ] = dv.getFloat32(base+x, littleEndian); this.points.positions.array[3i + 1] = dv.getFloat32(base+y, littleEndian); this.points.positions.array[3*i + 2] = dv.getFloat32(base+z, littleEndian);

if(this.points.colors){
    color = this.points.colormap(this.points.getColor(dv,base,littleEndian));
    this.points.colors.array[3*i    ] = color.r;
    this.points.colors.array[3*i + 1] = color.g;
    this.points.colors.array[3*i + 2] = color.b;
}

}

Is there something wrong with the offset maybe? I haven't changed anything here from the original file of the repo.

What could be going wrong here so that the values are received as NaN? Is the pointcloud maybe too big?

The only similar issue I found online was this one: https://github.com/RobotWebTools/ros3... which refers to an issue about the pointcloud being delayed. I don't think, mine is delayed. I waited a few minutes and nothing was displayed. The comment on https://github.com/osrf/rvizweb/issue... was mentioned especially as well.

However I am unclear what I should do according to this comment or how I should proceed in general? I am glad for any hint! Please tell me if I forgot to put some important information here.

edit retag flag offensive close merge delete