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

Revision history [back]

click to hide/show revision 1
initial version

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 == 0) {         // KEEP_ALIVE
    // sent while dragging to keep up control of the marker
  } else if (eventType == 1) {  // POSE_UPDATE
    getFeedbackHandler(markerName)->updateFeedback(feedbackPtr);
  } else {}//...
}

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 == 0) 2 && feedbackPtr->mouse_point_valid) {         // KEEP_ALIVE
    // sent while dragging to keep up control of the marker
// MENU_SELECT
    ROS_INFO_STREAM("interactive_marker_node::processMarkerFeedback:" << markerName << " id:" << feedbackPtr->menu_entry_id);
  } else if (eventType == 1) {  // POSE_UPDATE
    getFeedbackHandler(markerName)->updateFeedback(feedbackPtr);
  } else {}//...
{}//... other eventTypes
}