3 from visualization_msgs.msg
import Marker, InteractiveMarker, InteractiveMarkerControl
4 from geometry_msgs.msg
import Pose, Point, Quaternion
6 import pyexotica
as exo
8 __all__ = [
'TargetMarker']
12 return Pose(Point(x = p[0], y = p[1], z = p[2]), Quaternion(x = 0., y = 0., z = 0., w = 1.))
14 quat = exo.KDLFrame(p).get_quaternion()
15 return Pose(Point(x = p[0], y = p[1], z = p[2]), Quaternion(x = quat[0], y = quat[1], z = quat[2], w = quat[3]))
17 return Pose(Point(x = p[0], y = p[1], z = p[2]), Quaternion(x = p[3], y = p[4], z = p[5], w = p[6]))
19 raise RuntimeError(
'Invalid transform! Can only accept vectors of length 3, 6 or 7')
23 def __init__(self, pose=[0, 0, 0, 0, 0, 0, 1],
25 server_name='target_marker',
26 frame_id='exotica/world_frame',
27 marker_shape=Marker.ARROW,
28 marker_size=[0.2, 0.05, 0.05],
29 marker_color=[0.0, 0.5, 0.5, 1.0],
32 controls_translate=True):
47 visual_marker = Marker()
48 visual_marker.type = marker_shape
49 if len(marker_size) != 3:
50 raise RuntimeError(
"Length of marker_size needs to be 3.")
51 visual_marker.scale.x = marker_size[0]
52 visual_marker.scale.y = marker_size[1]
53 visual_marker.scale.z = marker_size[2]
54 if len(marker_color) != 4:
55 raise RuntimeError(
"Length of marker_color needs to be 4.")
56 visual_marker.color.r = marker_color[0]
57 visual_marker.color.g = marker_color[1]
58 visual_marker.color.b = marker_color[2]
59 visual_marker.color.a = marker_color[3]
62 visual_control = InteractiveMarkerControl()
63 visual_control.always_visible =
True 64 visual_control.markers.append( visual_marker )
67 self.
int_marker.controls.append( visual_control )
70 self.
addControl([1, 0, 0], InteractiveMarkerControl.ROTATE_AXIS)
71 self.
addControl([0, 1, 0], InteractiveMarkerControl.ROTATE_AXIS)
72 self.
addControl([0, 0, 1], InteractiveMarkerControl.ROTATE_AXIS)
73 if controls_translate:
74 self.
addControl([1, 0, 0], InteractiveMarkerControl.MOVE_AXIS)
75 self.
addControl([0, 1, 0], InteractiveMarkerControl.MOVE_AXIS)
76 self.
addControl([0, 0, 1], InteractiveMarkerControl.MOVE_AXIS)
78 for control
in controls:
85 control = InteractiveMarkerControl()
86 quat = exo.KDLFrame([0, 0, 0] + direction + [1]).get_quaternion()
87 control.orientation.x = quat[0]
88 control.orientation.y = quat[1]
89 control.orientation.z = quat[2]
90 control.orientation.w = quat[3]
91 control.interaction_mode = control_type
96 kdl.Rotation.Quaternion(feedback.pose.orientation.x, feedback.pose.orientation.y, feedback.pose.orientation.z, feedback.pose.orientation.w),
97 kdl.Vector(feedback.pose.position.x, feedback.pose.position.y, feedback.pose.position.z))
98 self.
position_exo = exo.KDLFrame([feedback.pose.position.x, feedback.pose.position.y, feedback.pose.position.z,
99 feedback.pose.orientation.x, feedback.pose.orientation.y, feedback.pose.orientation.z, feedback.pose.orientation.w])
def __init__(self, pose=[0, description='Target', server_name='target_marker', frame_id='exotica/world_frame', marker_shape=Marker.ARROW, marker_size=[0.2, marker_color=[0.0, controls=[], controls_rotate=True, controls_translate=True)
def addControl(self, direction, control_type)
def process_feedback(self, feedback)