simple_marker.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 """
4 Copyright (c) 2011, Willow Garage, Inc.
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
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.
18 
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.
30 """
31 
32 from __future__ import print_function
33 
34 import rospy
35 
37 from visualization_msgs.msg import *
38 
39 def processFeedback(feedback):
40  p = feedback.pose.position
41  print(feedback.marker_name + " is now at " + str(p.x) + ", " + str(p.y) + ", " + str(p.z))
42 
43 if __name__=="__main__":
44  rospy.init_node("simple_marker")
45 
46  # create an interactive marker server on the topic namespace simple_marker
47  server = InteractiveMarkerServer("simple_marker")
48 
49  # create an interactive marker for our server
50  int_marker = InteractiveMarker()
51  int_marker.header.frame_id = "base_link"
52  int_marker.name = "my_marker"
53  int_marker.description = "Simple 1-DOF Control"
54 
55  # create a grey box marker
56  box_marker = Marker()
57  box_marker.type = Marker.CUBE
58  box_marker.scale.x = 0.45
59  box_marker.scale.y = 0.45
60  box_marker.scale.z = 0.45
61  box_marker.color.r = 0.0
62  box_marker.color.g = 0.5
63  box_marker.color.b = 0.5
64  box_marker.color.a = 1.0
65 
66  # create a non-interactive control which contains the box
67  box_control = InteractiveMarkerControl()
68  box_control.always_visible = True
69  box_control.markers.append( box_marker )
70 
71  # add the control to the interactive marker
72  int_marker.controls.append( box_control )
73 
74  # create a control which will move the box
75  # this control does not contain any markers,
76  # which will cause RViz to insert two arrows
77  rotate_control = InteractiveMarkerControl()
78  rotate_control.name = "move_x"
79  rotate_control.interaction_mode = InteractiveMarkerControl.MOVE_AXIS
80 
81  # add the control to the interactive marker
82  int_marker.controls.append(rotate_control);
83 
84  # add the interactive marker to our collection &
85  # tell the server to call processFeedback() when feedback arrives for it
86  server.insert(int_marker, processFeedback)
87 
88  # 'commit' changes and send to all clients
89  server.applyChanges()
90 
91  rospy.spin()
92 
interactive_markers::interactive_marker_server::InteractiveMarkerServer
msg
interactive_markers::interactive_marker_server
simple_marker.processFeedback
def processFeedback(feedback)
Definition: simple_marker.py:39


interactive_marker_tutorials
Author(s): David Gossow
autogenerated on Wed Mar 2 2022 01:13:07