NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gait_inverse_pose.h
1 // Gait utility class that provides inverse pose representation functionality
2 // File: gait_inverse_pose.h
3 // Author: Philipp Allgeuer <pallgeuer@ais.uni-bonn.de>
4 
5 // Ensure header is only included once
6 #ifndef GAIT_INVERSE_POSE_H
7 #define GAIT_INVERSE_POSE_H
8 
9 // Includes
10 #include <gait/util/gait_common_pose.h>
11 #include <Eigen/Geometry>
12 
13 // Gait namespace
14 namespace gait
15 {
16  // Class forward declarations
17  class JointPose;
18  class JointLegPose;
19  class JointArmPose;
20  class InversePose;
21  class InverseLegPose;
22  class InverseArmPose;
23  class AbstractPose;
24  class AbstractLegPose;
25  class AbstractArmPose;
26 
37  {
38  //
39  // Constructor
40  //
41 
43  explicit InverseLegPose(bool left = true) { reset(left); }
44 
46  inline void reset(bool left = true)
47  {
48  cld.reset(left);
49  setPose(Eigen::Vector3d::Zero(), Eigen::Quaterniond::Identity());
50  }
51 
52  //
53  // Set functions
54  //
55 
57  inline void setPose(const Eigen::Vector3d& footPosition, const Eigen::Quaterniond& footRotation = Eigen::Quaterniond::Identity())
58  {
59  footPos = footPosition;
60  footRot = footRotation;
61  }
62 
64  inline void setPoseMirrored(const Eigen::Vector3d& footPosition, const Eigen::Quaterniond& footRotation = Eigen::Quaterniond::Identity())
65  {
66  footPos = footPosition;
67  footRot = footRotation;
68  if(!cld.isLeft)
69  {
70  footPos.y() = -footPos.y(); // Flip the position about the XZ plane
71  footRot.x() = -footRot.x(); // Mirror the orientation about the XZ plane
72  footRot.z() = -footRot.z(); // ...
73  }
74  }
75 
77  inline void setLinkLength(double length)
78  {
79  cld.linkLength = length;
80  }
81 
82  //
83  // Pose conversion functions
84  //
85 
87  void setFromJointPose(const JointLegPose& pose);
88 
90  void setFromAbstractPose(const AbstractLegPose& pose);
91 
93  void fromJointAngles(double hipYaw, double hipRoll, double hipPitch, double kneePitch, double anklePitch, double ankleRoll);
94 
96  void getJointAngles(double& hipYaw, double& hipRoll, double& hipPitch, double& kneePitch, double& anklePitch, double& ankleRoll) const;
97 
98  //
99  // Data members
100  //
101 
102  // Common leg data
104 
105  // Leg pose
106  Eigen::Vector3d footPos;
107  Eigen::Quaterniond footRot;
108  };
109 
119  {
120  //
121  // Constructor
122  //
123 
125  explicit InverseArmPose(bool left = true) { reset(left); }
126 
128  inline void reset(bool left = true)
129  {
130  cad.reset(left);
131  setPose(/* TODO */);
132  }
133 
134  //
135  // Set functions
136  //
137 
139  inline void setPose(/* TODO */)
140  {
141  }
142 
144  inline void setPoseMirrored(/* TODO */)
145  {
146  }
147 
149  inline void setLinkLength(double length)
150  {
151  cad.linkLength = length;
152  }
153 
154  //
155  // Pose conversion functions
156  //
157 
159  void setFromJointPose(const JointArmPose& pose);
160 
162  void setFromAbstractPose(const AbstractArmPose& pose);
163 
165  void fromJointAngles(double shoulderPitch, double shoulderRoll, double elbowPitch);
166 
168  void getJointAngles(double& shoulderPitch, double& shoulderRoll, double& elbowPitch) const;
169 
170  //
171  // Data members
172  //
173 
174  // Common arm data
176 
177  // Arm pose
178  /* TODO */
179  };
180 
188  struct InversePose
189  {
190  //
191  // Constructor
192  //
193 
196 
198  inline void reset()
199  {
200  leftLeg.reset(true);
201  rightLeg.reset(false);
202  leftArm.reset(true);
203  rightArm.reset(false);
204  }
205 
206  //
207  // Set functions
208  //
209 
211  inline void setLinkLengths(double legLinkLength, double armLinkLength)
212  {
213  leftLeg.cld.setLinkLength(legLinkLength);
214  rightLeg.cld.setLinkLength(legLinkLength);
215  leftArm.cad.setLinkLength(armLinkLength);
216  rightArm.cad.setLinkLength(armLinkLength);
217  }
218 
219  //
220  // Pose conversion functions
221  //
222 
224  void setFromJointPose(const JointPose& pose);
225 
227  void setFromAbstractPose(const AbstractPose& pose);
228 
230  inline void setLegsFromJointPose(const JointLegPose& left, const JointLegPose& right)
231  {
233  rightLeg.setFromJointPose(right);
234  }
235 
237  inline void setLegsFromAbstractPose(const AbstractLegPose& left, const AbstractLegPose& right)
238  {
241  }
242 
244  inline void setArmsFromJointPose(const JointArmPose& left, const JointArmPose& right)
245  {
247  rightArm.setFromJointPose(right);
248  }
249 
251  inline void setArmsFromAbstractPose(const AbstractArmPose& left, const AbstractArmPose& right)
252  {
255  }
256 
257  //
258  // Data members
259  //
260 
261  // Inverse limb pose structs
266  };
267 }
268 
269 #endif /* GAIT_INVERSE_POSE_H */
270 // EOF
void setLinkLength(double length)
Set the link length used for pose conversions.
Definition: gait_common_pose.h:178
void setLinkLengths(double legLinkLength, double armLinkLength)
Set the arm and leg link lengths used for pose conversions.
Definition: gait_inverse_pose.h:211
CommonArmData cad
Data that is shared by all arm pose representations.
Definition: gait_inverse_pose.h:175
InverseLegPose(bool left=true)
Default constructor.
Definition: gait_inverse_pose.h:43
InverseArmPose leftArm
Inverse pose of the left arm.
Definition: gait_inverse_pose.h:264
void reset(bool left=true)
Reset function.
Definition: gait_common_pose.h:135
void setLegsFromAbstractPose(const AbstractLegPose &left, const AbstractLegPose &right)
Set the inverse leg poses to given abstract poses.
Definition: gait_inverse_pose.h:237
Data struct that contains the information pertaining to an arm pose that should be common amongst all...
Definition: gait_common_pose.h:125
void setLinkLength(double length)
Set the link length used for pose conversions.
Definition: gait_inverse_pose.h:149
Data struct that encompasses the joint representation of a robot pose.
Definition: gait_joint_pose.h:242
InverseArmPose rightArm
Inverse pose of the right arm.
Definition: gait_inverse_pose.h:265
InversePose()
Default constructor.
Definition: gait_inverse_pose.h:195
CommonLegData cld
Data that is shared by all leg pose representations.
Definition: gait_inverse_pose.h:103
void setFromAbstractPose(const AbstractArmPose &pose)
Set the inverse arm pose to a given abstract arm pose.
Definition: gait_inverse_pose.cpp:144
Data struct that encompasses the abstract representation of an arm pose.
Definition: gait_abstract_pose.h:136
void setFromJointPose(const JointPose &pose)
Set the inverse pose to a given joint pose.
Definition: gait_inverse_pose.cpp:166
void setPoseMirrored()
Set the inverse pose in mirror mode (directly set the inverse pose parameters if this is the left arm...
Definition: gait_inverse_pose.h:144
void reset(bool left=true)
Reset function.
Definition: gait_common_pose.h:30
void getJointAngles(double &shoulderPitch, double &shoulderRoll, double &elbowPitch) const
Calculate the joint angles corresponding to the current inverse arm pose.
Definition: gait_inverse_pose.cpp:156
double linkLength
The assumed (equal) length of the upper and lower leg links (used for joint pose conversions) ...
Definition: gait_common_pose.h:114
InverseArmPose(bool left=true)
Default constructor.
Definition: gait_inverse_pose.h:125
double linkLength
The assumed (equal) length of the upper and lower arm links (used for joint pose conversions) ...
Definition: gait_common_pose.h:197
void getJointAngles(double &hipYaw, double &hipRoll, double &hipPitch, double &kneePitch, double &anklePitch, double &ankleRoll) const
Calculate the joint angles corresponding to the current inverse leg pose.
Definition: gait_inverse_pose.cpp:57
Eigen::Vector3d footPos
Position of the foot relative to its zero position (in body-fixed coordinates)
Definition: gait_inverse_pose.h:106
void setPose(const Eigen::Vector3d &footPosition, const Eigen::Quaterniond &footRotation=Eigen::Quaterniond::Identity())
Set the inverse pose (directly set the inverse pose parameters)
Definition: gait_inverse_pose.h:57
Data struct that encompasses the inverse representation of an arm pose.
Definition: gait_inverse_pose.h:118
void fromJointAngles(double shoulderPitch, double shoulderRoll, double elbowPitch)
Set the pose of the arm to the pose defined by the given joint angles.
Definition: gait_inverse_pose.cpp:150
Data struct that encompasses the joint representation of an arm pose.
Definition: gait_joint_pose.h:147
void setLegsFromJointPose(const JointLegPose &left, const JointLegPose &right)
Set the inverse leg poses to given joint poses.
Definition: gait_inverse_pose.h:230
void setFromAbstractPose(const AbstractLegPose &pose)
Set the inverse leg pose to a given abstract leg pose.
Definition: gait_inverse_pose.cpp:28
void setFromJointPose(const JointArmPose &pose)
Set the inverse arm pose to a given joint arm pose.
Definition: gait_inverse_pose.cpp:138
Eigen::Quaterniond footRot
Rotation of the foot relative to its zero position (relative to the body-fixed frame) ...
Definition: gait_inverse_pose.h:107
void fromJointAngles(double hipYaw, double hipRoll, double hipPitch, double kneePitch, double anklePitch, double ankleRoll)
Set the pose of the leg to the pose defined by the given joint angles.
Definition: gait_inverse_pose.cpp:37
void setArmsFromAbstractPose(const AbstractArmPose &left, const AbstractArmPose &right)
Set the inverse arm poses to given abstract poses.
Definition: gait_inverse_pose.h:251
Data struct that encompasses the inverse representation of a robot pose.
Definition: gait_inverse_pose.h:188
Data struct that encompasses the abstract representation of a robot pose.
Definition: gait_abstract_pose.h:214
void reset(bool left=true)
Reset function.
Definition: gait_inverse_pose.h:128
void setArmsFromJointPose(const JointArmPose &left, const JointArmPose &right)
Set the inverse arm poses to given joint poses.
Definition: gait_inverse_pose.h:244
void setFromAbstractPose(const AbstractPose &pose)
Set the inverse pose to a given abstract pose.
Definition: gait_inverse_pose.cpp:175
bool isLeft
Boolean flag that is true if this is a left leg and false if this is a right leg. ...
Definition: gait_common_pose.h:110
Data struct that encompasses the abstract representation of a leg pose.
Definition: gait_abstract_pose.h:35
Data struct that encompasses the joint representation of a leg pose.
Definition: gait_joint_pose.h:36
Data struct that encompasses the inverse representation of a leg pose.
Definition: gait_inverse_pose.h:36
void setFromJointPose(const JointLegPose &pose)
Set the inverse leg pose to a given joint leg pose.
Definition: gait_inverse_pose.cpp:21
void reset()
Reset function.
Definition: gait_inverse_pose.h:198
InverseLegPose rightLeg
Inverse pose of the right leg.
Definition: gait_inverse_pose.h:263
void setLinkLength(double length)
Set the link length used for pose conversions.
Definition: gait_inverse_pose.h:77
Data struct that contains the information pertaining to a leg pose that should be common amongst all ...
Definition: gait_common_pose.h:20
void setPose()
Set the inverse pose (directly set the inverse pose parameters)
Definition: gait_inverse_pose.h:139
void setLinkLength(double length)
Set the link length used for pose conversions.
Definition: gait_common_pose.h:89
void reset(bool left=true)
Reset function.
Definition: gait_inverse_pose.h:46
InverseLegPose leftLeg
Inverse pose of the left leg.
Definition: gait_inverse_pose.h:262
void setPoseMirrored(const Eigen::Vector3d &footPosition, const Eigen::Quaterniond &footRotation=Eigen::Quaterniond::Identity())
Set the inverse pose in mirror mode (directly set the inverse pose parameters if this is the left leg...
Definition: gait_inverse_pose.h:64