]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
Merge branch 'maint-demo' master
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 28 Mar 2014 00:09:54 +0000 (01:09 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 28 Mar 2014 00:09:54 +0000 (01:09 +0100)
Conflicts:
src/robomon/RobomonAtlantis.h

1  2 
src/robomon/RobomonAtlantis.cpp
src/robomon/RobomonAtlantis.h

index 63270a711a1911992a5058d9cedd9d7e6ebe86ac,6679b8ed36b3b1427d174a7e01f446bf948752af..9a2a30987191f88eab53e0daa39987a6d86b258d
@@@ -366,20 -396,11 +372,23 @@@ void RobomonAtlantis::createActions(
                        playgroundScene, SLOT(showObstacle(int)));
        connect(playgroundScene, SIGNAL(obstacleChanged(QPointF)),
                        this, SLOT(changeObstacle(QPointF)));
+       connect(motorSimulationCheckBox, SIGNAL(stateChanged(int)),
+               this, SLOT(setMotorSimulation(int)));
  }
  
 +void RobomonAtlantis::changeStrategy_1()
 +{
 +        orte.robot_switches.strategy = true;
 +        ORTEPublicationSend(orte.publication_robot_switches);
 +}
 +
 +void RobomonAtlantis::changeStrategy_0()
 +{
 +        orte.robot_switches.strategy = false;
 +        ORTEPublicationSend(orte.publication_robot_switches);
 +}
 +
  void RobomonAtlantis::setVoltage33(int state)
  {
        if (state)
index f62fe99c9b7d28bd683abd43a54d9990ff9bd307,f7983628b3200db586dd4012ae648f9291e85440..f7239bed5ffa13f352951673480b2017f980a124
@@@ -38,8 -39,40 +40,41 @@@ class QDial
  class QSlider;
  class QProgressBar;
  class QFont;
 +class QImage;
  
+ class MotorSimulation : QObject {
+     Q_OBJECT
+     QTimer timer;
+     qint64 last_time;
+     struct robottype_orte_data &orte;
+ public:
+     MotorSimulation(struct robottype_orte_data &orte) : QObject(), timer(this), orte(orte) {}
+     void start()
+     {
+         robottype_publisher_motion_irc_create(&orte, 0, 0);
+         connect(&timer, SIGNAL(timeout()), this, SLOT(updateIRC()));
+         timer.start(50);
+     }
+     void stop()
+     {
+         robottype_publisher_motion_irc_destroy(&orte);
+         timer.stop();
+         disconnect(&timer, SIGNAL(timeout()), this, SLOT(updateIRC()));
+     }
+ private slots:
+     void updateIRC()
+     {
+         qint64 now = QDateTime::currentMSecsSinceEpoch();
+         orte.motion_irc.left += orte.motion_speed.left * (now - last_time);   // TODO: Find constant for speed to irc conversion
+         orte.motion_irc.right+= orte.motion_speed.right * (now - last_time);
+         ORTEPublicationSend(orte.publication_motion_irc);
+         last_time = now;
+     }
+ };
  class RobomonAtlantis : public QWidget
  {
        Q_OBJECT
@@@ -81,11 -114,10 +116,12 @@@ private slots
        void changeObstacle(QPointF position);
        void sendStart(int plug);
        void setTeamColor(int plug);
 +        void changeStrategy_1();
 +        void changeStrategy_0();
+       void setMotorSimulation(int state);
  
        /************************************************************
 -       * ORTE 
 +       * ORTE
         ************************************************************/
        void motionStatusReceived();
        void actualPositionReceived();
@@@ -201,8 -229,10 +238,10 @@@ private
        QTimer *obstacleSimulationTimer;
        Point simulatedObstacle;
  
+       class MotorSimulation motorSimulation;
        /************************************************************
 -       * ORTE 
 +       * ORTE
         ************************************************************/
        void createOrte();