ros-visualization / rviz

ROS 3D Robot Visualizer
BSD 3-Clause "New" or "Revised" License
847 stars 463 forks source link

How to detect when an interactive marker is selected? #670

Closed danepowell closed 11 years ago

danepowell commented 11 years ago

I'm writing an Rviz plugin that lets users control the most-recently touched interactive marker with a 3d mouse or haptic device. I'm trying to learn the Rviz / Ogre architecture as I go, so please bear with me.

The only problem I have is how to 'capture' the event where an interactive marker is selected. From within my plugin, I want to know when an interactive marker is clicked with the mouse, and then store the pointer to that marker so I can send events to it later.

I'm beginning to wonder if this is even possible. It seems that when the user clicks a marker, processMouseEvent() and handleMouseEvent() is fired through the chain of interaction_tool and interactive_marker_control. I'm not sure how an external plugin could hook into this to capture the marker.

Do you have any suggestions?

PS- for support requests like this (as opposed to bugs / feature requests), is the Github issue queue or some other forum (answers.ros.org) more appropriate? Thanks.

dgossow commented 11 years ago

Yeah, please put this up on answers.ros.org

hershwg commented 11 years ago

I suppose answers.ros.org is technically more appropriate, but I don't really care.

Do you know about InteractiveMarkerControl::handle3DCursorEvent()? We added some support for 3D input devices a while ago. I haven't used them myself, but I've seen demos of Razer Hydra controllers used with RViz to control interactive markers. ... oh, @dgossow knows about this. Hopefully he'll answer you on answers.ros.org. :)

dgossow commented 11 years ago

You will want to write a clone of the "Interact" tool of some sort. I would suggest to make this tool set the 2d mouse position based on the 3d mouse position as well, so you don't need to switch back and forth between your pointer devices.

Again, duplicate on answers.ros.org so everyone can benefit from this. I'll re-answer it there.

danepowell commented 11 years ago

Thanks, I reposted this at http://answers.ros.org/question/73357/how-to-detect-when-an-interactive-marker-is-selected/

@hershwg Right, once I actually know which marker is selected, then I was planning to send 3d position and orientation to it using handle3DCursorEvent().

danepowell commented 11 years ago

@dgossow That's actually where my work and Adam Leeper's diverge- I want to use the mouse (or some other 2d interface, eventually) to select the marker to be manipulated. I know this seems awkward at first glance because of the need to switch devices, but I have some pretty compelling reasons for it.