8 import tf.transformations
as tft
16 from frame_editor
import utils_tf
18 from geometry_msgs.msg
import Pose
20 from visualization_msgs.msg
import InteractiveMarkerControl, Marker
32 def __init__(self, name, position=(0,0,0), orientation=(0,0,0,1), parent=
"world", style=
"none", group=
""):
38 self.
color = (0.0, 0.5, 0.5, 0.75)
46 if Frame.tf_buffer
is None:
56 tf2_structure_in_yaml = Frame.tf_buffer.all_frames_as_yaml()
57 tf2_structure = yaml.load(tf2_structure_in_yaml, Loader=yaml.Loader)
59 bc = tf2_structure[name][
"broadcaster"]
60 return bc == rospy.get_name()
93 if symbol
in [
'x',
'y',
'z']:
103 rpy = list(tft.euler_from_quaternion(self.
orientation))
110 self.
orientation = tuple(tft.quaternion_from_euler(*rpy))
117 return utils_tf.can_transform(
118 Frame.tf_buffer, target_frame, source_frame, time_)
122 return utils_tf.wait_for_transform(
123 Frame.tf_buffer, target_frame, source_frame, timeout)
128 def __init__(self, name, position, orientation, parent, style, group):
130 super(Object_Geometry, self).
__init__(name, position, orientation, parent, style, group)
137 self.
marker.id = Frame.create_new_id()
143 self.
marker.header.stamp = rospy.Time.now()
147 self.
marker.color =
NewColor(color[0], color[1], color[2], color[3])
154 def __init__(self, name, position, orientation, parent, length=1.0, width=1.0, group=""):
159 super(Object_Plane, self).
__init__(name, position, orientation, parent,
"plane", group)
167 self.
marker.type = Marker.TRIANGLE_LIST
176 def __init__(self, name, position, orientation, parent, length=1.0, width=1.0, height=1.0, group=""):
182 super(Object_Cube, self).
__init__(name, position, orientation, parent,
"cube", group)
187 self.
marker.type = Marker.CUBE
193 def __init__(self, name, position, orientation, parent, diameter=1.0, group=""):
197 super(Object_Sphere, self).
__init__(name, position, orientation, parent,
"sphere", group)
202 self.
marker.type = Marker.SPHERE
208 def __init__(self, name, position, orientation, parent, length=1.0, width=0.05, group=""):
213 super(Object_Axis, self).
__init__(name, position, orientation, parent,
"axis", group)
218 self.
marker.type = Marker.ARROW
224 def __init__(self, name, position, orientation, parent, package=None, mesh_path="", scale=1.0, group=""):
230 super(Object_Mesh, self).
__init__(name, position, orientation, parent,
"mesh", group)
241 self.
marker.type = Marker.MESH_RESOURCE
245 self.
marker.mesh_resource =
"file:"+rospkg.RosPack().get_path(self.
package)+
"/"+self.
path