34 from visualization_msgs.msg
import InteractiveMarkerFeedback
35 from visualization_msgs.msg
import MenuEntry
63 def insert(self, title, parent=None, command_type=MenuEntry.FEEDBACK, command="", callback=None):
64 handle = self.
doInsert(title, command_type, command, callback)
65 if parent
is not None:
68 parent_context.sub_entries.append(handle)
70 rospy.logerr(
"Parent menu entry " + str(parent) +
" not found.")
80 context.visible = visible
89 context.check_state = check_state
99 return context.check_state
105 def apply(self, server, marker_name):
106 marker = server.get(marker_name)
111 marker.menu_entries = list()
114 server.insert(marker, self.
processFeedback, InteractiveMarkerFeedback.MENU_SELECT)
125 for marker
in managed_markers:
126 success = self.
apply(server, marker)
and success
143 context.feedback_cb(feedback)
148 for handle
in handles_in:
151 if not context.visible:
153 entries_out.append(self.
makeEntry(context, handle, parent_handle))
157 rospy.logerr(
"Internal error: context handle not found! This is a bug in MenuHandler.")
162 menu_entry = MenuEntry()
164 menu_entry.title = context.title
165 elif context.check_state == self.
CHECKED:
166 menu_entry.title =
"[x] "+context.title
167 elif context.check_state == self.
UNCHECKED:
168 menu_entry.title =
"[ ] "+context.title
170 menu_entry.command = context.command
171 menu_entry.command_type = context.command_type
172 menu_entry.id = handle
173 menu_entry.parent_id = parent_handle
178 def doInsert(self, title, command_type, command, feedback_cb):
183 context.title = title
184 context.command = command
185 context.command_type = command_type
186 context.visible =
True 188 context.feedback_cb = feedback_cb
def insert(self, title, parent=None, command_type=MenuEntry.FEEDBACK, command="", callback=None)
Insert a new menu item.
Simple non-intrusive helper class which creates a menu and maps its entries to function callbacks...
def setCheckState(self, handle, check_state)
Specify if an entry is checked or can't be checked at all.
def apply(self, server, marker_name)
Copy current menu state into the marker given by the specified name & divert callback for MENU_SELECT...
def doInsert(self, title, command_type, command, feedback_cb)
def getTitle(self, handle)
Get the title for the given menu entry.
def getCheckState(self, handle)
Get the current state of an entry.
def reApply(self, server)
Re-apply to all markers that this was applied to previously.
def setVisible(self, handle, visible)
Specify if an entry should be visible or hidden.
def makeEntry(self, context, handle, parent_handle)
def processFeedback(self, feedback)
def pushMenuEntries(self, handles_in, entries_out, parent_handle)