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

How to highlight points in point cloud on mouse over?

asked 2015-08-13 03:22:31 -0500

VitaliyProoks gravatar image

updated 2015-08-17 03:29:27 -0500

Hello,

Is it possible in RViz to highlight a single point in a point cloud and then publish its coordinate?

Edit: By highlighting I mean get coordinates of the point on mouse moved.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-08-13 15:53:04 -0500

William gravatar image

You can select a single point in the point cloud with the selection tool, and you can publish a point which you click on the screen, but I'm not sure you can do both. You might have to write an rviz plugin to accomplish this.

edit flag offensive delete link more
0

answered 2015-08-17 03:35:30 -0500

VitaliyProoks gravatar image

updated 2015-08-17 03:44:26 -0500

I found an answer how to do that. So there is a Point Tool in RViz which is implemented in files point_tool.h, point_tool.cpp. The event listener processMouseEvent captures any mouse event, and what we need to do is to select a point the same way as it is done in the Point Tool with the only difference that we do not listen events when the mouse pointer does not move. Here's the basic implementation of the callback:

int PointHighlightingTool::processMouseEvent(rviz::ViewportMouseEvent &event) {
  int flags = 0;

  // Check if mouse moved
  if ((event.x == event.last_x) && (event.y == event.last_y)) {
    return flags;
  }

  Ogre::Vector3 pos;
  bool success = context_->getSelectionManager()->get3DPoint( event.viewport, event.x, event.y, pos );

  if (success)  // A point is found
  {
    // Coordinates are stored in the `pos` variable and we can do anything we like with them from now on
    std::ostringstream s;
    s.precision(3);
    s << " [" << pos.x << "," << pos.y << ", " << pos.z << "]";
    ROS_INFO("3D Point %s", s.str().c_str());
  }

  return flags;
}
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2015-08-13 03:22:31 -0500

Seen: 698 times

Last updated: Aug 17 '15