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 "phycylinder.h"
33 #include <QVector>
34 
35 namespace farsa {
36  class PhyObject;
37  class PhyJoint;
38  class PhyCylinder;
39 
46  class FARSA_WSIM_API PhyEpuck : public WObject {
47  Q_OBJECT
48 
49  public:
53  static const real batteryplacex;
54 
58  static const real batteryplacey;
59 
63  static const real batteryplacez;
64 
68  static const real batterym;
69 
74 
79  static const real bodyr;
80 
85  static const real bodyh;
86 
91  static const real wholebodym;
92 
96  static const real wheelr;
97 
101  static const real wheelh;
102 
106  static const real wheelm;
107 
111  static const real axletrack;
112 
119  static const real passivewheelr;
120 
127  static const real passivewheelm;
128 
129  public:
137  PhyEpuck(World* world, QString name, const wMatrix& transformation = wMatrix::identity());
138 
142  virtual ~PhyEpuck();
143 
150  {
151  return m_wheelsCtrl;
152  }
153 
160  {
161  return m_proximityIR;
162  }
163 
170  {
171  return m_groundIR;
172  }
173 
180  virtual void preUpdate();
181 
188  virtual void postUpdate();
189 
200  void setProximityIRSensorsGraphicalProperties(bool drawSensor, bool drawRay = false, bool drawRealRay = false);
201 
212  void setGroundIRSensorsGraphicalProperties(bool drawSensor, bool drawRay = false, bool drawRealRay = false);
213 
221  void setDrawFrontMarker(bool drawMarker);
222 
230  bool getDrawFrontMarker() const;
231 
240  void doKinematicSimulation(bool k);
241 
247  bool isKinematic() const
248  {
249  return m_kinematicSimulation;
250  }
251 
265  void setLedColors(QList<QColor> c, QColor upperBaseColor = QColor());
266 
272  QList<QColor> ledColors() const;
273 
281  const QList<PhyCylinder::SegmentColor>& segmentsColor() const;
282 
283 
284  protected slots:
294  void setLeftWheelDesideredVelocity(real velocity);
295 
305  void setRightWheelDesideredVelocity(real velocity);
306 
307  protected:
314  virtual void changedMatrix();
315 
316  private:
320  PhyObject* m_body;
321 
328  PhyCylinder* m_turret;
329 
336  QVector<PhyObject*> m_wheels;
337 
344  QVector<wMatrix> m_wheelsTransformation;
345 
352  QVector<PhyJoint*> m_wheelJoints;
353 
359  WheelMotorController* m_wheelsCtrl;
360 
365 
370 
374  bool m_kinematicSimulation;
375 
379  real m_leftWheelVelocity;
380 
384  real m_rightWheelVelocity;
385 
392  GraphicalWObject* m_frontMarker;
393 
400  QList<QColor> m_ledColors;
401 
408  mutable QList<PhyCylinder::SegmentColor> m_uniformColor;
409  };
410 } // end namespace farsa
411 
412 #endif
World's Object class.
Definition: wobject.h:39
static wMatrix identity()
create an identity matrix
Definition: wmatrix.h:460
static const real batteryplacex
The x dimension of the battery pack under the robot.
Definition: phyepuck.h:53
static const real wholebodym
The mass of the robot without the wheels and the battery.
Definition: phyepuck.h:91
WheelMotorController * wheelsController()
Returns the motor controller for the wheels.
Definition: phyepuck.h:149
bool isKinematic() const
Returns true if we are using the kinematic model.
Definition: phyepuck.h:247
static const real passivewheelm
The mass of the passive wheels.
Definition: phyepuck.h:127
The class modelling an e-puck robot.
Definition: phyepuck.h:46
World class.
Definition: world.h:223
static const real batteryplacez
The z dimension of the battery pack under the robot.
Definition: phyepuck.h:63
wMatrix class
Definition: wmatrix.h:48
An helper class to draw stuffs in the world.
static const real wheelr
The radius of the motorized wheels.
Definition: phyepuck.h:96
static const real batterym
The mass of the battery.
Definition: phyepuck.h:68
static const real axletrack
The distance between the two motorized wheels.
Definition: phyepuck.h:111
SimulatedIRGroundSensorController * groundIRSensorController()
Returns the ground IR sensors controller.
Definition: phyepuck.h:169
static const real wheelm
The mass of one motorized wheel.
Definition: phyepuck.h:106
static const real batteryplacey
The y dimension of the battery pack under the robot.
Definition: phyepuck.h:58
A collection of SingleIR modelling ground sensors.
static const real batteryplacedistancefromground
The distance of the battery pack from the ground.
Definition: phyepuck.h:73
float real
PhyCylinder class.
Definition: phycylinder.h:53
static const real passivewheelr
The radius of the passive wheels.
Definition: phyepuck.h:119
static const real bodyh
The height of the upper part of the robot (containing the main electionic board)
Definition: phyepuck.h:85
Dedicated controller for wheeled robots.
SimulatedIRProximitySensorController * proximityIRSensorController()
Returns the proximity infrared sensors controller.
Definition: phyepuck.h:159
static const real wheelh
The height of the motorized wheels.
Definition: phyepuck.h:101
PhyObject class.
Definition: phyobject.h:46
static const real bodyr
The radius of the upper part of the robot (containing the main electionic board)
Definition: phyepuck.h:79