aikido
JointStateSpace.hpp
1 #ifndef AIKIDO_STATESPACE_DART_JOINTSTATESPACE_HPP_
2 #define AIKIDO_STATESPACE_DART_JOINTSTATESPACE_HPP_
3 
4 #include <dart/dynamics/dynamics.hpp>
5 
6 #include "aikido/statespace/StateSpace.hpp"
7 
8 namespace aikido {
9 namespace statespace {
10 namespace dart {
11 
20 class JointStateSpace : public virtual StateSpace
21 {
22 public:
25  class Properties
26  {
27  public:
31  explicit Properties(const ::dart::dynamics::Joint* joint);
32 
34  const std::string& getName() const;
35 
37  const std::string& getType() const;
38 
40  std::size_t getNumDofs() const;
41 
43  const std::vector<std::string>& getDofNames() const;
44 
46  bool hasPositionLimit(std::size_t index) const;
47 
49  bool isPositionLimited() const;
50 
52  const Eigen::VectorXd& getPositionLowerLimits() const;
53 
55  const Eigen::VectorXd& getPositionUpperLimits() const;
56 
58  const Eigen::VectorXd& getVelocityLowerLimits() const;
59 
61  const Eigen::VectorXd& getVelocityUpperLimits() const;
62 
65  bool operator==(const Properties& otherProperties) const;
66 
69  bool operator!=(const Properties& otherProperties) const;
70 
71  protected:
73  std::string mName;
74 
76  std::string mType;
77 
79  std::vector<std::string> mDofNames;
80 
82  Eigen::VectorXd mPositionLowerLimits;
83 
85  Eigen::VectorXd mPositionUpperLimits;
86 
88  Eigen::Matrix<bool, Eigen::Dynamic, 1> mPositionHasLimits;
89 
91  Eigen::VectorXd mVelocityLowerLimits;
92 
94  Eigen::VectorXd mVelocityUpperLimits;
95 
97  // TODO: why doesn't this exist in DART??
98  // Eigen::Matrix<bool, Eigen::Dynamic, 1> mVelocityHasLimits;
99  };
100 
104  explicit JointStateSpace(const ::dart::dynamics::Joint* joint);
105 
107  virtual ~JointStateSpace() = default;
108 
112  const Properties& getProperties() const;
113 
117  bool isCompatible(const ::dart::dynamics::Joint* joint) const;
118 
123  void checkCompatibility(const ::dart::dynamics::Joint* joint) const;
124 
130  virtual void convertPositionsToState(
131  const Eigen::VectorXd& positions, StateSpace::State* state) const = 0;
132 
138  virtual void convertStateToPositions(
139  const StateSpace::State* state, Eigen::VectorXd& positions) const = 0;
140 
145  virtual void getState(
146  const ::dart::dynamics::Joint* joint, StateSpace::State* state) const;
147 
152  virtual void setState(
153  ::dart::dynamics::Joint* joint, const StateSpace::State* state) const;
154 
155 protected:
156  Properties mProperties;
157 };
158 
159 } // namespace dart
160 } // namespace statespace
161 } // namespace aikido
162 
163 #endif // ifndef AIKIDO_STATESPACE_DART_JOINTSTATESPACE_HPP_
std::size_t getNumDofs() const
Return the number of DOFs in the joint.
Definition: JointStateSpace.cpp:46
bool hasPositionLimit(std::size_t index) const
Return whether the index DOF is position-limited.
Definition: JointStateSpace.cpp:58
Static properties from the DART Joint.
Definition: JointStateSpace.hpp:25
virtual void convertStateToPositions(const StateSpace::State *state, Eigen::VectorXd &positions) const =0
Converts a State in this state space to DART Joint positions, e.g.
bool operator!=(const Properties &otherProperties) const
Return whether two JointStateSpace::Properties are different.
Definition: JointStateSpace.cpp:138
Eigen::VectorXd mVelocityLowerLimits
The joint&#39;s velocity lower limits.
Definition: JointStateSpace.hpp:91
const std::string & getName() const
Return the name of the joint.
Definition: JointStateSpace.cpp:34
void checkCompatibility(const ::dart::dynamics::Joint *joint) const
Throws an error if the Joint cannot be used with this state space.
Definition: JointStateSpace.cpp:165
const std::string & getType() const
Return the type of the joint.
Definition: JointStateSpace.cpp:40
const Eigen::VectorXd & getVelocityLowerLimits() const
Return the vector of velocity lower limits.
Definition: JointStateSpace.cpp:92
Definition: FrameMarker.hpp:11
Format of serialized trajectory in YAML.
Definition: algorithm.hpp:4
std::string mName
Name of the joint.
Definition: JointStateSpace.hpp:73
A tuple of states where the i-th state is from the i-th subspace.
Definition: CartesianProduct.hpp:162
Eigen::VectorXd mPositionLowerLimits
The joint&#39;s position lower limits.
Definition: JointStateSpace.hpp:82
virtual void setState(::dart::dynamics::Joint *joint, const StateSpace::State *state) const
Sets the positions of the joint to state.
Definition: JointStateSpace.cpp:186
bool isPositionLimited() const
Return whether any DOF is position-limited.
Definition: JointStateSpace.cpp:72
Properties(const ::dart::dynamics::Joint *joint)
Constructs the joint properties for joint.
Definition: JointStateSpace.cpp:8
StateSpace of a DART Joint.
Definition: JointStateSpace.hpp:20
const std::vector< std::string > & getDofNames() const
Return the names of DOFs in the joint.
Definition: JointStateSpace.cpp:52
std::string mType
Name of the joint type.
Definition: JointStateSpace.hpp:76
std::vector< std::string > mDofNames
Names of DOFs in the Joint.
Definition: JointStateSpace.hpp:79
const Eigen::VectorXd & getPositionUpperLimits() const
Return the vector of position upper limits.
Definition: JointStateSpace.cpp:85
Represents a Lie group and its associated Lie algebra, i.e.
Definition: StateSpace.hpp:33
Eigen::VectorXd mVelocityUpperLimits
The joint&#39;s velocity upper limits.
Definition: JointStateSpace.hpp:94
const Eigen::VectorXd & getVelocityUpperLimits() const
Return the vector of velocity upper limits.
Definition: JointStateSpace.cpp:99
Eigen::Matrix< bool, Eigen::Dynamic, 1 > mPositionHasLimits
The joint&#39;s position limits.
Definition: JointStateSpace.hpp:88
virtual ~JointStateSpace()=default
Destructor.
const Properties & getProperties() const
Gets the joint properties associated with this state space.
Definition: JointStateSpace.cpp:152
Eigen::VectorXd mPositionUpperLimits
The joint&#39;s position upper limits.
Definition: JointStateSpace.hpp:85
JointStateSpace(const ::dart::dynamics::Joint *joint)
Constructs a state space for joint.
Definition: JointStateSpace.cpp:145
const Eigen::VectorXd & getPositionLowerLimits() const
Return the vector of position lower limits.
Definition: JointStateSpace.cpp:78
bool operator==(const Properties &otherProperties) const
Return whether two JointStateSpace::Properties are identical.
Definition: JointStateSpace.cpp:106
virtual void getState(const ::dart::dynamics::Joint *joint, StateSpace::State *state) const
Gets the positions of the joint and store them in state.
Definition: JointStateSpace.cpp:179
bool isCompatible(const ::dart::dynamics::Joint *joint) const
Returns whether the Joint can be used with this state space.
Definition: JointStateSpace.cpp:158
virtual void convertPositionsToState(const Eigen::VectorXd &positions, StateSpace::State *state) const =0
Converts DART Joint positions, e.g.