33 from python_qt_binding.QtCore
import Qt
34 from python_qt_binding.QtGui
import QBrush, QPen
38 from rqt_bag
import TimelineRenderer
40 from .evaluation_cache
import get_cache
41 from .util
import FIELDS
45 """This class displays the velocity of the best trajectories in the timeline view."""
48 TimelineRenderer.__init__(self, timeline, msg_combine_px=height)
56 return 1.0 - (value - self.
cache.v_min) / (self.
cache.v_max - self.
cache.v_min)
59 painter.setBrush(QBrush(Qt.white))
60 painter.drawRect(x, y, width, height)
62 messages = self.
cache.getMessages(self.timeline.scene(), topic, rospy.Time(stamp_start), rospy.Time(stamp_end))
63 if self.
cache.v_min
is None:
65 painter.setBrush(QBrush(Qt.black))
67 painter.drawLine(x, z_val, x + width, z_val)
70 for field, color
in FIELDS.items():
73 color = getattr(Qt, color)
76 for t, msg
in sorted(messages):
77 best = msg.twists[msg.best_index]
78 best_vel = best.traj.velocity
79 p_x = self.timeline.map_stamp_to_x(t)
81 painter.setBrush(QBrush(color))
82 painter.setPen(QPen(color, 1))
83 value = getattr(best_vel, field)
85 painter.setBrush(QBrush(Qt.red))
86 painter.setPen(QPen(Qt.red, 1))
90 painter.drawLine(last[0], last[1], p_x, p_y)
91 painter.drawEllipse(p_x - RADIUS, p_y - RADIUS, 2 * RADIUS, 2 * RADIUS)