Parasol Planning Library (PPL)
Robot.h
Go to the documentation of this file.
1 #ifndef PMPL_ROBOT_H_
2 #define PMPL_ROBOT_H_
3 
4 #include "Control.h"
5 
6 #include <iostream>
7 #include <memory>
8 #include <string>
9 #include <vector>
10 #include <unordered_map>
11 
12 class Actuator;
13 class Body;
14 class Boundary;
15 class Cfg;
16 class CSpaceBoundingBox;
17 class MPProblem;
18 class MultiBody;
19 class XMLNode;
20 
21 
31 class Robot final {
32 
35 
36  MPProblem* m_problem{nullptr};
37 
38  std::unique_ptr<MultiBody> m_multibody;
39 
41  std::unordered_map<std::string, std::unique_ptr<Actuator>> m_actuators;
42  std::unique_ptr<CSpaceBoundingBox> m_cspace;
43  std::unique_ptr<CSpaceBoundingBox> m_vspace;
44 
45  std::string m_label;
46  bool m_virtual{false};
47  bool m_nonholonomic{false};
48  bool m_carlike{false};
49  double m_maxLinearVelocity{10};
50  double m_maxAngularVelocity{1};
51  std::string m_capability;
52  bool m_fixed{false};
53  bool m_manipulator{false};
54  std::string m_defaultStrategyLabel;
55 
66  struct EndEffector {
67  EndEffector() {}
68  EndEffector(XMLNode& _node, MultiBody* const _mb);
69 
71  Body* effectorBody{nullptr};
72 
74  mathtool::Vector3d contactPoint;
75 
78  mathtool::Vector3d centerToContactDir;
79  };
80 
81  EndEffector m_endEffector;
82 
84 
85  public:
86 
89 
93  Robot(MPProblem* const _p, XMLNode& _node);
94 
98  Robot(MPProblem* const _p, std::unique_ptr<MultiBody>&& _mb,
99  const std::string& _label);
100 
104  Robot(MPProblem* const _p, const Robot& _r);
105 
106  ~Robot() noexcept;
107 
115 
116  Robot(const Robot&) = delete;
117  Robot(Robot&&) = delete;
118 
119  Robot& operator=(const Robot&) = delete;
120  Robot& operator=(Robot&&) = delete;
121 
123 
124  protected:
125 
128 
131  void ReadXMLFile(const std::string& _filename);
132 
135  void ReadXMLNode(XMLNode& _node);
136 
139  void ReadMultiBodyXML(XMLNode& _node);
140 
143  void ReadMultibodyFile(const std::string& _filename);
144 
146 
147  public:
148 
151 
154 
156  const CSpaceBoundingBox* GetCSpace() const noexcept;
157 
159  const CSpaceBoundingBox* GetVSpace() const noexcept;
160 
162  MPProblem* GetMPProblem() const noexcept;
163 
169 
170  MultiBody* GetMultiBody() noexcept;
171  const MultiBody* GetMultiBody() const noexcept;
172 
174  const EndEffector& GetEndEffector() const noexcept;
175 
181 
184  Actuator* GetActuator(const std::string& _label) noexcept;
186  const std::unordered_map<std::string, std::unique_ptr<Actuator>>&
187  GetActuators() const noexcept;
188 
192 
196  bool IsVirtual() const noexcept;
197 
200  void SetVirtual(const bool _v) noexcept;
201 
203  bool IsNonholonomic() const noexcept;
204 
206  bool IsCarlike() const noexcept;
207 
209  double GetMaxLinearVelocity() const noexcept;
210 
212  double GetMaxAngularVelocity() const noexcept;
213 
215  const std::string& GetLabel() const noexcept;
216 
218  const std::string& GetDefaultStrategyLabel() const noexcept;
219 
221  const std::string& GetCapability() const noexcept;
222 
224  void SetCapability(const std::string& _capability);
225 
227  bool IsManipulator() const noexcept;
228 
230  bool IsFixed() const noexcept;
231 
235  void SetInitialCfg(Cfg _cfg);
237 
238 
239 };
240 
241 /*----------------------------------- Debug ----------------------------------*/
242 
243 std::ostream& operator<<(std::ostream&, const Robot&);
244 
245 /*----------------------------------------------------------------------------*/
246 
247 #endif
Definition: Actuator.h:35
Definition: Body.h:41
Definition: Boundary.h:30
An n-dimensional bounding box in c-space.
Definition: CSpaceBoundingBox.h:10
Definition: Cfg.h:38
Definition: MPProblem.h:34
Definition: MultiBody.h:65
Definition: Robot.h:31
void ReadMultiBodyXML(XMLNode &_node)
Definition: Robot.cpp:235
const std::string & GetCapability() const noexcept
Get the capability for this robot.
Definition: Robot.cpp:415
void SetInitialCfg(Cfg _cfg)
Set initial configuration for the robot (not implemented)
const std::string & GetLabel() const noexcept
Get the unique label for this robot.
Definition: Robot.cpp:402
void ReadMultibodyFile(const std::string &_filename)
Definition: Robot.cpp:246
void ReadXMLFile(const std::string &_filename)
Definition: Robot.cpp:170
Actuator * GetActuator(const std::string &_label) noexcept
Definition: Robot.cpp:345
~Robot() noexcept
MultiBody * GetMultiBody() noexcept
Definition: Robot.cpp:322
bool IsFixed() const noexcept
Check if the robot has a fixed base.
Definition: Robot.cpp:435
void InitializePlanningSpaces()
Compute the configuration and velocity spaces for this robot.
Definition: Robot.cpp:264
void SetVirtual(const bool _v) noexcept
Definition: Robot.cpp:367
const EndEffector & GetEndEffector() const noexcept
Access the robot manipulator's end effector, if it exists.
Definition: Robot.cpp:337
bool IsVirtual() const noexcept
Definition: Robot.cpp:360
const std::string & GetDefaultStrategyLabel() const noexcept
Get the default strategy label for this robot.
Definition: Robot.cpp:408
const std::unordered_map< std::string, std::unique_ptr< Actuator > > & GetActuators() const noexcept
Get set of all actuators mapped by label.
Definition: Robot.cpp:352
Robot(MPProblem *const _p, XMLNode &_node)
Definition: Robot.cpp:23
void ReadXMLNode(XMLNode &_node)
Definition: Robot.cpp:178
const CSpaceBoundingBox * GetCSpace() const noexcept
Get the configuration space boundary for this robot.
Definition: Robot.cpp:300
const CSpaceBoundingBox * GetVSpace() const noexcept
Get the velocity space boundary for this robot.
Definition: Robot.cpp:307
void SetCapability(const std::string &_capability)
Set the capability for this robot.
Definition: Robot.cpp:422
double GetMaxLinearVelocity() const noexcept
Get the maximum translational velocity for this robot.
Definition: Robot.cpp:388
Cfg GetInitialCfg()
Get initial configuration for the robot (not implemented)
bool IsManipulator() const noexcept
Check if the robot is a manipulator.
Definition: Robot.cpp:428
bool IsCarlike() const noexcept
Check if the robot is car-like.
Definition: Robot.cpp:381
double GetMaxAngularVelocity() const noexcept
Get the maximum angular velocity for this robot.
Definition: Robot.cpp:395
bool IsNonholonomic() const noexcept
Check if the robot is nonholonomic.
Definition: Robot.cpp:374
MPProblem * GetMPProblem() const noexcept
Get the owning MPProblem.
Definition: Robot.cpp:314
Definition: XMLNode.h:27