GAMS  1.4.0
BaseAlgorithm.h
Go to the documentation of this file.
1 
54 #ifndef _GAMS_ALGORITHMS_BASE_ALGORITHM_H_
55 #define _GAMS_ALGORITHMS_BASE_ALGORITHM_H_
56 
57 #include "gams/variables/Sensor.h"
60 #include "gams/variables/Self.h"
61 #include "gams/pose/Region.h"
62 #include "madara/knowledge/KnowledgeBase.h"
63 
65 
66 #include <vector>
67 
68 namespace gams
69 {
70  namespace controllers
71  {
72  class BaseController;
73  class Multicontroller;
74  }
75 
76  namespace algorithms
77  {
82  {
83  UNKNOWN = 0x00000000,
84  OK = 0x00000001,
85  WAITING = 0x00000002,
86  DEADLOCKED = 0x00000004,
87  FAILED = 0x00000008,
88  FINISHED = 0x00000010
89  };
90 
95  {
96  public:
97  // allow Base controller to initialize our variables
100 
110  madara::knowledge::KnowledgeBase * knowledge = 0,
111  platforms::BasePlatform * platform = 0,
112  variables::Sensors * sensors = 0,
113  variables::Self * self = 0,
114  variables::Agents * agents = 0);
115 
119  virtual ~BaseAlgorithm();
120 
125  void operator=(const BaseAlgorithm & rhs);
126 
131  virtual int analyze(void) = 0;
132 
137  virtual int execute(void) = 0;
138 
143  virtual int plan(void) = 0;
144 
149  virtual void set_agents(variables::Agents * agents);
150 
155  virtual void set_platform(platforms::BasePlatform * platform);
156 
161  virtual void set_self(variables::Self * self);
162 
167  virtual void set_sensors(variables::Sensors * sensors);
168 
173 
177  madara::knowledge::KnowledgeBase * get_knowledge_base(void);
178 
183 
188 
193 
198 
199  protected:
202 
204  unsigned int executions_;
205 
207  madara::knowledge::KnowledgeBase * knowledge_;
208 
211 
214 
217 
220  };
221 
222  // deprecated typdef. Please use BaseAlgorithm instead.
224 
225  typedef std::vector <BaseAlgorithm *> Algorithms;
226  }
227 }
228 
229 #endif // _GAMS_VARIABLES_SWARM_H_
Copyright(c) 2014 Carnegie Mellon University.
#define GAMS_EXPORT
Definition: GamsExport.h:20
Copyright(c) 2014 Carnegie Mellon University.
Copyright(c) 2014 Carnegie Mellon University.
The base class that algorithms in GAMS use.
Definition: BaseAlgorithm.h:95
variables::Agents * get_agents(void)
Gets the list of agents.
platforms::BasePlatform * platform_
provides access to the platform
variables::Agents * agents_
the list of agents potentially participating in the algorithm
madara::knowledge::KnowledgeBase * knowledge_
provides access to the knowledge base
virtual ~BaseAlgorithm()
Destructor.
virtual int execute(void)=0
Plans the next execution of the algorithm.
platforms::BasePlatform * get_platform(void)
Gets the platform.
variables::Self * get_self(void)
Gets self-defined variables.
variables::Sensors * sensors_
provides access to sensor information
variables::AlgorithmStatus * get_algorithm_status(void)
Gets algorithm status variables.
virtual int plan(void)=0
Plans the next execution of the algorithm.
virtual int analyze(void)=0
Analyzes environment, platform, or other information.
virtual void set_sensors(variables::Sensors *sensors)
Sets the map of sensor names to sensor information.
variables::Self * self_
the algorithm's concept of self
virtual void set_agents(variables::Agents *agents)
Sets the list of agents in the swarm.
variables::Sensors * get_sensors(void)
Gets the available sensor information.
unsigned int executions_
number of executions
variables::AlgorithmStatus status_
provides access to status information for this platform
BaseAlgorithm(madara::knowledge::KnowledgeBase *knowledge=0, platforms::BasePlatform *platform=0, variables::Sensors *sensors=0, variables::Self *self=0, variables::Agents *agents=0)
Constructor.
virtual void set_self(variables::Self *self)
Sets the map of sensor names to sensor information.
virtual void set_platform(platforms::BasePlatform *platform)
Sets the platform.
void operator=(const BaseAlgorithm &rhs)
Assignment operator.
madara::knowledge::KnowledgeBase * get_knowledge_base(void)
Gets the knowledge base.
The basic controller that can be used to perform actions on platforms and algorithms.
A controller that has the capability of managing multiple controllers.
The base platform for all platforms to use.
Definition: BasePlatform.h:113
A container for algorithm status information.
A container for self referencing information.
Definition: Self.h:70
AlgorithmAnalyzeStatus
Possible algorithm statuses, as returnable by analyze()
Definition: BaseAlgorithm.h:82
BaseAlgorithm Base
std::vector< BaseAlgorithm * > Algorithms
std::map< std::string, Sensor * > Sensors
a map of sensor names to the sensor information
Definition: Sensor.h:238
std::vector< Agent > Agents
An array of agent knowledge.
Definition: Agent.h:246
Contains all GAMS-related tools, classes and code.
Copyright(c) 2014 Carnegie Mellon University.