]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
robomon: Fix segmentation fault when disabling more than two lidars
authorMichal Vokac <vokac.m@gmail.com>
Sun, 5 Oct 2014 08:06:22 +0000 (10:06 +0200)
committerMichal Vokac <vokac.m@gmail.com>
Sun, 5 Oct 2014 08:06:22 +0000 (10:06 +0200)
Since we simulate more than one LIDAR, we need extra timer for each sensor
to generate signal for simulation slot.
Using only one timer object causes that after one sensor is disabled
(unchecked) the timer is deleted and then after unchecking the second
sensor it tries to remove the same timer and crashes.

src/robomon/RobomonAtlantis.cpp
src/robomon/RobomonAtlantis.h

index bb9a8a52ac94ff8f76233efc3e90072d31d344f2..356ad7dd45ee3883eb2282ff565a26ef3cd3d342 100644 (file)
@@ -638,15 +638,15 @@ void RobomonAtlantis::setHokuyoObstacleSimulation(int state)
        if (state) {
                /* TODO Maybe it is possible to attach only once to Shmap */
                ShmapInit(0);
        if (state) {
                /* TODO Maybe it is possible to attach only once to Shmap */
                ShmapInit(0);
-               obstacleSimulationTimer = new QTimer(this);
-               connect(obstacleSimulationTimer, SIGNAL(timeout()),
+               obstacleSimulationTimerHokuyo = new QTimer(this);
+               connect(obstacleSimulationTimerHokuyo, SIGNAL(timeout()),
                        this, SLOT(simulateObstaclesHokuyo()));
                        this, SLOT(simulateObstaclesHokuyo()));
-               obstacleSimulationTimer->start(100);
+               obstacleSimulationTimerHokuyo->start(100);
                setMouseTracking(true);
                hokuyoScan->setVisible(true);
        } else {
                setMouseTracking(true);
                hokuyoScan->setVisible(true);
        } else {
-               if (obstacleSimulationTimer)
-                       delete obstacleSimulationTimer;
+               if (obstacleSimulationTimerHokuyo)
+                       delete obstacleSimulationTimerHokuyo;
                // Hide scans of lidars
                hokuyoScan->setVisible(false);
        }
                // Hide scans of lidars
                hokuyoScan->setVisible(false);
        }
@@ -657,15 +657,15 @@ void RobomonAtlantis::setSick331ObstacleSimulation(int state)
        if (state) {
                /* TODO Maybe it is possible to attach only once to Shmap */
                ShmapInit(0);
        if (state) {
                /* TODO Maybe it is possible to attach only once to Shmap */
                ShmapInit(0);
-               obstacleSimulationTimer = new QTimer(this);
-               connect(obstacleSimulationTimer, SIGNAL(timeout()),
+               obstacleSimulationTimerSick331 = new QTimer(this);
+               connect(obstacleSimulationTimerSick331, SIGNAL(timeout()),
                        this, SLOT(simulateObstaclesSick()));
                        this, SLOT(simulateObstaclesSick()));
-               obstacleSimulationTimer->start(100);
+               obstacleSimulationTimerSick331->start(100);
                setMouseTracking(true);
                sickScan->setVisible(true);
        } else {
                setMouseTracking(true);
                sickScan->setVisible(true);
        } else {
-               if (obstacleSimulationTimer)
-                       delete obstacleSimulationTimer;
+               if (obstacleSimulationTimerSick331)
+                       delete obstacleSimulationTimerSick331;
                // Hide scans of lidars
                sickScan->setVisible(false);
        }
                // Hide scans of lidars
                sickScan->setVisible(false);
        }
@@ -676,15 +676,15 @@ void RobomonAtlantis::setSick551ObstacleSimulation(int state)
        if (state) {
                /* TODO Maybe it is possible to attach only once to Shmap */
                ShmapInit(0);
        if (state) {
                /* TODO Maybe it is possible to attach only once to Shmap */
                ShmapInit(0);
-               obstacleSimulationTimer = new QTimer(this);
-               connect(obstacleSimulationTimer, SIGNAL(timeout()),
+               obstacleSimulationTimerSick551 = new QTimer(this);
+               connect(obstacleSimulationTimerSick551, SIGNAL(timeout()),
                        this, SLOT(simulateObstaclesSick551()));
                        this, SLOT(simulateObstaclesSick551()));
-               obstacleSimulationTimer->start(100);
+               obstacleSimulationTimerSick551->start(100);
                setMouseTracking(true);
                sick551Scan->setVisible(true);
        } else {
                setMouseTracking(true);
                sick551Scan->setVisible(true);
        } else {
-               if (obstacleSimulationTimer)
-                       delete obstacleSimulationTimer;
+               if (obstacleSimulationTimerSick551)
+                       delete obstacleSimulationTimerSick551;
                // Hide scans of lidars
                sick551Scan->setVisible(false);
        }
                // Hide scans of lidars
                sick551Scan->setVisible(false);
        }
@@ -770,9 +770,6 @@ void RobomonAtlantis::changeObstacle(QPointF position)
 
        simulatedObstacle.x = position.x();
        simulatedObstacle.y = position.y();
 
        simulatedObstacle.x = position.x();
        simulatedObstacle.y = position.y();
-       simulateObstaclesLidar(hokuyo_params);
-       simulateObstaclesLidar(sick_params);
-       simulateObstaclesLidar(sick551_params);
 }
 
 /**********************************************************************
 }
 
 /**********************************************************************
index 6e79e0284f5fe983419b152556b044e228dfc6b4..0b40940ddca9d5e08dec2f493e927aa421c7ddc8 100644 (file)
@@ -216,7 +216,9 @@ private:
        int sickSimEnabled;
        int sick551SimEnabled;
 
        int sickSimEnabled;
        int sick551SimEnabled;
 
-       QTimer *obstacleSimulationTimer;
+       QTimer *obstacleSimulationTimerHokuyo;
+       QTimer *obstacleSimulationTimerSick331;
+       QTimer *obstacleSimulationTimerSick551;
        Point simulatedObstacle;
 
        /************************************************************
        Point simulatedObstacle;
 
        /************************************************************