GAMS  1.2.2
BasePlatform.h
Go to the documentation of this file.
1 
54 #ifndef _GAMS_PLATFORM_BASE_H_
55 #define _GAMS_PLATFORM_BASE_H_
56 
57 #include <string>
58 
59 #include "gams/variables/Self.h"
60 #include "gams/variables/Sensor.h"
64 #include "gams/pose/Position.h"
65 #include "gams/pose/Pose.h"
66 #include "madara/knowledge/KnowledgeBase.h"
67 
68 namespace gams
69 {
70  namespace controllers
71  {
72  class BaseController;
73  class Multicontroller;
74  }
75 
76  namespace platforms
77  {
82  {
83  UNKNOWN = 0,
84  OK = 1,
85  WAITING = 2,
87  FAILED = 8,
88  MOVING = 16,
94  };
95 
100  {
106  };
107 
110  public:
113  virtual bool check_position(
114  const pose::Position &current,
115  const pose::Position &target) const = 0;
116 
117  virtual ~PositionBounds() = default;
118  };
119 
122  public:
125  virtual bool check_orientation(
126  const pose::Orientation &current,
127  const pose::Orientation &target) const = 0;
128 
129  virtual ~OrientationBounds() = default;
130  };
131 
135  public PositionBounds, public OrientationBounds {};
136 
142  class GAMS_EXPORT Epsilon : public PoseBounds {
143  private:
144  double dist_ = 0.1, radians_ = M_PI/16;
145  public:
147  Epsilon() {}
148 
152  Epsilon(double dist)
153  : dist_(dist) {}
154 
159  Epsilon(double dist, double radians)
160  : dist_(dist), radians_(radians) {}
161 
168  //
170  template<typename AngleUnits>
171  Epsilon(double dist, double angle, AngleUnits u)
172  : dist_(dist), radians_(u.to_radians(angle)) {}
173 
175  const pose::Position &current,
176  const pose::Position &target) const override {
177  return current.distance_to(target) <= dist_;
178  }
179 
181  const pose::Orientation &current,
182  const pose::Orientation &target) const override {
183  return fabs(current.angle_to(target)) <= radians_;
184  }
185  };
186 
191  {
192  public:
193  // allow Base controller to initialize our variables
196 
203  BasePlatform (
204  madara::knowledge::KnowledgeBase * knowledge = 0,
205  variables::Sensors * sensors = 0,
206  variables::Self * self = 0);
207 
211  virtual ~BasePlatform ();
212 
217  void operator= (const BasePlatform & rhs);
218 
223  virtual int analyze (void) = 0;
224 
229  virtual double get_accuracy (void) const;
230 
235  utility::Position * get_position ();
236 
241  pose::Position get_location () const;
242 
247  pose::Orientation get_orientation () const;
248 
253  pose::Pose get_pose () const;
254 
258  virtual std::string get_name () const = 0;
259 
265  virtual std::string get_id () const = 0;
266 
271  virtual double get_min_sensor_range () const;
272 
276  virtual double get_move_speed () const;
277 
283  virtual const variables::Sensor & get_sensor (const std::string& name) const;
284 
289  virtual void get_sensor_names (variables::SensorNames & sensors) const;
290 
295  virtual int home (void);
296 
301  virtual int land (void);
302 
308  virtual int move (const pose::Position & target) {
309  return move (target, Epsilon());
310  }
311 
318  virtual int move (const pose::Position & target,
319  const PositionBounds &bounds);
320 
327  int move (const pose::Position & target, double epsilon) {
328  return move (target, Epsilon(epsilon));
329  }
330 
336  virtual int orient (const pose::Orientation & target) {
337  return orient (target, Epsilon());
338  }
339 
346  virtual int orient (const pose::Orientation & target,
347  const OrientationBounds &bounds);
348 
355  int orient (const pose::Orientation & target, double epsilon) {
356  return orient(target, Epsilon (epsilon));
357  }
358 
374  virtual int pose (const pose::Pose & target) {
375  return pose (target, Epsilon());
376  }
377 
394  virtual int pose (const pose::Pose & target, const PoseBounds &bounds);
395 
413  int pose (const pose::Pose & target,
414  double loc_epsilon, double rot_epsilon = M_PI/16) {
415  return pose(target, Epsilon(loc_epsilon, rot_epsilon));
416  }
417 
421  virtual void pause_move (void);
422 
427  virtual int sense (void) = 0;
428 
433  void set_knowledge (madara::knowledge::KnowledgeBase * rhs);
434 
439  virtual void set_move_speed (const double& speed);
440 
445  virtual void set_sensors (variables::Sensors * sensors);
446 
450  virtual void stop_move (void);
451 
455  virtual void resume_move (void);
456 
460  virtual void resume_orientation (void);
461 
465  virtual void stop_orientation (void);
466 
471  virtual int takeoff (void);
472 
477  madara::knowledge::KnowledgeBase * get_knowledge_base (void) const;
478 
483  variables::Self * get_self (void) const;
484 
489  variables::Sensors * get_sensors (void) const;
490 
495  variables::PlatformStatus * get_platform_status (void);
496 
501  const variables::PlatformStatus * get_platform_status (void) const;
502 
510  virtual const pose::ReferenceFrame & get_frame (void) const;
511 
512  protected:
514  double move_speed_;
515 
517  madara::knowledge::KnowledgeBase * knowledge_;
518 
521 
524 
527 
529  //static pose::GPSFrame frame_;
530  };
531 
532  // deprecated typdef. Please use BasePlatform instead.
534  }
535 }
536 
537 #include "BasePlatform.inl"
538 
539 #endif // _GAMS_PLATFORM_BASE_H_
Interface for defining a bounds checker for Poses, a combination of position and orientation checking...
Definition: BasePlatform.h:134
bool check_orientation(const pose::Orientation &current, const pose::Orientation &target) const override
Override to return whether the current orientation is within the expected bounds of target...
Definition: BasePlatform.h:180
Interface for defining a bounds checker for Orientations.
Definition: BasePlatform.h:121
static const detail::radians_t radians
Radians unit flag; see Euler constructor.
Definition: AngleUnits.h:87
variables::PlatformStatus status_
provides access to status information for this platform
Definition: BasePlatform.h:526
virtual int pose(const pose::Pose &target)
Moves the platform to a pose (location and orientation)
Definition: BasePlatform.h:374
A container for sensor information.
Definition: Sensor.h:80
Epsilon(double dist, double angle, AngleUnits u)
Use specified tolerances, with custom angle units.
Definition: BasePlatform.h:171
std::map< std::string, Sensor * > Sensors
a map of sensor names to the sensor information
Definition: Sensor.h:238
The base platform for all platforms to use.
Definition: BasePlatform.h:190
Copyright (c) 2014 Carnegie Mellon University.
variables::Self * self_
provides access to self state
Definition: BasePlatform.h:520
A simple bounds checker which tests whether the current position is within the given number of meters...
Definition: BasePlatform.h:142
Epsilon(double dist)
Use default value for angle tolerance.
Definition: BasePlatform.h:152
PlatformAnalyzeStatus
Possible platform statuses, as returnable by analyze ()
Definition: BasePlatform.h:81
Copyright (c) 2014 Carnegie Mellon University.
double distance_to(const derived_type &target) const
Calculate distance from this Coordinate to a target.
Interface for defining a bounds checker for Positions.
Definition: BasePlatform.h:109
bool check_position(const pose::Position &current, const pose::Position &target) const override
Override to return whether the current position is within the expected bounds of target.
Definition: BasePlatform.h:174
virtual int orient(const pose::Orientation &target)
Rotates the platform to match a given angle.
Definition: BasePlatform.h:336
Contains all GAMS-related tools, classes and code.
Epsilon(double dist, double radians)
Use specified tolerances.
Definition: BasePlatform.h:159
A container for self referencing information.
Definition: Self.h:69
Copyright (c) 2014 Carnegie Mellon University.
PlatformReturnValues
Platform return values.
Definition: BasePlatform.h:99
variables::Sensors * sensors_
provides access to a sensor
Definition: BasePlatform.h:523
int orient(const pose::Orientation &target, double epsilon)
Rotates the platform to match a given angle.
Definition: BasePlatform.h:355
#define GAMS_EXPORT
Definition: GamsExport.h:20
Epsilon()
Use default values for position and angle tolerance.
Definition: BasePlatform.h:147
virtual int move(const pose::Position &target)
Moves the platform to a location.
Definition: BasePlatform.h:308
madara::knowledge::KnowledgeBase * knowledge_
provides access to variables and values
Definition: BasePlatform.h:517
std::vector< std::string > SensorNames
a list of sensor names
Definition: Sensor.h:241
The basic controller that can be used to perform actions on platforms and algorithms.
A controller that has the capability of starting many different threads.
Provides Reference Frame (i.e., coordinate systemm) transforms.
double move_speed_
movement speed for platform in meters/second
Definition: BasePlatform.h:514
A position in an x, y, z coordinate system.
Definition: Position.h:77
int pose(const pose::Pose &target, double loc_epsilon, double rot_epsilon=M_PI/16)
Moves the platform to a pose (location and orientation)
Definition: BasePlatform.h:413
Copyright (c) 2014 Carnegie Mellon University.
A container for platform status information.
int move(const pose::Position &target, double epsilon)
Moves the platform to a location.
Definition: BasePlatform.h:327
BasePlatform Base
Definition: BasePlatform.h:533