phykhepera.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 PHYKHEPERA_H
23 #define PHYKHEPERA_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 PhyKhepera : public WObject {
46  Q_OBJECT
47 
48  public:
52  static const real bodydistancefromground;
53 
57  static const real bodyr;
58 
62  static const real bodyh;
63 
67  static const real bodym;
68 
72  static const real wheelr;
73 
77  static const real wheelh;
78 
82  static const real wheelm;
83 
87  static const real axletrack;
88 
95  static const real passivewheelr;
96 
103  static const real passivewheelm;
104 
105  public:
113  PhyKhepera(World* world, QString name, const wMatrix& transformation = wMatrix::identity());
114 
118  virtual ~PhyKhepera();
119 
125  WheelMotorController* wheelsController()
126  {
127  return m_wheelsCtrl;
128  }
129 
135  IRSensorController* proximityIRSensorController()
136  {
137  return m_proximityIR;
138  }
139 
146  virtual void preUpdate();
147 
154  virtual void postUpdate();
155 
166  void setProximityIRSensorsGraphicalProperties(bool drawSensor, bool drawRay = false, bool drawRealRay = false);
167 
175  void setDrawFrontMarker(bool drawMarker);
176 
184  bool getDrawFrontMarker() const;
185 
194  void doKinematicSimulation(bool k);
195 
201  bool isKinematic() const
202  {
203  return m_kinematicSimulation;
204  }
205 
206  protected slots:
216  void setLeftWheelDesideredVelocity(real velocity);
217 
227  void setRightWheelDesideredVelocity(real velocity);
228 
229  protected:
236  virtual void changedMatrix();
237 
238  private:
242  PhyObject* m_body;
243 
248  wMatrix m_bodyTransformation;
249 
254  wMatrix m_bodyInvTransformation;
255 
262  QVector<PhyObject*> m_wheels;
263 
271  QVector<wMatrix> m_wheelsTransformation;
272 
279  QVector<PhyJoint*> m_wheelJoints;
280 
286  WheelMotorController* m_wheelsCtrl;
287 
292 
296  bool m_kinematicSimulation;
297 
301  real m_leftWheelVelocity;
302 
306  real m_rightWheelVelocity;
307 
314  GraphicalWObject* m_frontMarker;
315  };
316 } // end namespace farsa
317 
318 #endif