Parasol Planning Library (PPL)
Connection.h
Go to the documentation of this file.
1 #ifndef CONNECTION_H
2 #define CONNECTION_H
3 
4 #include <array>
5 #include <memory>
6 #include <string>
7 #include <utility>
8 
9 #include "Transformation.h"
10 using namespace mathtool;
11 
12 #include "DHParameters.h"
13 #include "Utilities/IOUtils.h"
15 
16 class Body;
17 class MultiBody;
18 class XMLNode;
19 
20 
35 class Connection final {
36 
37  public:
38 
41 
43  enum class JointType {
44  Revolute,
45  Spherical,
46  NonActuated
47  };
48 
52 
54  Connection(MultiBody* const _owner);
55 
59  Connection(MultiBody* const _owner, XMLNode& _node);
60 
64  Connection(const Connection&);
66 
70 
71  Connection& operator=(const Connection&);
73 
77 
81  void Read(istream& _is, CountingStreamBuffer& _cbs);
82 
88  void SetBodies(MultiBody* const _owner, const size_t _parentIndex,
89  const size_t _childIndex);
90 
94  void SetBodies(MultiBody* const _owner = nullptr);
95 
100  void SetAdjacentBodies(MultiBody* const _owner, const size_t _firstIndex,
101  const size_t _secondIndex);
102 
106 
108  JointType GetConnectionType() const noexcept;
109 
111  bool IsRevolute() const noexcept;
112 
114  bool IsSpherical() const noexcept;
115 
117  bool IsNonActuated() const noexcept;
118 
122  const Range<double>& GetJointRange(const size_t _i) const noexcept;
123 
128  void SetJointRange(const size_t _i, const Range<double>& _r) noexcept;
129 
133 
135  const Body* GetPreviousBody() const noexcept;
136  Body* GetPreviousBody() noexcept;
137 
139  size_t GetPreviousBodyIndex() const noexcept;
140 
142  const Body* GetNextBody() const noexcept;
143  Body* GetNextBody() noexcept;
144 
146  size_t GetNextBodyIndex() const noexcept;
147 
151 
153  DHParameters& GetDHParameters() noexcept;
154  const DHParameters& GetDHParameters() const noexcept;
155 
157  Transformation& GetTransformationToBody2() noexcept;
158  const Transformation& GetTransformationToBody2() const noexcept;
159 
161  Transformation& GetTransformationToDHFrame() noexcept;
162  const Transformation& GetTransformationToDHFrame() const noexcept;
163 
165 
166  private:
167 
170 
171  MultiBody* m_multibody{nullptr};
172  Transformation m_transformationToBody2;
173  Transformation m_transformationToDHFrame;
174  DHParameters m_dhParameters;
175 
176  JointType m_jointType;
177  std::pair<size_t, size_t> m_bodyIndices;
178  std::array<Range<double>, 2> m_jointRange;
179 
181 
182 };
183 
184 
185 /*---------------------------------- Debug -----------------------------------*/
186 
187 std::ostream& operator<<(std::ostream&, const Connection::JointType&);
188 
189 std::ostream& operator<<(std::ostream& _os, const Connection& _c);
190 
191 /*----------------------------------------------------------------------------*/
192 
193 #endif
std::ostream & operator<<(std::ostream &, const Connection::JointType &)
Definition: Connection.cpp:394
void Read(GenericStateGraph *_g, const std::string &_filename)
Definition: GenericStateGraph.h:1337
Definition: Body.h:41
Definition: Connection.h:35
Connection & operator=(Connection &&)
Move.
Connection(Connection &&)
Move.
JointType
The supported connection types.
Definition: Connection.h:43
Definition: CountingStreamBuffer.h:20
Definition: DHParameters.h:27
Definition: MultiBody.h:65
Definition: XMLNode.h:27
Definition: Cfg.h:23
A range of numeric values.
Definition: Range.h:17