4 Copyright (c) 2011, Willow Garage, Inc.
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15 * Neither the name of the Willow Garage, Inc. nor the names of its
16 contributors may be used to endorse or promote products derived from
17 this software without specific prior written permission.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 POSSIBILITY OF SUCH DAMAGE.
32 from __future__
import print_function
49 handle = feedback.menu_entry_id
50 state = menu_handler.getCheckState( handle )
52 if state == MenuHandler.CHECKED:
53 menu_handler.setCheckState( handle, MenuHandler.UNCHECKED )
54 rospy.loginfo(
"Hiding first menu entry")
55 menu_handler.setVisible( h_first_entry,
False )
57 menu_handler.setCheckState( handle, MenuHandler.CHECKED )
58 rospy.loginfo(
"Showing first menu entry")
59 menu_handler.setVisible( h_first_entry,
True )
61 menu_handler.reApply( server )
62 rospy.loginfo(
"update")
67 menu_handler.setCheckState( h_mode_last, MenuHandler.UNCHECKED )
68 h_mode_last = feedback.menu_entry_id
69 menu_handler.setCheckState( h_mode_last, MenuHandler.CHECKED )
71 rospy.loginfo(
"Switching to menu entry #" + str(h_mode_last))
72 menu_handler.reApply( server )
79 marker.type = Marker.CUBE
80 marker.scale.x = msg.scale * 0.45
81 marker.scale.y = msg.scale * 0.45
82 marker.scale.z = msg.scale * 0.45
91 control = InteractiveMarkerControl()
92 control.always_visible =
True
93 control.markers.append(
makeBox(msg) )
94 msg.controls.append( control )
99 int_marker = InteractiveMarker()
100 int_marker.header.frame_id =
"base_link"
101 int_marker.pose.position.y = -3.0 * marker_pos
108 int_marker.name = name
110 control = InteractiveMarkerControl()
112 control.interaction_mode = InteractiveMarkerControl.BUTTON
113 control.always_visible =
True
115 control.markers.append(
makeBox( int_marker ) )
116 int_marker.controls.append(control)
118 server.insert( int_marker )
121 rospy.loginfo(
"The deep sub-menu has been found.")
124 global h_first_entry, h_mode_last
125 h_first_entry = menu_handler.insert(
"First Entry" )
126 entry = menu_handler.insert(
"deep", parent=h_first_entry)
127 entry = menu_handler.insert(
"sub", parent=entry );
128 entry = menu_handler.insert(
"menu", parent=entry, callback=deepCb );
130 menu_handler.setCheckState( menu_handler.insert(
"Show First Entry", callback=enableCb ), MenuHandler.CHECKED )
132 sub_menu_handle = menu_handler.insert(
"Switch" )
135 h_mode_last = menu_handler.insert( s, parent=sub_menu_handle, callback=modeCb )
136 menu_handler.setCheckState( h_mode_last, MenuHandler.UNCHECKED)
138 menu_handler.setCheckState( h_mode_last, MenuHandler.CHECKED )
140 if __name__==
"__main__":
141 rospy.init_node(
"menu")
150 menu_handler.apply( server,
"marker1" )
151 menu_handler.apply( server,
"marker2" )
152 server.applyChanges()