phyepuck.h
1 /********************************************************************************
2  * WorldSim -- library for robot simulations *
3  * Copyright (C) 2012-2013 *
4  * Gianluca Massera <emmegian@yahoo.it> *
5  * Fabrizio Papi <erkito87@gmail.com> *
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the Free Software *
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
20  ********************************************************************************/
21 
22 #ifndef PHYEPUCK_H
23 #define PHYEPUCK_H
24 
25 #include "worldsimconfig.h"
26 #include "wvector.h"
27 #include "wmatrix.h"
28 #include "world.h"
29 #include "motorcontrollers.h"
30 #include "sensorcontrollers.h"
31 #include <QVector>
32 
33 namespace farsa {
34  class PhyObject;
35  class PhyJoint;
36  class PhyCylinder;
37 
44  class FARSA_WSIM_API PhyEpuck : public WObject {
45  Q_OBJECT
46 
47  public:
51  static const real batteryplacex;
52 
56  static const real batteryplacey;
57 
61  static const real batteryplacez;
62 
66  static const real batterym;
67 
71  static const real batteryplacedistancefromground;
72 
77  static const real bodyr;
78 
83  static const real bodyh;
84 
89  static const real wholebodym;
90 
94  static const real wheelr;
95 
99  static const real wheelh;
100 
104  static const real wheelm;
105 
109  static const real axletrack;
110 
117  static const real passivewheelr;
118 
125  static const real passivewheelm;
126 
127  public:
135  PhyEpuck(World* world, QString name, const wMatrix& transformation = wMatrix::identity());
136 
140  virtual ~PhyEpuck();
141 
147  WheelMotorController* wheelsController()
148  {
149  return m_wheelsCtrl;
150  }
151 
157  IRSensorController* proximityIRSensorController()
158  {
159  return m_proximityIR;
160  }
161 
167  IRSensorController* groundIRSensorController()
168  {
169  return m_groundIR;
170  }
171 
178  virtual void preUpdate();
179 
186  virtual void postUpdate();
187 
198  void setProximityIRSensorsGraphicalProperties(bool drawSensor, bool drawRay = false, bool drawRealRay = false);
199 
210  void setGroundIRSensorsGraphicalProperties(bool drawSensor, bool drawRay = false, bool drawRealRay = false);
211 
220  void doKinematicSimulation(bool k);
221 
227  bool isKinematic() const
228  {
229  return m_kinematicSimulation;
230  }
231 
232  protected slots:
242  void setLeftWheelDesideredVelocity(real velocity);
243 
253  void setRightWheelDesideredVelocity(real velocity);
254 
255  protected:
262  virtual void changedMatrix();
263 
264  private:
268  PhyObject* m_body;
269 
276  QVector<PhyObject*> m_wheels;
277 
284  QVector<wMatrix> m_wheelsTransformation;
285 
292  QVector<PhyJoint*> m_wheelJoints;
293 
299  WheelMotorController* m_wheelsCtrl;
300 
305 
310 
314  bool m_kinematicSimulation;
315 
319  real m_leftWheelVelocity;
320 
324  real m_rightWheelVelocity;
325  };
326 } // end namespace farsa
327 
328 #endif