se2ez
scene.h
Go to the documentation of this file.
1 /* Author: Constantinos Chamzas */
2 
3 #ifndef SE2EZ_CORE_SCENE_
4 #define SE2EZ_CORE_SCENE_
5 
6 #include <map>
7 #include <vector>
8 
10 #include <se2ez/core/math.h>
11 
12 namespace se2ez
13 {
14  /** \cond IGNORE */
15  SE2EZ_CLASS_FORWARD(State)
16  SE2EZ_CLASS_FORWARD(Robot)
17  /** \endcond */
18 
19  /** \cond IGNORE */
20  SE2EZ_CLASS_FORWARD(Scene)
21  /** \endcond */
22 
23  /** \class se2ez::ScenePtr
24  \brief A shared pointer wrapper for se2ez::Scene. */
25 
26  /** \class se2ez::SceneConstPtr
27  \brief A const shared pointer wrapper for se2ez::Scene. */
28 
29  /** \brief A representation of a Scene (in this case, one active robot and multiple passive robots (with
30  * all joints fixed representing the obstacles).
31  */
32  class Scene
33  {
34  public:
35  struct RobotData
36  {
37  const RobotPtr robot; ///< Underlying robot.
38  const StatePtr state; ///< Underlying state of the robot.
39 
40  /** \brief Constructor.
41  * \param[in] r Robot to store.
42  * \param[in] s State associated with robot.
43  */
44  RobotData(const RobotPtr &r, const StatePtr &s);
45  };
46 
47  /** \brief Constructor. Nothing interesting right now.
48  */
49  Scene(const RobotPtr &arobot);
50 
51  // non-copyable
52  Scene(const Scene &) = delete;
53  Scene(Scene &&) = delete;
54 
55  /** \name Scene Management
56  \{ */
57 
58  /** \brief Attach a robot as passive to the scene at a zero state.
59  * \param[in] robot Robot to attach.
60  * \param[in] name Name of the robot.
61  */
62  void addRobot(const RobotPtr &robot, const std::string &name);
63 
64  /** \brief Attach a robot as passive to the scene with given state
65  * \param[in] robot Robot to attach.
66  * \param[in] name Name of the robot.
67  * \param[in] state State of the attached Frame.
68  */
69  void addRobot(const RobotPtr &robot, const std::string &name, const StatePtr &state);
70 
71  /** \brief creates the scene, is called after a robot is added.
72  */
73  void compileScene();
74 
75  /** \brief Removes the specific robot from the Scene.
76  */
77  void removeRobot(const std::string &name);
78 
79  /** \brief Completely clears internal structures, a brand new scene!
80  */
81  void clear();
82 
83  /** \brief Completely clears the passive robots!
84  */
85  void clearPassive();
86 
87  /** \} */
88 
89  /** \name Getters and Setters
90  \{ */
91 
92  /** \brief Returns a the active robot.
93  * \return Active Robot.
94  */
95  const RobotPtr &getActiveRobot();
96 
97  /** \brief Returns a new aggregated robot including all the passive and active robots
98  * \return MegaRobot.
99  */
100  const RobotPtr &getSceneRobot();
101 
102  /** \brief Returns the mrobot signature.
103  * \return signature of the mega-robot.
104  */
105  const std::string &getSignature();
106 
107  /** \brief Returns robot the robot named name, throws error otherwise.
108  * \return RobotPtr to that robot.
109  */
110  const RobotPtr &getRobot(const std::string &name);
111 
112  /** \brief Gets the all the names of the robots active and passive.
113  * \return Vector of all robots in the Scene.
114  */
115  const std::vector<std::string> getRobotNames();
116 
117  /** \brief Sets a state for a robot.
118  * \param[in] name Name of state to set.
119  * \param[in] state State to set named state to.
120  */
121  void setRobotState(const std::string &name, const StatePtr &state);
122 
123  /** \brief Sets every passive robot to a random state.
124  */
125  void setRandom();
126 
127  /** \brief get the state for a robot.
128  * \param[in] name Name of state to set.
129  * \param[in] state State to set named state to.
130  */
131  void getNamedRobot(const std::string &name, const StatePtr &state);
132 
133  /** \} */
134 
135  bool dirty{false}; ///< Does the scene robot need updating?
136 
137  private:
138  std::map<std::string, RobotData> robots_; ///< Map of robots and their names.
139  const RobotPtr arobot_; ///< Active Robot
140  RobotPtr mrobot_; ///< Mega Robot
141  };
142 } // namespace se2ez
143 
144 #endif
A shared pointer wrapper for se2ez::State.
A representation of a Scene (in this case, one active robot and multiple passive robots (with all joi...
Definition: scene.h:32
const RobotPtr robot
Underlying robot.
Definition: scene.h:37
std::map< std::string, RobotData > robots_
Map of robots and their names.
Definition: scene.h:138
const StatePtr state
Underlying state of the robot.
Definition: scene.h:38
A shared pointer wrapper for se2ez::Robot.
Main namespace.
Definition: collision.h:11
const RobotPtr arobot_
Active Robot.
Definition: scene.h:139
#define SE2EZ_CLASS_FORWARD(C)
Definition: class_forward.h:9
RobotPtr mrobot_
Mega Robot.
Definition: scene.h:140