interactive.py
Go to the documentation of this file.
1 import roslib; roslib.load_manifest('easy_markers')
2 
3 from easy_markers.generator import MarkerGenerator
6 from visualization_msgs.msg import InteractiveMarkerControl
7 
8 TYPEDATA = {
9  'rotate_x': [1,1,0,0, InteractiveMarkerControl.ROTATE_AXIS],
10  'move_x' : [1,1,0,0, InteractiveMarkerControl.MOVE_AXIS],
11  'rotate_z': [1,0,1,0, InteractiveMarkerControl.ROTATE_AXIS],
12  'move_z' : [1,0,1,0, InteractiveMarkerControl.MOVE_AXIS],
13  'rotate_y': [1,0,0,1, InteractiveMarkerControl.ROTATE_AXIS],
14  'move_y' : [1,0,0,1, InteractiveMarkerControl.MOVE_AXIS]
15 }
16 
17 def default_callback(feedback):
18  print feedback
19 
21  def __init__(self, name="interactive_markers"):
24  self.mg.type = 1
25  self.mg.scale = [.25]*3
26  self.c = 0
27  self.markers = {}
28 
29 
30 
31  def makeMarker( self, callback=None, marker=None, pose=[0,0,0], controls=[],
32  fixed=False, name=None, frame="/map", description="", imode=0, rot=[0,0,0,1]):
33 
34  if marker is None:
35  marker = self.mg.marker()
36 
37  if callback is None:
38  callback = default_callback
39 
40  if name is None:
41  name = "control%d"%self.c
42  self.c += 1
43 
44  int_marker = InteractiveMarker()
45  int_marker.header.frame_id = frame
46  int_marker.pose.position.x = pose[0]
47  int_marker.pose.position.y = pose[1]
48  int_marker.pose.position.z = pose[2]
49  int_marker.pose.orientation.x = rot[0]
50  int_marker.pose.orientation.y = rot[1]
51  int_marker.pose.orientation.z = rot[2]
52  int_marker.pose.orientation.w = rot[3]
53  int_marker.scale = 1
54  int_marker.name = name
55  int_marker.description = description
56 
57  control = InteractiveMarkerControl()
58  control.always_visible = True
59  control.interaction_mode = imode
60  control.markers.append( marker )
61  int_marker.controls.append(control)
62 
63  for control_name in controls:
64  data = TYPEDATA[control_name]
65  control = InteractiveMarkerControl()
66  control.orientation.w = data[0]
67  control.orientation.x = data[1]
68  control.orientation.y = data[2]
69  control.orientation.z = data[3]
70  control.name = control_name
71  control.interaction_mode = data[4]
72  if fixed:
73  control.orientation_mode = InteractiveMarkerControl.FIXED
74  int_marker.controls.append(control)
75 
76  self.server.insert(int_marker, callback)
77  self.markers[name] = int_marker
78  self.server.applyChanges()
def makeMarker(self, callback=None, marker=None, pose=[0, controls=[], fixed=False, name=None, frame="/map", description="", imode=0, rot=[0)
Definition: interactive.py:32
def default_callback(feedback)
Definition: interactive.py:17
def __init__(self, name="interactive_markers")
Definition: interactive.py:21


easy_markers
Author(s): David V. Lu!!
autogenerated on Mon Jun 10 2019 15:48:46