Parasol Planning Library (PPL)
RobotGroup.h
Go to the documentation of this file.
1 #ifndef PMPL_ROBOT_GROUP_H_
2 #define PMPL_ROBOT_GROUP_H_
3 
4 #include <iostream>
5 #include <string>
6 #include <vector>
7 #include <unordered_map>
8 
9 class MPProblem;
10 class Robot;
11 class XMLNode;
12 
13 
17 class RobotGroup final {
18 
19  public:
20 
23 
24  typedef std::vector<Robot*>::iterator iterator;
25  typedef std::vector<Robot*>::const_iterator const_iterator;
26 
30 
35  RobotGroup(MPProblem* const _problem, const std::string& _label,
36  const std::vector<Robot*>& _robots);
37 
42  RobotGroup(MPProblem* const _problem, XMLNode& _node);
43 
47 
49  std::string GetLabel() const noexcept;
50 
52  Robot* GetRobot(const size_t _index) const noexcept;
53 
55  Robot* GetRobot(const std::string& _label) const noexcept;
56 
58  const std::vector<Robot*>& GetRobots() const noexcept;
59 
62  size_t GetGroupIndex(Robot* const _robot) const noexcept;
63 
65  bool VerifyRobotInGroup(Robot* const _robot) const noexcept;
66 
68  size_t Size() const noexcept;
69 
71  size_t TotalDofs() const noexcept;
72 
77 
78  iterator begin() noexcept;
79  iterator end() noexcept;
80 
81  const_iterator begin() const noexcept;
82  const_iterator end() const noexcept;
83 
85 
86  private:
87 
90 
91  MPProblem* const m_problem;
92  std::string m_label;
93 
94  std::vector<Robot*> m_robots;
95  std::unordered_map<Robot*, size_t> m_indexes;
96 
98 
99 };
100 
101 /*----------------------------------- Debug ----------------------------------*/
102 
103 std::ostream& operator<<(std::ostream&, const RobotGroup&);
104 
105 /*----------------------------------------------------------------------------*/
106 
107 #endif
Definition: MPProblem.h:34
A group of one or more robots.
Definition: RobotGroup.h:17
size_t GetGroupIndex(Robot *const _robot) const noexcept
Definition: RobotGroup.cpp:108
std::vector< Robot * >::iterator iterator
Definition: RobotGroup.h:24
std::string GetLabel() const noexcept
Get the group label.
Definition: RobotGroup.cpp:70
Robot * GetRobot(const size_t _index) const noexcept
Get a robot by index.
Definition: RobotGroup.cpp:77
size_t Size() const noexcept
Get the number of robots in the group.
Definition: RobotGroup.cpp:128
bool VerifyRobotInGroup(Robot *const _robot) const noexcept
Check whether the robot is in the group or not.
Definition: RobotGroup.cpp:121
iterator end() noexcept
Definition: RobotGroup.cpp:154
iterator begin() noexcept
Definition: RobotGroup.cpp:147
RobotGroup(MPProblem *const _problem, const std::string &_label, const std::vector< Robot * > &_robots)
Definition: RobotGroup.cpp:16
std::vector< Robot * >::const_iterator const_iterator
Definition: RobotGroup.h:25
size_t TotalDofs() const noexcept
Get the number of DOFs accumulated over all robots.
Definition: RobotGroup.cpp:135
const std::vector< Robot * > & GetRobots() const noexcept
Get all robots.
Definition: RobotGroup.cpp:101
Definition: Robot.h:31
Definition: XMLNode.h:27