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

How to detect when an interactive marker is selected?

asked 2013-08-16 08:03:52 -0600

danep gravatar image

updated 2013-08-16 08:20:26 -0600

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?

(note: originally posted at https://github.com/ros-visualization/rviz/issues/670)

EDIT: To clarify, based on responses in the Github issue- I want users to still be able to interact with the markers using the mouse. Whichever marker they clicked on most recently, I want to store as a pointer in my own plugin. I'll then call handle3DCursorEvent() on the marker to control it using the 3d device. My problem is just initially capturing and storing the pointer to the marker.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-08-16 08:24:34 -0600

danep gravatar image

It seems the 'brute force' answer would be to clone the rviz::InteractionTool, and have it also send mouse events to my plugin. It's just not ideal, since it requires users to select a different tool in Rviz, and it also means duplicating and tracking upstream code.

edit flag offensive delete link more

Comments

You could subclass InteractionTool and get the object that's under the mouse from focused_object_. See https://github.com/ros-visualization/rviz/blob/hydro-devel/src/rviz/default_plugin/tools/interaction_tool.h#L73

dgossow gravatar image dgossow  ( 2013-08-16 09:20:11 -0600 )edit

I guess that makes sense. However, when I try to create a derived class with InteractionTool as the base class, the plugin doesn't show up in Rviz. rospack plugins --attrib=plugin rviz does show it. Any ideas? See here

danep gravatar image danep  ( 2013-08-19 10:05:17 -0600 )edit

You need to set base_class_type="rviz::Tool" for RViz to find this.

dgossow gravatar image dgossow  ( 2013-08-19 15:21:39 -0600 )edit

Woohoo! Alright, I've got a new tool that behaves just like InteractionTool. I'll work on using focused_object_ like you suggested.

danep gravatar image danep  ( 2013-08-20 05:47:16 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-08-16 08:03:52 -0600

Seen: 1,196 times

Last updated: Aug 16 '13