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 
207  virtual real orientation(const Box2DWrapper* plane) const = 0;
208 
217  virtual real robotHeight() const = 0;
218 
227  virtual real robotRadius() const = 0;
228 
234  virtual bool isKinematic() const = 0;
235 
241  virtual QColor robotColor() const = 0;
242 
243 protected:
250  const QColor& configuredRobotColor() const
251  {
252  return m_color;
253  }
254 
255 private:
260  const QColor m_color;
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 
355  virtual real orientation(const Box2DWrapper* plane) const;
356 
365  virtual real robotHeight() const;
366 
375  virtual real robotRadius() const;
376 
382  virtual bool isKinematic() const;
383 
389  virtual QColor robotColor() const;
390 };
391 
397 class FARSA_EXPERIMENTS_API Epuck : public RobotOnPlane, public PhyEpuck
398 {
399 public:
400 
411  Epuck(ConfigurationParameters& params, QString prefix);
412 
423  virtual void save(ConfigurationParameters& params, QString prefix);
424 
432  static void describe(QString type);
433 
437  virtual ~Epuck();
438 
449  virtual void setPosition(const Box2DWrapper* plane, real x, real y);
450 
456  virtual wVector position() const;
457 
469  virtual void setOrientation(const Box2DWrapper* plane, real angle);
470 
484  virtual real orientation(const Box2DWrapper* plane) const;
485 
494  virtual real robotHeight() const;
495 
504  virtual real robotRadius() const;
505 
511  virtual bool isKinematic() const;
512 
518  virtual QColor robotColor() const;
519 };
520 
526 class FARSA_EXPERIMENTS_API Khepera : public RobotOnPlane, public PhyKhepera
527 {
528 public:
529 
540  Khepera(ConfigurationParameters& params, QString prefix);
541 
552  virtual void save(ConfigurationParameters& params, QString prefix);
553 
561  static void describe(QString type);
562 
566  virtual ~Khepera();
567 
578  virtual void setPosition(const Box2DWrapper* plane, real x, real y);
579 
585  virtual wVector position() const;
586 
598  virtual void setOrientation(const Box2DWrapper* plane, real angle);
599 
613  virtual real orientation(const Box2DWrapper* plane) const;
614 
623  virtual real robotHeight() const;
624 
633  virtual real robotRadius() const;
634 
640  virtual bool isKinematic() const;
641 
647  virtual QColor robotColor() const;
648 };
649 
650 } //end namespace farsa
651 
652 #endif
wMatrix extractRobotTranformation(ConfigurationParameters &params, QString prefix)
Gets the transformation matrix of the robot.
Definition: robots.cpp:50
The subclass of PhyObject2DWrapper wrapping a box.
const QColor & configuredRobotColor() const
Returns the robot color specified by the configuration parameter.
Definition: robots.h:250
The base class for robots that move on a plane.
Definition: robots.h:108
An abstract class for robots.
Definition: robots.h:74
The class modelling the e-puck robot.
Definition: robots.h:397
This file contains the common type defitions used on the whole framework.
World * extractWorld(ConfigurationParameters &params)
Gets the resource for world.
Definition: robots.cpp:34
QString extractRobotName(ConfigurationParameters &params, QString prefix, QString defaultName)
Gets the name of the robot.
Definition: robots.cpp:45
float real
The class modelling the marXbot robot.
Definition: robots.h:268
virtual ~Robot()
Destructor.
Definition: robots.h:95
Robot(ConfigurationParameters &params, QString prefix)
Constructor.
Definition: robots.h:87
The class modelling the Khepera robot.
Definition: robots.h:526