Previously the hokuyo scan was redrawn also when robot's position changes.
This led to "shaking" of hokuyo scan becouse robot's position and scan data
was not delivered in the same time.
Now, the scan is redrawn only when new data arrives. When the robot move
after that instant the scan stays at the same place.
void HokuyoScan::setPosition(double x, double y, double phi)
{
- QPointF pos(x, y);
+ // Store position to be used when new data arrives
+ this->x = x;
+ this->y = y;
+ this->phi = phi;
+}
+void HokuyoScan::newScan(struct hokuyo_scan_type *scan)
+{
+ QPointF pos(x, y);
pos = PlaygroundScene::world2scene(pos);
-
setPos(pos);
setTransform(QTransform().rotateRadians(phi).translate(HOKUYO_CENTER_OFFSET_MM, 0));
-}
-void HokuyoScan::newScan(struct hokuyo_scan_type *scan)
-{
data = *scan;
+
update(boundingRect());
}
class HokuyoScan : public QGraphicsItem
{
+ float x, y, phi;
public:
struct hokuyo_scan_type data;
HokuyoScan();