RobotWebTools / ros3djs

3D Visualization Library for use with the ROS JavaScript Libraries
https://robotwebtools.github.io/ros3djs
Other
369 stars 216 forks source link

PointCloud2 is not displayed correctly #249

Open cmperezg opened 5 years ago

cmperezg commented 5 years ago

Hello I've built an app to display sensor data from a robot, but I can't get PointClouds to display correctly. LaserScans work without issue, so I'm quite sure the structure of my code is fine. This is the configuration I am trying to display:

{
        "type" : "Grid",  
        "config" : {
            "size" : 2,
            "color" : "#707070",
            "lineWidth" : 0.01
        }
    },
    {
        "type" : "PointCloud2",  
        "config" : {
            "topic" : "/camera_left/depth/points",
            "material" : { "size": 0.3, "color": "#e8a010" }
        }
    },
    {
        "type" : "PointCloud2",  
        "config" : {
            "topic" : "/camera_right/depth/points",
            "material" : {"size": 0.3, "color": "#e87c10" }
        }
    }

The tfClient is added later, and the config is handled by a parser.

However, the point cloud is displayed very weirdly. here is a screenshot:

ros3d_pointcloud

Here is an rviz screenshot of the same rosbag playing, subscribing to the exact same topics: rviz_pintcloud

Why is it being flattened out this way? Am I missing something in the configuration? Is it even possible to display more than one point cloud at once? I had no issues displaying several laser scans. After a few seconds this starts to lag like crazy too, but that is a separate issue and I see there is a ticket for it already.

Any help with this issue would be greatly appreciated.

mvollrath commented 5 years ago

Can you paste the contents of the "fields" (PointField list) for a frame of this cloud? We've seen issues with some non-standard field layouts.

cmperezg commented 5 years ago

Hi @mvollrath , thanks for your reply.

Here are the fields for a frame:

- 
  name: "x"
  offset: 0
  datatype: 7
  count: 1
- 
  name: "y"
  offset: 4
  datatype: 7
  count: 1
- 
  name: "z"
  offset: 8
  datatype: 7
  count: 1
---
cmperezg commented 5 years ago

This was not a bug. The problem was that I was not aware that a point limit was being set by default. setting max_pts to 200000 fixed the problem for me.

Kad91 commented 5 years ago

Another question About PointCloud2. It looks like that when max_pts (name it N) is selected, only the N first points are displayed. Is there a way to display N points choosing them ( for example every 2 points ) ?

mvollrath commented 5 years ago

@Kad91 Use pointRatio for that kind of subsampling.