GAMS  1.4.0
SCRIMMAGEBasePlatform.h
Go to the documentation of this file.
1 #ifdef _GAMS_SCRIMMAGE_
2 
3 #include "gams/variables/Self.h"
8 #include "madara/knowledge/KnowledgeBase.h"
10 #include "gams/pose/Position.h"
11 #include "gams/pose/Orientation.h"
12 #include "gams/pose/GPSFrame.h"
13 #include "madara/threads/Threader.h"
14 #include "madara/threads/BaseThread.h"
15 #include "madara/LockType.h"
16 #include "madara/knowledge/containers/Integer.h"
17 #include "madara/knowledge/containers/NativeDoubleVector.h"
18 
20 
21 #include <scrimmage/simcontrol/SimControl.h>
22 
23 namespace gams
24 {
25  namespace platforms
26  {
27  class SCRIMMAGEBasePlatform : public BasePlatform
28  {
29  public:
30  SCRIMMAGEBasePlatform(
31  madara::knowledge::KnowledgeBase * kb_,
32  gams::variables::Sensors * sensors_,
33  gams::variables::Self * self_
34  );
35 
36  virtual ~SCRIMMAGEBasePlatform();
37 
38  void operator=(const SCRIMMAGEBasePlatform & rhs);
39 
40  /*
41  Required implementations
42  */
43 
44  /*
45  Reads the state from the agent that this platform is controlling
46  */
47  virtual int sense(void) override;
48  virtual int analyze(void) override;
49  virtual std::string get_name() const override;
50 
51  /*
52  Returns the ID of the GAMS agent (SCRIMMAGEBasePlatform) used by controllers/algorithms
53  */
54  virtual std::string get_id() const override;
55 
56  /*
57  Platform actions required for Spell, Zone Coverage, Move.
58  */
59 
60  /*
61  \@desc Spawns an entity in the SCRIMMAGE simulator via a protobuf msg on the GenerateEntity topic presented by SimControl.cpp. At present, this spawns a copy of the entity at position 0 in the <entity> list provided by the default world.
62  */
63  void spawn_entity(void);
64 
65  /*
66  \@desc Used in determining how close to a waypoint/goal the robot needs to be before moving to the next point
67  */
68  virtual double get_accuracy() const override;
69 
70  /*
71  \@desc
72  */
73  virtual int move(const gams::pose::Position & target, const gams::pose::PositionBounds &bounds) override;
74 
75  /*
76  \@desc
77  */
78  virtual int orient(const gams::pose::Orientation & target, const gams::pose::OrientationBounds &bounds) override;
79  virtual const gams::pose::ReferenceFrame & get_frame(void) const override;
80 
81  /*
82  \@desc Returns the pointer to the SimControl object. One SimControl instance for all of the SCRIMMAGEBasePlatforms (singleton pattern)
83  */
84  static scrimmage::SimControl * get_simcontrol_instance()
85  {
86  return simcontrol;
87  }
88 
89  /*
90  \@desc Returns whether simcontrol was started with the run_threaded() option
91  */
92  static bool simcontrol_threaded()
93  {
94  return running_threaded;
95  }
96 
97  /*
98  \@desc Stored access of this agents ID, which is different from the ID used to access the SCRIMMAGE agent associated with this specific instance. SCRIMMAGE starts its non-spawned entity (the one specified in the world XML file) at 0, and all other spawned copies then start at 1 moving forward. To access the SCRIMMAGE agent, it will be self_id + 1 indexing, or, just use scrimmage_access_id below
99  */
100  madara::knowledge::KnowledgeRecord self_id;
101 
102  /*
103  \@desc The ID to access a SCRIMMAGE agent
104  */
105  int scrimmage_access_id;
106 
107  madara::threads::Threader threader_;
108 
109  /*
110  \@desc Static pointer to the SimControl object needed to interface with agents in the SCRIMMAGE simulator
111  */
112  static scrimmage::SimControl * simcontrol;
113 
114  /*
115  \@desc Specifies whether or not SimControl is running threaded
116  */
117  static bool running_threaded;
118 
119  /*
120  \@desc XML file the SimControl object loads from. Loaded into the KB at "worldfile"
121  */
122  static std::string world_file;
123 
124  };
125 
126 
130  class GAMS_EXPORT SCRIMMAGEBasePlatformFactory : public PlatformFactory
131  {
132  public:
133 
134  SCRIMMAGEBasePlatformFactory();
135 
136  virtual ~SCRIMMAGEBasePlatformFactory();
137 
152  virtual BasePlatform * create(
153  const madara::knowledge::KnowledgeMap & args,
154  madara::knowledge::KnowledgeBase * knowledge,
155  variables::Sensors * sensors,
156  variables::Platforms * platforms,
157  variables::Self * self);
158 
160  std::string type_;
161 
162  };
163 
164 
165  } // ns platforms end
166 } // ns gams end
167 
168 #endif // _GAMS_SCRIMMAGE_
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.
Copyright(c) 2014 Carnegie Mellon University.
Copyright(c) 2014 Carnegie Mellon University.
Interface for defining a bounds checker for Orientations.
Definition: Epsilon.h:80
Interface for defining a bounds checker for Positions.
Definition: Epsilon.h:68
Provides Reference Frame (i.e., coordinate systemm) transforms.
A container for self referencing information.
Definition: Self.h:70
std::map< std::string, PlatformStatus > Platforms
a map of sensor names to the sensor information
std::map< std::string, Sensor * > Sensors
a map of sensor names to the sensor information
Definition: Sensor.h:238
Contains all GAMS-related tools, classes and code.
Copyright (c) 2015 Carnegie Mellon University.
Copyright (c) 2015 Carnegie Mellon University.
Copyright (c) 2015 Carnegie Mellon University.
Copyright (c) 2015-2018 Carnegie Mellon University.