38 import roslib; roslib.load_manifest(
'rcprg_ros_utils')
47 from std_msgs.msg
import ColorRGBA
53 import tf_conversions.posemath
as pm
59 self.
br = tf2_ros.TransformBroadcaster()
62 self.
tf.translation.x = 1.0
63 self.
tf.translation.y = 0.0
64 self.
tf.translation.z = 1.5
65 self.
tf.rotation.x = 0
66 self.
tf.rotation.y = 0
67 self.
tf.rotation.z = 0
68 self.
tf.rotation.w = 1
75 while not rospy.is_shutdown():
76 t = TransformStamped()
77 t.header.stamp = rospy.Time.now()
78 t.header.frame_id =
"world" 81 self.
br.sendTransform(t)
88 int_position_marker = InteractiveMarker()
89 int_position_marker.header.frame_id =
'world' 90 int_position_marker.name =
'pose_int_marker_' + self.
frame_id 91 int_position_marker.scale = 0.2
92 int_position_marker.pose.position.x = self.
tf.translation.x
93 int_position_marker.pose.position.y = self.
tf.translation.y
94 int_position_marker.pose.position.z = self.
tf.translation.z
95 int_position_marker.pose.orientation = self.
tf.rotation
105 box.interaction_mode = InteractiveMarkerControl.BUTTON
107 int_position_marker.controls.append( box )
109 self.
server.applyChanges();
112 if ( feedback.marker_name ==
'pose_int_marker_' + self.
frame_id ):
113 self.
tf.translation.x = feedback.pose.position.x
114 self.
tf.translation.y = feedback.pose.position.y
115 self.
tf.translation.z = feedback.pose.position.z
116 self.
tf.rotation = feedback.pose.orientation
117 print "PyKDL.Frame(PyKDL.Rotation.Quaternion(", self.
tf.rotation.x,
",", self.
tf.rotation.y,
",", self.
tf.rotation.z,
",", self.
tf.rotation.w,
"), PyKDL.Vector(", self.
tf.translation.x,
",", self.
tf.translation.y,
",", self.
tf.translation.z,
"))" 121 markerX.type = Marker.ARROW
122 markerX.scale = scale
123 markerX.pose.position = position
124 ori = quaternion_about_axis(0, [0, 1 ,0])
125 markerX.pose.orientation = Quaternion(ori[0], ori[1], ori[2], ori[3])
126 markerX.color = ColorRGBA(1,0,0,1)
128 markerY.type = Marker.ARROW
129 markerY.scale = scale
130 markerY.pose.position = position
131 ori = quaternion_about_axis(math.pi/2.0, [0, 0 ,1])
132 markerY.pose.orientation = Quaternion(ori[0], ori[1], ori[2], ori[3])
133 markerY.color = ColorRGBA(0,1,0,1)
135 markerZ.type = Marker.ARROW
136 markerZ.scale = scale
137 markerZ.pose.position = position
138 ori = quaternion_about_axis(-math.pi/2.0, [0, 1 ,0])
139 markerZ.pose.orientation = Quaternion(ori[0], ori[1], ori[2], ori[3])
140 markerZ.color = ColorRGBA(0,0,1,1)
141 control = InteractiveMarkerControl()
142 control.always_visible =
True;
143 control.markers.append( markerX );
144 control.markers.append( markerY );
145 control.markers.append( markerZ );
150 marker.type = Marker.SPHERE
152 marker.pose.position = position
153 marker.pose.orientation = Quaternion(0,0,0,1)
155 control = InteractiveMarkerControl()
156 control.always_visible =
True;
157 control.markers.append( marker );
161 control = InteractiveMarkerControl()
162 control.orientation_mode = InteractiveMarkerControl.FIXED
163 if mode == InteractiveMarkerControl.ROTATE_AXIS:
164 control.name =
'rotate_';
165 if mode == InteractiveMarkerControl.MOVE_AXIS:
166 control.name =
'move_';
168 control.orientation = Quaternion(1,0,0,1)
169 control.name = control.name+
'x';
171 control.orientation = Quaternion(0,1,0,1)
172 control.name = control.name+
'x';
174 control.orientation = Quaternion(0,0,1,1)
175 control.name = control.name+
'x';
176 control.interaction_mode = mode
179 if __name__ ==
"__main__":
181 rospy.init_node(
'pose_int_marker', anonymous=
True)
186 frame_id = rospy.get_param(
"~frame_id")
187 except KeyError
as e:
188 print "Some ROS parameters are not provided:" def createInteractiveMarkerControl6DOF(self, mode, axis)
def createAxisMarkerControl(self, scale, position)
def insert6DofGlobalMarker(self)
def __init__(self, frame_id)
def createButtoMarkerControl(self, scale, position, color)
def processFeedback(self, feedback)