Acutally the link the QA mentions has the right-click menu in line 266.
Overall your marker menu can be applied like:
//pointer to a dynamically allocated object server
boost::shared_ptr < interactive_markers::InteractiveMarkerServer > server;
server.reset(new
interactive_markers::InteractiveMarkerServer
("interactive_markers", "", false));
ros::Duration(0.1).sleep(); // wait till fully init.
// apply right-click menu
interactive_markers::MenuHandler menuHandler;
menuHandler.insert("Start Steering", &processMarkerFeedback);// callback function
menuHandler.insert("Stop Steering", &processMarkerFeedback);
menuHandler.apply(*server, myMarker.name);// marker of any type
the callback function looks like line 123,
// The current marker postion is published as transform
// more feedback extraction on .../interactive_marker_tutorials/src/basic_controls.cpp
void processMarkerFeedback(const
vm::InteractiveMarkerFeedbackConstPtr & feedbackPtr)
{
int eventType = feedbackPtr->event_type;
std::string markerName = feedbackPtr->marker_name;
if (eventType == 2 && feedbackPtr->mouse_point_valid) { // MENU_SELECT
ROS_INFO_STREAM("interactive_marker_node::processMarkerFeedback:" << markerName << " id:" << feedbackPtr->menu_entry_id);
} else {}//... other eventTypes
}
Originally posted by user23fj239 with karma: 748 on 2016-07-25
This answer was NOT ACCEPTED on the original site
Post score: 1