interface_markers.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
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         ## Publish all changed markers
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() ## ToDo
00036 
00037         marker = copy.deepcopy(element.marker) # copy
00038 
00039         marker.header.frame_id = element.name
00040         marker.header.stamp = rospy.Time() # zero time
00041         marker.ns = "frame_editor_markers"
00042         marker.frame_locked = True # Tells rviz to retransform the marker into the current location of the specified frame every update cycle.
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         ## Publish with own rate
00058         if (rospy.Time.now() - self.last_publish_time) >= self.publish_period:
00059 
00060             ## Update all markers
00061             self.update(editor, 0, editor.frames.values())
00062 
00063             self.last_publish_time = rospy.Time.now()
00064 
00065 # eof


frame_editor
Author(s): ipa-frn
autogenerated on Sat Jun 8 2019 20:21:35