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 "phymarxbot.h"
31 #include "phyepuck.h"
32 #include "phykhepera.h"
33 #include "wheeledexperimenthelper.h"
34 
35 namespace farsa {
36 
40 namespace robotConfigurationUtilities {
47  FARSA_EXPERIMENTS_API World* extractWorld(ConfigurationParameters& params);
48 
57  FARSA_EXPERIMENTS_API QString extractRobotName(ConfigurationParameters& params, QString prefix, QString defaultName);
58 
66  FARSA_EXPERIMENTS_API wMatrix extractRobotTranformation(ConfigurationParameters& params, QString prefix);
67 }
68 
74  class FARSA_EXPERIMENTS_TEMPLATE Robot : public ParameterSettableInConstructor
75 {
76 public:
87  Robot(ConfigurationParameters& params, QString prefix) :
88  ParameterSettableInConstructor(params, prefix)
89  {
90  }
91 
95  virtual ~Robot()
96  {
97  }
98 };
99 
108 class FARSA_EXPERIMENTS_API RobotOnPlane : public Robot
109 {
110 public:
111 
122  RobotOnPlane(ConfigurationParameters& params, QString prefix);
123 
134  virtual void save(ConfigurationParameters& params, QString prefix);
135 
143  static void describe(QString type);
144 
148  virtual ~RobotOnPlane();
149 
160  void setPosition(const Box2DWrapper* plane, const wVector& pos);
161 
172  virtual void setPosition(const Box2DWrapper* plane, real x, real y) = 0;
173 
179  virtual wVector position() const = 0;
180 
192  virtual void setOrientation(const Box2DWrapper* plane, real angle) = 0;
193 
204  virtual real orientation(const Box2DWrapper* plane) const = 0;
205 
214  virtual real robotHeight() const = 0;
215 
224  virtual real robotRadius() const = 0;
225 
231  virtual bool isKinematic() const = 0;
232 
238  virtual QColor robotColor() const = 0;
239 
240 protected:
247  const QColor& configuredRobotColor() const
248  {
249  return m_color;
250  }
251 
252 private:
257  const QColor m_color;
258 };
259 
265 class FARSA_EXPERIMENTS_API MarXbot : public RobotOnPlane, public PhyMarXbot
266 {
267 public:
268 
279  MarXbot(ConfigurationParameters& params, QString prefix);
280 
291  virtual void save(ConfigurationParameters& params, QString prefix);
292 
300  static void describe(QString type);
301 
305  virtual ~MarXbot();
306 
317  virtual void setPosition(const Box2DWrapper* plane, real x, real y);
318 
324  virtual wVector position() const;
325 
337  virtual void setOrientation(const Box2DWrapper* plane, real angle);
338 
349  virtual real orientation(const Box2DWrapper* plane) const;
350 
359  virtual real robotHeight() const;
360 
369  virtual real robotRadius() const;
370 
376  virtual bool isKinematic() const;
377 
383  virtual QColor robotColor() const;
384 };
385 
391 class FARSA_EXPERIMENTS_API Epuck : public RobotOnPlane, public PhyEpuck
392 {
393 public:
394 
405  Epuck(ConfigurationParameters& params, QString prefix);
406 
417  virtual void save(ConfigurationParameters& params, QString prefix);
418 
426  static void describe(QString type);
427 
431  virtual ~Epuck();
432 
443  virtual void setPosition(const Box2DWrapper* plane, real x, real y);
444 
450  virtual wVector position() const;
451 
463  virtual void setOrientation(const Box2DWrapper* plane, real angle);
464 
475  virtual real orientation(const Box2DWrapper* plane) const;
476 
485  virtual real robotHeight() const;
486 
495  virtual real robotRadius() const;
496 
502  virtual bool isKinematic() const;
503 
509  virtual QColor robotColor() const;
510 };
511 
517 class FARSA_EXPERIMENTS_API Khepera : public RobotOnPlane, public PhyKhepera
518 {
519 public:
520 
531  Khepera(ConfigurationParameters& params, QString prefix);
532 
543  virtual void save(ConfigurationParameters& params, QString prefix);
544 
552  static void describe(QString type);
553 
557  virtual ~Khepera();
558 
569  virtual void setPosition(const Box2DWrapper* plane, real x, real y);
570 
576  virtual wVector position() const;
577 
589  virtual void setOrientation(const Box2DWrapper* plane, real angle);
590 
601  virtual real orientation(const Box2DWrapper* plane) const;
602 
611  virtual real robotHeight() const;
612 
621  virtual real robotRadius() const;
622 
628  virtual bool isKinematic() const;
629 
635  virtual QColor robotColor() const;
636 };
637 
638 } //end namespace farsa
639 
640 #endif