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 "wheeledexperimenthelper.h"
34 
35 namespace farsa {
36 
42  class FARSA_EXPERIMENTS_TEMPLATE Robot : public ParameterSettableInConstructor
43 {
44 public:
55  Robot(ConfigurationParameters& params, QString prefix) :
56  ParameterSettableInConstructor(params, prefix)
57  {
58  }
59 
63  virtual ~Robot()
64  {
65  }
66 };
67 
68 #ifdef FARSA_USE_YARP_AND_ICUB
69 
74 class FARSA_EXPERIMENTS_API iCubRobot : public Robot, public PhyiCub
75 {
76 public:
77 
88  iCubRobot(ConfigurationParameters& params, QString prefix);
89 
100  virtual void save(ConfigurationParameters& params, QString prefix);
101 
109  static void describe(QString type);
110 
114  virtual ~iCubRobot();
115 };
116 #endif // FARSA_USE_YARP_AND_ICUB
117 
125 class FARSA_EXPERIMENTS_API RobotOnPlane : public Robot
126 {
127 public:
128 
139  RobotOnPlane(ConfigurationParameters& params, QString prefix);
140 
151  virtual void save(ConfigurationParameters& params, QString prefix);
152 
160  static void describe(QString type);
161 
165  virtual ~RobotOnPlane();
166 
177  void setPosition(const Box2DWrapper* plane, const wVector& pos);
178 
189  virtual void setPosition(const Box2DWrapper* plane, real x, real y) = 0;
190 
196  virtual wVector position() const = 0;
197 
209  virtual void setOrientation(const Box2DWrapper* plane, real angle) = 0;
210 
221  virtual real orientation(const Box2DWrapper* plane) const = 0;
222 
223 protected:
231  static wVector positionOnPlane(const Box2DWrapper* plane, real x, real y);
232 
247  static void orientationOnPlane(const Box2DWrapper* plane, real angle, wMatrix& mtr);
248 
260  static real angleBetweenXAxes(const wMatrix& mtr1, const wMatrix& mtr2);
261 };
262 
268 class FARSA_EXPERIMENTS_API MarXbot : public RobotOnPlane, public PhyMarXbot
269 {
270 public:
271 
282  MarXbot(ConfigurationParameters& params, QString prefix);
283 
294  virtual void save(ConfigurationParameters& params, QString prefix);
295 
303  static void describe(QString type);
304 
308  virtual ~MarXbot();
309 
320  virtual void setPosition(const Box2DWrapper* plane, real x, real y);
321 
327  virtual wVector position() const;
328 
340  virtual void setOrientation(const Box2DWrapper* plane, real angle);
341 
352  virtual real orientation(const Box2DWrapper* plane) const;
353 };
354 
360 class FARSA_EXPERIMENTS_API Epuck : public RobotOnPlane, public PhyEpuck
361 {
362 public:
363 
374  Epuck(ConfigurationParameters& params, QString prefix);
375 
386  virtual void save(ConfigurationParameters& params, QString prefix);
387 
395  static void describe(QString type);
396 
400  virtual ~Epuck();
401 
412  virtual void setPosition(const Box2DWrapper* plane, real x, real y);
413 
419  virtual wVector position() const;
420 
432  virtual void setOrientation(const Box2DWrapper* plane, real angle);
433 
444  virtual real orientation(const Box2DWrapper* plane) const;
445 };
446 
447 } //end namespace farsa
448 
449 #endif