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 "graphicalwobject.h"
32 #include "phyhinge.h"
33 #include "phyfixed.h"
34 #include "phycylinder.h"
35 #include <QVector>
36 
37 namespace farsa {
38  class PhyObject;
39  class PhyJoint;
40  class PhyCylinder;
41  class PhyFixed;
42  class PhyHinge;
43 
55  class FARSA_WSIM_API PhyMarXbot : public WObject {
56  Q_OBJECT
57  public:
58  // Robot dimensions. Measures and masses in MKS
59 
60  // --- chassis containing the battery
61  static const real basex;
62  static const real basey;
63  static const real basez;
64  static const real basem;
65 
66  // --- cylinder body supporting infrared and other modules and turrets
67  static const real bodyr;
68  static const real bodyh;
69  static const real bodym;
70 
71  // --- inner part of the continous tracks (where the rubber tracks move on)
72  static const real axledistance;
73  static const real trackradius;
74  static const real trackheight;
75  static const real trackm;
76 
77  // --- the height of the treads on tracks and wheels
78  static const real treaddepth;
79 
80  // --- external wheels (the radius is excluding the tread height)
81  static const real wheelr;
82  static const real wheelh;
83  static const real wheelm;
84 
85  // --- height of the turret
86  static const real turreth;
87  static const real turretm;
88 
89  // --- dimensions of the attachment device
90  static const real attachdevr;
91  static const real attachdevx;
92  static const real attachdevy;
93  static const real attachdevz;
94  static const real attachdevm;
95 
96  public:
100  PhyMarXbot( World* world, QString name, const wMatrix& tm = wMatrix::identity() );
103  virtual ~PhyMarXbot();
106  return wheelsCtrl;
107  }
110  return attachdevCtrl;
111  }
114  return proximityIR;
115  }
118  return groundBottomIR;
119  }
122  return groundAroundIR;
123  }
126  return tractionSensor;
127  }
132  virtual void preUpdate();
137  virtual void postUpdate();
139  void setProximityIRSensorsGraphicalProperties(bool drawSensor, bool drawRay = false, bool drawRealRay = false);
141  void setGroundBottomIRSensorsGraphicalProperties(bool drawSensor, bool drawRay = false, bool drawRealRay = false);
143  void setGroundAroundIRSensorsGraphicalProperties(bool drawSensor, bool drawRay = false, bool drawRealRay = false);
144 
152  void setDrawFrontMarker(bool drawMarker);
153 
161  bool getDrawFrontMarker() const;
162 
171  void enableAttachmentDevice(bool enable);
172 
179  {
180  return (attachdev != NULL);
181  }
182 
190  void resetAttachmentDevice();
191 
199  {
200  return basev;
201  }
202 
210  {
211  return turretv;
212  }
213 
222  {
223  return attachdev;
224  }
225 
233  {
234  return attachdevjoint;
235  }
236 
243  void doKinematicSimulation(bool k);
244 
246  bool isKinematic() const
247  {
248  return kinematicSimulation;
249  }
250 
263  void setLedColors(QList<QColor> c);
264 
270  QList<QColor> ledColors() const;
271 
279  const QList<PhyCylinder::SegmentColor>& segmentsColor() const;
280 
281  public slots:
282 
283  protected slots:
293  void setLeftWheelDesideredVelocity(real velocity);
294 
304  void setRightWheelDesideredVelocity(real velocity);
305 
306  protected:
308  virtual void changedMatrix();
309 
310  private:
312  PhyObject* basev;
314  QVector<PhyObject*> wheels;
316  QVector<wMatrix> wheelstm;
318  QVector<PhyJoint*> wheelJoints;
320  WheelMotorController* wheelsCtrl;
323  PhyCylinder* turretv;
325  wMatrix turrettm;
327  PhyFixed* forcesensor;
330  PhyObject* attachdev;
332  wMatrix attachdevtm;
334  PhyHinge* attachdevjoint;
340  SimulatedIRGroundSensorController* groundBottomIR;
342  SimulatedIRGroundSensorController* groundAroundIR;
344  TractionSensorController* tractionSensor;
346  bool kinematicSimulation;
348  real leftWheelVelocity;
350  real rightWheelVelocity;
351 
358  GraphicalWObject* frontMarker;
359 
366  QList<QColor> ledColorsv;
367 
374  mutable QList<PhyCylinder::SegmentColor> uniformColor;
375  };
376 
377  namespace previous {
381  class FARSA_WSIM_API PhyMarXbot : public WObject {
382  Q_OBJECT
383  public:
384  // Robot dimensions. Measures and masses in MKS
385 
386  // --- chassis containing the battery
387  static const real basex;
388  static const real basey;
389  static const real basez;
390  static const real basem;
391 
392  // --- cylinder body supporting infrared and other modules and turrets
393  static const real bodyr;
394  static const real bodyh;
395  static const real bodym;
396 
397  // --- inner part of the continous tracks (where the rubber tracks move on)
398  static const real axledistance;
399  static const real trackradius;
400  static const real trackheight;
401  static const real trackm;
402 
403  // --- the height of the treads on tracks and wheels
404  static const real treaddepth;
405 
406  // --- external wheels (the radius is excluding the tread height)
407  static const real wheelr;
408  static const real wheelh;
409  static const real wheelm;
410 
411  // --- height of the attachment ring
412  static const real attachringh;
413  static const real attachringm;
414 
415  // --- module with 12 RGB LEDs
416  static const real ledsh;
417  static const real ledsradius;
418  static const real ledsm;
419 
420  public:
424  PhyMarXbot( World* world, QString name, const wMatrix& tm = wMatrix::identity() );
427  virtual ~PhyMarXbot();
430  return wheelsCtrl;
431  };
434  return proximityIR;
435  }
438  return groundBottomIR;
439  }
442  return groundAroundIR;
443  }
446  return tractionSensor;
447  }
452  virtual void preUpdate();
457  virtual void postUpdate();
459  void setProximityIRSensorsGraphicalProperties(bool drawSensor, bool drawRay = false, bool drawRealRay = false);
461  void setGroundBottomIRSensorsGraphicalProperties(bool drawSensor, bool drawRay = false, bool drawRealRay = false);
463  void setGroundAroundIRSensorsGraphicalProperties(bool drawSensor, bool drawRay = false, bool drawRealRay = false);
464 
465 
472  void doKinematicSimulation(bool k);
473 
476  bool isKinematic() const
477  {
478  return kinematicSimulation;
479  }
480  public slots:
481 
482  protected slots:
492  void setLeftWheelDesideredVelocity(real velocity);
493 
503  void setRightWheelDesideredVelocity(real velocity);
504 
505  protected:
507  virtual void changedMatrix();
508 
509  private:
511  PhyObject* base;
513  QVector<PhyObject*> wheels;
515  QVector<wMatrix> wheelstm;
517  QVector<PhyJoint*> wheelJoints;
519  WheelMotorController* wheelsCtrl;
521  PhyObject* attachring;
523  wMatrix attachringtm;
525  PhyFixed* forcesensor;
529  SimulatedIRGroundSensorController* groundBottomIR;
531  SimulatedIRGroundSensorController* groundAroundIR;
533  TractionSensorController* tractionSensor;
535  bool kinematicSimulation;
537  real leftWheelVelocity;
539  real rightWheelVelocity;
540  };
541  }
542 } // end namespace farsa
543 
544 #endif
PhyHinge * attachmentDeviceJoint()
Returns the joint of the attachment device.
Definition: phymarxbot.h:232
World's Object class.
Definition: wobject.h:39
static wMatrix identity()
create an identity matrix
Definition: wmatrix.h:460
The class modelling the motor for the attachment device of the MarXbot.
MarXbotAttachmentDeviceMotorController * attachmentDeviceController()
returns the motor controller for the attachment device
Definition: phymarxbot.h:109
The MarXbot robot.
Definition: phymarxbot.h:55
IRSensorController * groundAroundIRSensorController()
return the ground IR sensors on the base (just above the wheels)
Definition: phymarxbot.h:441
IRSensorController * groundBottomIRSensorController()
returns the ground IR sensors below the battery pack
Definition: phymarxbot.h:437
PhyFixed class.
Definition: phyfixed.h:43
SimulatedIRGroundSensorController * groundBottomIRSensorController()
returns the ground IR sensors below the battery pack
Definition: phymarxbot.h:117
TractionSensorController * tractionSensorController()
return traction sensor of the robot
Definition: phymarxbot.h:125
World class.
Definition: world.h:223
WheelMotorController * wheelsController()
returns the motor controller for the wheels
Definition: phymarxbot.h:429
wMatrix class
Definition: wmatrix.h:48
bool attachmentDeviceEnabled() const
Returns true if the attachment device is enabled.
Definition: phymarxbot.h:178
bool isKinematic() const
Returns true if we are using the kinematic model.
Definition: phymarxbot.h:476
PhyObject * turret()
Returns the solid modelling the turret of the robot.
Definition: phymarxbot.h:209
IRSensorController * proximityIRSensorController()
returns the proximity infrared sensors
Definition: phymarxbot.h:433
An helper class to draw stuffs in the world.
The base abstract class of sensor controllers for infrared sensors.
PhyObject * base()
Returns the solid modelling the base of the robot.
Definition: phymarxbot.h:198
A collection of SingleIR modelling ground sensors.
float real
The controller for traction sensor.
SimulatedIRProximitySensorController * proximityIRSensorController()
returns the proximity infrared sensors
Definition: phymarxbot.h:113
TractionSensorController * tractionSensorController()
return traction sensor of the robot
Definition: phymarxbot.h:445
PhyCylinder class.
Definition: phycylinder.h:53
PhyObject * attachmentDevice()
Returns the solid modelling the attachment device.
Definition: phymarxbot.h:221
Dedicated controller for wheeled robots.
SimulatedIRGroundSensorController * groundAroundIRSensorController()
return the ground IR sensors on the base (just above the wheels)
Definition: phymarxbot.h:121
bool isKinematic() const
Returns true if we are using the kinematic model.
Definition: phymarxbot.h:246
PhyObject class.
Definition: phyobject.h:46
MarXbot class The marXbot represent an marXbot robot.
Definition: phymarxbot.h:381
PhyHinge class.
Definition: phyhinge.h:43
WheelMotorController * wheelsController()
returns the motor controller for the wheels
Definition: phymarxbot.h:105