prototype_joint_entity.h
Go to the documentation of this file.
1 
7 #ifndef PROTOTYPE_JOINT_ENTITY_H
8 #define PROTOTYPE_JOINT_ENTITY_H
9 
10 namespace argos {
11  class CPrototypeLinkEntity;
12  class CPrototypeJointEntity;
13 }
14 
15 #include <argos3/core/simulator/entity/composable_entity.h>
16 #include <argos3/core/utility/math/quaternion.h>
17 #include <argos3/core/utility/math/vector3.h>
18 
19 namespace argos {
20 
22 
23  public:
24 
26 
27  using TVector = std::vector<CPrototypeJointEntity*>;
28  using TVectorIterator = std::vector<CPrototypeJointEntity*>::iterator;
29  using TVectorConstIterator = std::vector<CPrototypeJointEntity*>::const_iterator;
30 
31  public:
32  enum class EType {
33  FIXED,
34  PRISMATIC,
35  REVOLUTE,
36  SPHERICAL,
37  PLANAR,
38  };
39 
40  union ULimit {
41  ULimit() {}
44  };
45 
46  struct SActuator {
47  enum class EMode {
48  DISABLED,
49  POSITION,
50  VELOCITY,
51  };
52  Real Target = 0.0f;
53  Real MaxImpulse = 0.0f;
55  };
56 
57  struct SSensor {
58  enum class EMode {
59  DISABLED,
60  POSITION,
61  VELOCITY,
62  };
63  Real Value = 0.0f;
65  };
66 
67  public:
68 
70 
72 
73  virtual void Init(TConfigurationNode& t_tree);
74 
75  virtual std::string GetTypeDescription() const {
76  return "joint";
77  }
78 
80  return *m_pcParentLink;
81  }
82 
83  inline const CPrototypeLinkEntity& GetParentLink() const {
84  return *m_pcParentLink;
85  }
86 
87  inline const CVector3& GetParentLinkJointPosition() const {
88  return m_cParentLinkJointPosition;
89  }
90 
92  return m_cParentLinkJointOrientation;
93  }
94 
96  return *m_pcChildLink;
97  }
98 
99  inline const CPrototypeLinkEntity& GetChildLink() const {
100  return *m_pcChildLink;
101  }
102 
103  inline const CVector3& GetChildLinkJointPosition() const {
104  return m_cChildLinkJointPosition;
105  }
106 
108  return m_cChildLinkJointOrientation;
109  }
110 
111  inline bool GetDisableCollision() const {
112  return m_bDisableCollision;
113  }
114 
115  inline EType GetType() const {
116  return m_eType;
117  }
118 
119  inline const CVector3& GetJointAxis() const {
120  return m_cJointAxis;
121  }
122 
123  bool HasLimit() {
124  return m_bHasLimit;
125  }
126 
127  const ULimit& GetLimit() const {
128  ARGOS_ASSERT(m_bHasLimit == true,
129  "CPrototypeJointEntity::GetLimit(), id=\"" <<
130  GetId() <<
131  "\": joint was not initialized with a limit");
132  return m_uLimit;
133  }
134 
136  return m_cSensor;
137  }
138 
140  return m_cActuator;
141  }
142 
143  private:
144 
145  CPrototypeLinkEntity* m_pcParentLink;
146  CVector3 m_cParentLinkJointPosition;
147  CQuaternion m_cParentLinkJointOrientation;
148 
149  CPrototypeLinkEntity* m_pcChildLink;
150  CVector3 m_cChildLinkJointPosition;
151  CQuaternion m_cChildLinkJointOrientation;
152 
153  bool m_bDisableCollision;
154  EType m_eType;
155  CVector3 m_cJointAxis;
156  bool m_bHasLimit;
157  ULimit m_uLimit;
158  SSensor m_cSensor;
159  SActuator m_cActuator;
160  };
161 
162 }
163 
164 #endif
#define ARGOS_ASSERT(condition, message)
When code is compiled in debug, this macro throws an ARGoS exception with the passed message if the s...
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
Basic class for an entity that contains other entities.
std::vector< CEntity * > TVector
A vector of entities.
Definition: entity.h:97
const std::string & GetId() const
Returns the id of this entity.
Definition: entity.h:157
A 3D vector class.
Definition: vector3.h:31
virtual std::string GetTypeDescription() const
Returns a string label for this class.
CPrototypeLinkEntity & GetChildLink()
const CVector3 & GetChildLinkJointPosition() const
const CPrototypeLinkEntity & GetChildLink() const
const CVector3 & GetParentLinkJointPosition() const
const CVector3 & GetJointAxis() const
CPrototypeJointEntity(CComposableEntity *pc_parent)
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
std::vector< CPrototypeJointEntity * >::iterator TVectorIterator
CPrototypeLinkEntity & GetParentLink()
const CQuaternion & GetParentLinkJointOrientation() const
const CPrototypeLinkEntity & GetParentLink() const
const CQuaternion & GetChildLinkJointOrientation() const
std::vector< CPrototypeJointEntity * >::const_iterator TVectorConstIterator