robots.h
1 /********************************************************************************
2  * FARSA Experiments Library *
3  * Copyright (C) 2007-2012 *
4  * Tomassino Ferrauto <tomassino.ferrauto@istc.cnr.it> *
5  * Stefano Nolfi <stefano.nolfi@istc.cnr.it> *
6  * Onofrio Gigliotta <onofrio.gigliotta@istc.cnr.it> *
7  * Gianluca Massera <emmegian@yahoo.it> *
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  * This program is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17  * GNU General Public License for more details. *
18  * *
19  * You should have received a copy of the GNU General Public License *
20  * along with this program; if not, write to the Free Software *
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
22  ********************************************************************************/
23 
24 #ifndef ROBOTS_H
25 #define ROBOTS_H
26 
27 #include "experimentsconfig.h"
28 #include "parametersettable.h"
29 #include "configurationparameters.h"
30 #include "phyicub.h"
31 #include "phymarxbot.h"
32 #include "phyepuck.h"
33 #include "phykhepera.h"
34 #include "wheeledexperimenthelper.h"
35 
36 namespace farsa {
37 
43  class FARSA_EXPERIMENTS_TEMPLATE Robot : public ParameterSettableInConstructor
44 {
45 public:
56  Robot(ConfigurationParameters& params, QString prefix) :
57  ParameterSettableInConstructor(params, prefix)
58  {
59  }
60 
64  virtual ~Robot()
65  {
66  }
67 };
68 
69 #ifdef FARSA_USE_YARP_AND_ICUB
70 
75 class FARSA_EXPERIMENTS_API iCubRobot : public Robot, public PhyiCub
76 {
77 public:
78 
89  iCubRobot(ConfigurationParameters& params, QString prefix);
90 
101  virtual void save(ConfigurationParameters& params, QString prefix);
102 
110  static void describe(QString type);
111 
115  virtual ~iCubRobot();
116 };
117 #endif // FARSA_USE_YARP_AND_ICUB
118 
126 class FARSA_EXPERIMENTS_API RobotOnPlane : public Robot
127 {
128 public:
129 
140  RobotOnPlane(ConfigurationParameters& params, QString prefix);
141 
152  virtual void save(ConfigurationParameters& params, QString prefix);
153 
161  static void describe(QString type);
162 
166  virtual ~RobotOnPlane();
167 
178  void setPosition(const Box2DWrapper* plane, const wVector& pos);
179 
190  virtual void setPosition(const Box2DWrapper* plane, real x, real y) = 0;
191 
197  virtual wVector position() const = 0;
198 
210  virtual void setOrientation(const Box2DWrapper* plane, real angle) = 0;
211 
222  virtual real orientation(const Box2DWrapper* plane) const = 0;
223 
232  virtual real robotHeight() const = 0;
233 
242  virtual real robotRadius() const = 0;
243 
249  virtual bool isKinematic() const = 0;
250 
251 protected:
259  static wVector positionOnPlane(const Box2DWrapper* plane, real x, real y);
260 
275  static void orientationOnPlane(const Box2DWrapper* plane, real angle, wMatrix& mtr);
276 
288  static real angleBetweenXAxes(const wMatrix& mtr1, const wMatrix& mtr2);
289 };
290 
296 class FARSA_EXPERIMENTS_API MarXbot : public RobotOnPlane, public PhyMarXbot
297 {
298 public:
299 
310  MarXbot(ConfigurationParameters& params, QString prefix);
311 
322  virtual void save(ConfigurationParameters& params, QString prefix);
323 
331  static void describe(QString type);
332 
336  virtual ~MarXbot();
337 
348  virtual void setPosition(const Box2DWrapper* plane, real x, real y);
349 
355  virtual wVector position() const;
356 
368  virtual void setOrientation(const Box2DWrapper* plane, real angle);
369 
380  virtual real orientation(const Box2DWrapper* plane) const;
381 
390  virtual real robotHeight() const;
391 
400  virtual real robotRadius() const;
401 
407  virtual bool isKinematic() const;
408 };
409 
415 class FARSA_EXPERIMENTS_API Epuck : public RobotOnPlane, public PhyEpuck
416 {
417 public:
418 
429  Epuck(ConfigurationParameters& params, QString prefix);
430 
441  virtual void save(ConfigurationParameters& params, QString prefix);
442 
450  static void describe(QString type);
451 
455  virtual ~Epuck();
456 
467  virtual void setPosition(const Box2DWrapper* plane, real x, real y);
468 
474  virtual wVector position() const;
475 
487  virtual void setOrientation(const Box2DWrapper* plane, real angle);
488 
499  virtual real orientation(const Box2DWrapper* plane) const;
500 
509  virtual real robotHeight() const;
510 
519  virtual real robotRadius() const;
520 
526  virtual bool isKinematic() const;
527 };
528 
534 class FARSA_EXPERIMENTS_API Khepera : public RobotOnPlane, public PhyKhepera
535 {
536 public:
537 
548  Khepera(ConfigurationParameters& params, QString prefix);
549 
560  virtual void save(ConfigurationParameters& params, QString prefix);
561 
569  static void describe(QString type);
570 
574  virtual ~Khepera();
575 
586  virtual void setPosition(const Box2DWrapper* plane, real x, real y);
587 
593  virtual wVector position() const;
594 
606  virtual void setOrientation(const Box2DWrapper* plane, real angle);
607 
618  virtual real orientation(const Box2DWrapper* plane) const;
619 
628  virtual real robotHeight() const;
629 
638  virtual real robotRadius() const;
639 
645  virtual bool isKinematic() const;
646 };
647 
648 } //end namespace farsa
649 
650 #endif