]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
robomon: Update hokuyo only when new scan data arrives
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 25 Apr 2010 08:21:28 +0000 (10:21 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 25 Apr 2010 08:21:28 +0000 (10:21 +0200)
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.

src/robomon/hokuyoscan.cpp
src/robomon/hokuyoscan.h

index 2528c75f5fd00a0ab5da934554fcd0577d12ad8d..f806cf5a805893f8ebe14b43beeff29e2a6452dd 100644 (file)
@@ -61,16 +61,20 @@ void HokuyoScan::paint(QPainter * painter, const QStyleOptionGraphicsItem * opti
 
 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());
 }
index 8e26662d2f429d657b62dc85c6c4fcf09e78a8d8..49128392b240f5346e3843cbf814dc5b69ff92a0 100644 (file)
@@ -10,6 +10,7 @@
 
 class HokuyoScan : public QGraphicsItem
 {
+    float x, y, phi;
 public:
     struct hokuyo_scan_type data;
     HokuyoScan();