phymarxbot.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 PHYMARXBOT_H
23 #define PHYMARXBOT_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  class PhyFixed;
38 
42  class FARSA_WSIM_API PhyMarXbot : public WObject {
43  Q_OBJECT
44  public:
45  // Robot dimensions. Measures and masses in MKS
46 
47  // --- chassis containing the battery
48  static const real basex;
49  static const real basey;
50  static const real basez;
51  static const real basem;
52 
53  // --- cylinder body supporting infrared and other modules and turrets
54  static const real bodyr;
55  static const real bodyh;
56  static const real bodym;
57 
58  // --- inner part of the continous tracks (where the rubber tracks move on)
59  static const real axledistance;
60  static const real trackradius;
61  static const real trackheight;
62  static const real trackm;
63 
64  // --- the height of the treads on tracks and wheels
65  static const real treaddepth;
66 
67  // --- external wheels (the radius is excluding the tread height)
68  static const real wheelr;
69  static const real wheelh;
70  static const real wheelm;
71 
72  // --- height of the attachment ring
73  static const real attachringh;
74  static const real attachringm;
75 
76  // --- module with 12 RGB LEDs
77  static const real ledsh;
78  static const real ledsradius;
79  static const real ledsm;
80 
81  public:
85  PhyMarXbot( World* world, QString name, const wMatrix& tm = wMatrix::identity() );
88  virtual ~PhyMarXbot();
91  return wheelsCtrl;
92  };
95  return proximityIR;
96  }
99  return groundBottomIR;
100  }
103  return groundAroundIR;
104  }
107  return tractionSensor;
108  }
113  virtual void preUpdate();
118  virtual void postUpdate();
120  void setProximityIRSensorsGraphicalProperties(bool drawSensor, bool drawRay = false, bool drawRealRay = false);
122  void setGroundBottomIRSensorsGraphicalProperties(bool drawSensor, bool drawRay = false, bool drawRealRay = false);
124  void setGroundAroundIRSensorsGraphicalProperties(bool drawSensor, bool drawRay = false, bool drawRealRay = false);
125 
126 
133  void doKinematicSimulation(bool k);
134 
137  bool isKinematic() const
138  {
139  return kinematicSimulation;
140  }
141  public slots:
142 
143  protected slots:
153  void setLeftWheelDesideredVelocity(real velocity);
154 
164  void setRightWheelDesideredVelocity(real velocity);
165 
166  protected:
168  virtual void changedMatrix();
169 
170  private:
172  PhyObject* base;
174  QVector<PhyObject*> wheels;
176  QVector<wMatrix> wheelstm;
178  QVector<PhyJoint*> wheelJoints;
180  WheelMotorController* wheelsCtrl;
182  PhyObject* attachring;
184  wMatrix attachringtm;
186  PhyFixed* forcesensor;
190  SimulatedIRGroundSensorController* groundBottomIR;
192  SimulatedIRGroundSensorController* groundAroundIR;
194  TractionSensorController* tractionSensor;
196  bool kinematicSimulation;
198  real leftWheelVelocity;
200  real rightWheelVelocity;
201  };
202 } // end namespace farsa
203 
204 #endif