I once did a dirty hack in rviz to republish the selected points, this was done in a hurry and not well. So what I did was : I hooked into the updateProperties method of the SelectionHandle rviz/src/selection/selection_handler.cpp. I felt this should be called everytime the selection changes.
You can then iterate over the bounding boxes and will get the center coordinates of the selected points in the currently set fixed_frame.
As I said, it's dirty, doesn't get you RGB but only XYZ, but maybe it's of help for you.
A cleaner way would be to create Interactive Markers to select and area and then in an external node that gets the coordinates of the markes and the scan in, cut out the points yourself and republish/save them. Of course this will be hard if you want to add/remove from the selection with modifier keys, therefor i also hope we will one day get a feature like this built into rviz.
int publish_counter = 0;
void SelectionHandler::updateProperties()
{
V_Property::iterator it = properties_.begin();
V_Property::iterator end = properties_.end();
for (; it != end; ++it)
{
propertyChanged(*it);
}
ROS_INFO("boxes LENGTH %i", boxes_.size());
M_HandleToBox::iterator iit = boxes_.begin();
M_HandleToBox::iterator iend = boxes_.end();
publish_counter++;
// you dont want to take each update since updateProperties seems to be called at each frame
if (publish_counter % 20 == 0)
{
std::vector<Ogre::Vector3> pts;
for (; iit != iend; ++iit)
{
Ogre::WireBoundingBox *box = (*iit).second.second;
Ogre::AxisAlignedBox aabb = box->getBoundingBox();
Ogre::Vector3 center = aabb.getCenter();
pts.push_back(center);
// here we get the Points, the coordinate system differs between ogre and ros:
//ROS_INFO("CENTER: %f %f %f", -center.z, -center.x, center.y);
}
//I made a little class SelectionPublisher that would convert to a
// PointCloud2 MSG and publish it, took it out here
//SelectionPublisher::publish(pts);
}
}