RobotLocomotion / drake

Model-based design and verification for robotics.
https://drake.mit.edu
Other
3.35k stars 1.27k forks source link

Meshcat pointcloud isn't visible in 2D render mode (orthographic projection) #17630

Open RussTedrake opened 2 years ago

RussTedrake commented 2 years ago

What happened?

Running the following code:

  geometry::Meshcat meshcat;
  meshcat.Set2dRenderMode(math::RigidTransformd(Eigen::Vector3d{0, 0, 1}), -2,
                          2, -2, 2);
  perception::PointCloud test_cloud(4);
  // clang-format off
  test_cloud.mutable_xyzs() << 0, 1, 1, 0,
                          1, 1, 0, 0,
                          0, 0, 0, 0;
  // clang-format on
  meshcat.SetObject("Box corners", test_cloud, 0.1, Rgba(0, 1, 0));
  meshcat.SetLine("Box", test_cloud.xyzs().cast<double>(), 1.0, Rgba(1, 0, 0));
  std::cout << "[Press RETURN to continue]." << std::endl;
  std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

Results in meshcat showing red lines in the intended box location, but no green points. Commenting out the Set2dRenderMode line results in the visualization appearing as expected.

Frustratingly, the meshcat_manual_test does cover this case, and the point cloud looks fine in the perspective projection.

I'm not sure if Drake is responsible, or meshcat, or three.js, etc. But I'll open this for awareness and tracking.

Version

No response

What operating system are you using?

Google Chrome on Ubuntu 20.04.

What installation option are you using?

Building from source (on master).

Relevant log output

No response

AlexandreAmice commented 1 year ago

Hitting this today. Is there any recommended quick fix?

jwnimmer-tri commented 1 year ago

I have no experience here, but this comment caught my eye:

Frustratingly, the meshcat_manual_test does cover this case, and the point cloud looks fine in the perspective projection.

The manual test has this:

    perception::PointCloud cloud(
        kPoints, perception::pc_flags::kXYZs | perception::pc_flags::kRGBs);

I wonder if adding the RGBs per-point would be some kind of a work-around? Or in general, trying to figure out what the test is doing that works, different from the example up above.