Go to the documentation of this file.00001
00002
00003 import copy
00004 import rospy
00005
00006 from frame_editor.interface import Interface
00007
00008 from visualization_msgs.msg import Marker
00009
00010
00011 class FrameEditor_Markers(Interface):
00012
00013 def __init__(self, frame_editor):
00014 self.editor = frame_editor
00015 self.editor.observers.append(self)
00016
00017 self.publisher = rospy.Publisher("frame_editor_marker", Marker, queue_size=10, latch=False)
00018 self.last_publish_time = rospy.Time.now()
00019 self.publish_period = rospy.Duration(2.0)
00020
00021
00022 def update(self, editor, level, elements):
00023
00024
00025
00026 for element in elements:
00027 if not element:
00028 continue
00029 if element.marker:
00030 self.publish_marker(element)
00031
00032
00033 def publish_marker(self, element):
00034
00035 element.update_marker()
00036
00037 marker = copy.deepcopy(element.marker)
00038
00039 marker.header.frame_id = element.name
00040 marker.header.stamp = rospy.Time()
00041 marker.ns = "frame_editor_markers"
00042 marker.frame_locked = True
00043
00044 if element.hidden:
00045 marker.action = Marker.DELETE
00046 else:
00047 marker.action = Marker.ADD
00048
00049 if element.style == "mesh":
00050 if element.path == "" or element.path is None:
00051 marker.action = Marker.DELETE
00052
00053 self.publisher.publish(marker)
00054
00055
00056 def broadcast(self, editor):
00057
00058 if (rospy.Time.now() - self.last_publish_time) >= self.publish_period:
00059
00060
00061 self.update(editor, 0, editor.frames.values())
00062
00063 self.last_publish_time = rospy.Time.now()
00064
00065