33 from math
import cos, sin
35 from python_qt_binding.QtCore
import Qt
36 from python_qt_binding.QtGui
import QBrush, QPainter, QPen
37 from python_qt_binding.QtWidgets
import QWidget
39 from .bounds
import Bounds
40 from .util
import subtractPose
44 """Expand the negative bounds of the x axis by 10 percent so the area behind the robot is visible."""
45 bounds.x_min -= (bounds.x_max - bounds.x_min) * extra
49 """This widget displays the actual trajectories of the robot's position through time in robot coordinate space."""
52 QWidget.__init__(self, parent)
84 if desired_width == 0
or desired_height == 0:
87 wr = rect.width() / desired_width
88 hr = rect.height() / desired_height
89 self.
ratio = min(wr, hr)
114 self.
qp.drawEllipse(x - radius, y - radius, 2 * radius, 2 * radius)
119 def drawPoses(self, poses, base_pose, pose_radius=4, final_pose_radius=5, draw_final_orientation=True):
125 self.
drawLine(last.x, last.y, pose.x, pose.y)
130 self.
drawCircle(last.x, last.y, final_pose_radius)
132 if draw_final_orientation:
133 scale_radius = final_pose_radius / self.
ratio
135 last.x + scale_radius * cos(last.theta),
136 last.y + scale_radius * sin(last.theta))
141 self.
qp.setPen(QPen(Qt.black, 0))
152 brush = self.
qp.brush()
155 self.
qp.setPen(QPen(Qt.gray, 0))
158 self.
drawPoses(twist.traj.poses, twist.traj.poses[0], 0, draw_final_orientation=
False)
161 self.
qp.setPen(QPen(Qt.black, 0))
163 poses = self.
evaluation.twists[index].traj.poses
167 self.
qp.setBrush(brush)
169 if self.
plan is not None:
170 self.
qp.setPen(QPen(Qt.green, 0))