7 import roslib; roslib.load_manifest(
'velma_common')
12 from std_msgs.msg
import ColorRGBA
18 import tf_conversions.posemath
as pm
22 from velma_common
import *
23 from rcprg_ros_utils
import exitError
26 return PyKDL.Wrench(PyKDL.Vector(lx,ly,lz), PyKDL.Vector(rx,ry,rz))
34 self.
server = InteractiveMarkerServer(
'int_markers_cimp_' + self.
prefix)
50 self.
hide.interaction_mode = InteractiveMarkerControl.BUTTON
51 self.
hide.name =
'button_hide' 55 self.
server.applyChanges();
59 self.
server.applyChanges();
63 int_position_marker = InteractiveMarker()
64 int_position_marker.header.frame_id =
'torso_base' 65 int_position_marker.name = self.
prefix+
'_arm_position_marker' 66 int_position_marker.scale = 0.2
67 int_position_marker.pose = pm.toMsg(T_B_T)
77 box.interaction_mode = InteractiveMarkerControl.BUTTON
79 int_position_marker.controls.append( box )
81 self.
server.applyChanges();
97 if ( feedback.event_type == InteractiveMarkerFeedback.BUTTON_CLICK
and feedback.control_name ==
"button_hide" ):
106 if ( feedback.marker_name == self.
prefix+
'_arm_position_marker' )
and ( feedback.event_type == InteractiveMarkerFeedback.BUTTON_CLICK )
and ( feedback.control_name ==
"button" ):
107 T_B_Td = pm.fromMsg(feedback.pose)
108 self.
p = pm.toMsg(T_B_Td)
113 self.
velma.moveCartImp(self.
prefix, [T_B_Td], [5.0],
None,
None, [imp], [5.0], PyKDL.Wrench(PyKDL.Vector(5,5,5), PyKDL.Vector(5,5,5)), start_time=0.5, damping=PyKDL.Wrench(PyKDL.Vector(dmp, dmp, dmp),PyKDL.Vector(dmp, dmp, dmp)))
117 marker.type = Marker.SPHERE
119 marker.pose.position = position
121 control = InteractiveMarkerControl()
122 control.always_visible =
True;
123 control.markers.append( marker );
128 marker.type = Marker.CUBE
130 marker.pose.position = position
131 marker.color = ColorRGBA(0.5,0.5,0.5,1)
132 control = InteractiveMarkerControl()
133 control.always_visible =
True;
134 control.markers.append( marker );
139 markerX.type = Marker.ARROW
140 markerX.scale = scale
141 markerX.pose.position = position
142 ori = quaternion_about_axis(0, [0, 1 ,0])
143 markerX.pose.orientation = Quaternion(ori[0], ori[1], ori[2], ori[3])
144 markerX.color = ColorRGBA(1,0,0,1)
146 markerY.type = Marker.ARROW
147 markerY.scale = scale
148 markerY.pose.position = position
149 ori = quaternion_about_axis(math.pi/2.0, [0, 0 ,1])
150 markerY.pose.orientation = Quaternion(ori[0], ori[1], ori[2], ori[3])
151 markerY.color = ColorRGBA(0,1,0,1)
153 markerZ.type = Marker.ARROW
154 markerZ.scale = scale
155 markerZ.pose.position = position
156 ori = quaternion_about_axis(-math.pi/2.0, [0, 1 ,0])
157 markerZ.pose.orientation = Quaternion(ori[0], ori[1], ori[2], ori[3])
158 markerZ.color = ColorRGBA(0,0,1,1)
159 control = InteractiveMarkerControl()
160 control.always_visible =
True;
161 control.markers.append( markerX );
162 control.markers.append( markerY );
163 control.markers.append( markerZ );
168 marker.type = Marker.SPHERE
170 marker.pose.position = position
171 marker.pose.orientation = Quaternion(0,0,0,1)
173 control = InteractiveMarkerControl()
174 control.always_visible =
True;
175 control.markers.append( marker );
179 control = InteractiveMarkerControl()
180 control.orientation_mode = InteractiveMarkerControl.FIXED
181 if mode == InteractiveMarkerControl.ROTATE_AXIS:
182 control.name =
'rotate_' + axis;
183 elif mode == InteractiveMarkerControl.MOVE_AXIS:
184 control.name =
'move_' + axis;
186 raise Exception(
'Wrong axis mode: "{}"'.format(mode))
188 control.orientation = Quaternion(1,0,0,1)
190 control.orientation = Quaternion(0,1,0,1)
192 control.orientation = Quaternion(0,0,1,1)
194 raise Exception(
'Wrong axis name: "{}"'.format(axis))
195 control.interaction_mode = mode
198 if __name__ ==
"__main__":
200 rospy.init_node(
'int_markers_cimp', anonymous=
False)
204 velma = VelmaInterface()
205 print "waiting for init..." 210 print "Switch to cart_imp mode (no trajectory)..." 211 if not velma.moveCartImpRightCurrentPos(start_time=0.2):
213 if velma.waitForEffectorRight() != 0:
216 if not velma.moveCartImpLeftCurrentPos(start_time=0.2):
218 if velma.waitForEffectorLeft() != 0:
221 print "Switched to cart_imp mode." def makeWrench(lx, ly, lz, rx, ry, rz)
def createSphereMarkerControl(self, scale, position, color)
def processFeedbackHide(self, feedback)
def createButtoMarkerControl(self, scale, position, color)
def insert6DofGlobalMarker(self)
def processFeedback(self, feedback)
def createBoxMarkerControl(self, scale, position)
def createAxisMarkerControl(self, scale, position)
def erase6DofMarker(self)
def createInteractiveMarkerControl6DOF(self, mode, axis)
def __init__(self, prefix, velma_interface)