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 "graphicalwobject.h"
32 #include <QVector>
33 
34 namespace farsa {
35  class PhyObject;
36  class PhyJoint;
37  class PhyCylinder;
38 
45  class FARSA_WSIM_API PhyEpuck : public WObject {
46  Q_OBJECT
47 
48  public:
52  static const real batteryplacex;
53 
57  static const real batteryplacey;
58 
62  static const real batteryplacez;
63 
67  static const real batterym;
68 
72  static const real batteryplacedistancefromground;
73 
78  static const real bodyr;
79 
84  static const real bodyh;
85 
90  static const real wholebodym;
91 
95  static const real wheelr;
96 
100  static const real wheelh;
101 
105  static const real wheelm;
106 
110  static const real axletrack;
111 
118  static const real passivewheelr;
119 
126  static const real passivewheelm;
127 
128  public:
136  PhyEpuck(World* world, QString name, const wMatrix& transformation = wMatrix::identity());
137 
141  virtual ~PhyEpuck();
142 
148  WheelMotorController* wheelsController()
149  {
150  return m_wheelsCtrl;
151  }
152 
158  IRSensorController* proximityIRSensorController()
159  {
160  return m_proximityIR;
161  }
162 
168  IRSensorController* groundIRSensorController()
169  {
170  return m_groundIR;
171  }
172 
179  virtual void preUpdate();
180 
187  virtual void postUpdate();
188 
199  void setProximityIRSensorsGraphicalProperties(bool drawSensor, bool drawRay = false, bool drawRealRay = false);
200 
211  void setGroundIRSensorsGraphicalProperties(bool drawSensor, bool drawRay = false, bool drawRealRay = false);
212 
220  void setDrawFrontMarker(bool drawMarker);
221 
229  bool getDrawFrontMarker() const;
230 
239  void doKinematicSimulation(bool k);
240 
246  bool isKinematic() const
247  {
248  return m_kinematicSimulation;
249  }
250 
251  protected slots:
261  void setLeftWheelDesideredVelocity(real velocity);
262 
272  void setRightWheelDesideredVelocity(real velocity);
273 
274  protected:
281  virtual void changedMatrix();
282 
283  private:
287  PhyObject* m_body;
288 
295  QVector<PhyObject*> m_wheels;
296 
303  QVector<wMatrix> m_wheelsTransformation;
304 
311  QVector<PhyJoint*> m_wheelJoints;
312 
318  WheelMotorController* m_wheelsCtrl;
319 
324 
329 
333  bool m_kinematicSimulation;
334 
338  real m_leftWheelVelocity;
339 
343  real m_rightWheelVelocity;
344 
351  GraphicalWObject* m_frontMarker;
352  };
353 } // end namespace farsa
354 
355 #endif