interface_markers.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import copy
4 import rospy
5 
6 from frame_editor.interface import Interface
7 
8 from visualization_msgs.msg import Marker
9 
10 
12 
13  def __init__(self, frame_editor):
14  self.editor = frame_editor
15  self.editor.observers.append(self)
16 
17  self.publisher = rospy.Publisher("frame_editor_marker", Marker, queue_size=10, latch=False)
18  self.last_publish_time = rospy.Time.now()
19  self.publish_period = rospy.Duration(2.0)
20 
21 
22  def update(self, editor, level, elements):
23 
24  ## Publish all changed markers
25 
26  for element in elements:
27  if not element:
28  continue
29  if element.marker:
30  self.publish_marker(element)
31 
32 
33  def publish_marker(self, element):
34 
35  element.update_marker() ## ToDo
36 
37  marker = copy.deepcopy(element.marker) # copy
38 
39  marker.header.frame_id = element.name
40  marker.header.stamp = rospy.Time() # zero time
41  marker.ns = "frame_editor_markers"
42  marker.frame_locked = True # Tells rviz to retransform the marker into the current location of the specified frame every update cycle.
43 
44  if element.hidden:
45  marker.action = Marker.DELETE
46  else:
47  marker.action = Marker.ADD
48 
49  if element.style == "mesh":
50  if element.path == "" or element.path is None:
51  marker.action = Marker.DELETE
52 
53  self.publisher.publish(marker)
54 
55 
56  def broadcast(self, editor):
57  ## Publish with own rate
58  if (rospy.Time.now() - self.last_publish_time) >= self.publish_period:
59 
60  ## Update all markers
61  self.update(editor, 0, editor.frames.values())
62 
63  self.last_publish_time = rospy.Time.now()
64 
65 # eof
def update(self, editor, level, elements)
Definition: interface.py:10


frame_editor
Author(s): ipa-lth , ipa-frn
autogenerated on Wed Apr 10 2019 02:47:55