NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gait_joint_pose.h
1 // Gait utility class that provides joint pose representation functionality
2 // File: gait_joint_pose.h
3 // Author: Philipp Allgeuer <pallgeuer@ais.uni-bonn.de>
4 
5 // Ensure header is only included once
6 #ifndef GAIT_JOINT_POSE_H
7 #define GAIT_JOINT_POSE_H
8 
9 // Includes
10 #include <gait/util/gait_common_pose.h>
11 #include <gait/gait_common.h>
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 
36  struct JointLegPose
37  {
38  //
39  // Constructor
40  //
41 
43  explicit JointLegPose(bool left = true) { reset(left); }
44 
46  inline void reset(bool left = true)
47  {
48  cld.reset(left);
49  setPose(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
50  }
51 
52  //
53  // Set functions
54  //
55 
57  inline void setPose(double hipYaw, double hipRoll, double hipPitch, double kneePitch, double anklePitch, double ankleRoll)
58  {
59  this->hipYaw = hipYaw;
60  this->hipRoll = hipRoll;
61  this->hipPitch = hipPitch;
62  this->kneePitch = kneePitch;
63  this->anklePitch = anklePitch;
64  this->ankleRoll = ankleRoll;
65  }
66 
68  inline void setPoseMirrored(double hipYaw, double hipRoll, double hipPitch, double kneePitch, double anklePitch, double ankleRoll)
69  {
70  this->hipYaw = (cld.isLeft ? hipYaw : -hipYaw);
71  this->hipRoll = (cld.isLeft ? hipRoll : -hipRoll);
72  this->hipPitch = hipPitch;
73  this->kneePitch = kneePitch;
74  this->anklePitch = anklePitch;
75  this->ankleRoll = (cld.isLeft ? ankleRoll : -ankleRoll);
76  }
77 
79  inline void setLinkLength(double length)
80  {
81  cld.linkLength = length;
82  }
83 
84  //
85  // Pose conversion functions
86  //
87 
89  void setFromInversePose(const InverseLegPose& pose);
90 
92  void setFromAbstractPose(const AbstractLegPose& pose);
93 
95  inline void fromJointAngles(double hipYaw, double hipRoll, double hipPitch, double kneePitch, double anklePitch, double ankleRoll)
96  {
97  this->hipYaw = hipYaw;
98  this->hipRoll = hipRoll;
99  this->hipPitch = hipPitch;
100  this->kneePitch = kneePitch;
101  this->anklePitch = anklePitch;
102  this->ankleRoll = ankleRoll;
103  }
104 
106  inline void getJointAngles(double& hipYaw, double& hipRoll, double& hipPitch, double& kneePitch, double& anklePitch, double& ankleRoll) const
107  {
108  hipYaw = this->hipYaw;
109  hipRoll = this->hipRoll;
110  hipPitch = this->hipPitch;
111  kneePitch = this->kneePitch;
112  anklePitch = this->anklePitch;
113  ankleRoll = this->ankleRoll;
114  }
115 
116  //
117  // Other functions
118  //
119 
121  void blendTowards(const JointLegPose& other, double b);
122 
123  //
124  // Data members
125  //
126 
127  // Common leg data
129 
130  // Leg pose
131  double hipYaw;
132  double hipRoll;
133  double hipPitch;
134  double kneePitch;
135  double anklePitch;
136  double ankleRoll;
137  };
138 
148  {
149  //
150  // Constructor
151  //
152 
154  explicit JointArmPose(bool left = true) { reset(left); }
155 
157  inline void reset(bool left = true)
158  {
159  cad.reset(left);
160  setPose(0.0, 0.0, 0.0);
161  }
162 
163  //
164  // Set functions
165  //
166 
168  inline void setPose(double shoulderPitch, double shoulderRoll, double elbowPitch)
169  {
170  this->shoulderPitch = shoulderPitch;
171  this->shoulderRoll = shoulderRoll;
172  this->elbowPitch = elbowPitch;
173  }
174 
176  inline void setPoseMirrored(double shoulderPitch, double shoulderRoll, double elbowPitch)
177  {
178  this->shoulderPitch = shoulderPitch;
179  this->shoulderRoll = (cad.isLeft ? shoulderRoll : -shoulderRoll);
180  this->elbowPitch = elbowPitch;
181  }
182 
184  inline void setLinkLength(double length)
185  {
186  cad.linkLength = length;
187  }
188 
189  //
190  // Pose conversion functions
191  //
192 
194  void setFromInversePose(const InverseArmPose& pose);
195 
197  void setFromAbstractPose(const AbstractArmPose& pose);
198 
200  inline void fromJointAngles(double shoulderPitch, double shoulderRoll, double elbowPitch)
201  {
202  this->shoulderPitch = shoulderPitch;
203  this->shoulderRoll = shoulderRoll;
204  this->elbowPitch = elbowPitch;
205  }
206 
208  inline void getJointAngles(double& shoulderPitch, double& shoulderRoll, double& elbowPitch) const
209  {
210  shoulderPitch = this->shoulderPitch;
211  shoulderRoll = this->shoulderRoll;
212  elbowPitch = this->elbowPitch;
213  }
214 
215  //
216  // Other functions
217  //
218 
220  void blendTowards(const JointArmPose& other, double b);
221 
222  //
223  // Data members
224  //
225 
226  // Common arm data
228 
229  // Arm pose
230  double shoulderPitch;
231  double shoulderRoll;
232  double elbowPitch;
233  };
234 
242  struct JointPose
243  {
244  //
245  // Constructor
246  //
247 
249  JointPose() { reset(); }
250 
252  inline void reset()
253  {
254  leftLeg.reset(true);
255  rightLeg.reset(false);
256  leftArm.reset(true);
257  rightArm.reset(false);
258  }
259 
260  //
261  // Set functions
262  //
263 
265  inline void setLinkLengths(double legLinkLength, double armLinkLength)
266  {
267  leftLeg.cld.setLinkLength(legLinkLength);
268  rightLeg.cld.setLinkLength(legLinkLength);
269  leftArm.cad.setLinkLength(armLinkLength);
270  rightArm.cad.setLinkLength(armLinkLength);
271  }
272 
273  //
274  // Pose conversion functions
275  //
276 
278  void setFromInversePose(const InversePose& pose);
279 
281  void setFromAbstractPose(const AbstractPose& pose);
282 
284  inline void setLegsFromInversePose(const InverseLegPose& left, const InverseLegPose& right)
285  {
288  }
289 
291  inline void setLegsFromAbstractPose(const AbstractLegPose& left, const AbstractLegPose& right)
292  {
295  }
296 
298  inline void setArmsFromInversePose(const InverseArmPose& left, const InverseArmPose& right)
299  {
302  }
303 
305  inline void setArmsFromAbstractPose(const AbstractArmPose& left, const AbstractArmPose& right)
306  {
309  }
310 
311  //
312  // Data interface functions
313  //
314 
316  void readJointPosArray(const double (&pos)[NUM_JOINTS]);
317 
319  void readJointEffortArray(const double (&effort)[NUM_JOINTS]);
320 
322  void writeJointPosArray(double (&pos)[NUM_JOINTS]) const;
323 
325  void writeJointEffortArray(double (&effort)[NUM_JOINTS]) const;
326 
327  //
328  // Other functions
329  //
330 
332  void blendTowards(const JointPose& other, double b);
333 
334  //
335  // Data members
336  //
337 
338  // Joint limb pose structs
343  };
344 }
345 
346 #endif /* GAIT_JOINT_POSE_H */
347 // EOF
void setLinkLength(double length)
Set the link length used for pose conversions.
Definition: gait_common_pose.h:178
void setFromAbstractPose(const AbstractLegPose &pose)
Set the joint leg pose to a given abstract leg pose.
Definition: gait_joint_pose.cpp:25
JointPose()
Default constructor.
Definition: gait_joint_pose.h:249
void readJointEffortArray(const double(&effort)[NUM_JOINTS])
Set the joint efforts to the values specified by a given joint effort array.
Definition: gait_joint_pose.cpp:133
JointLegPose leftLeg
Joint pose of the left leg.
Definition: gait_joint_pose.h:339
void setLegsFromInversePose(const InverseLegPose &left, const InverseLegPose &right)
Set the joint leg poses to given inverse poses.
Definition: gait_joint_pose.h:284
JointLegPose(bool left=true)
Default constructor.
Definition: gait_joint_pose.h:43
void setLinkLength(double length)
Set the link length used for pose conversions.
Definition: gait_joint_pose.h:184
void setFromInversePose(const InversePose &pose)
Set the joint pose to a given inverse pose.
Definition: gait_joint_pose.cpp:85
void reset(bool left=true)
Reset function.
Definition: gait_common_pose.h:135
CommonArmData cad
Data that is shared by all arm pose representations.
Definition: gait_joint_pose.h:227
void setPoseMirrored(double hipYaw, double hipRoll, double hipPitch, double kneePitch, double anklePitch, double ankleRoll)
Set the joint pose in mirror mode (directly set the joint pose parameters if this is the left leg...
Definition: gait_joint_pose.h:68
JointArmPose leftArm
Joint pose of the left arm.
Definition: gait_joint_pose.h:341
void setArmsFromInversePose(const InverseArmPose &left, const InverseArmPose &right)
Set the joint arm poses to given inverse poses.
Definition: gait_joint_pose.h:298
void reset()
Reset function.
Definition: gait_joint_pose.h:252
Data struct that contains the information pertaining to an arm pose that should be common amongst all...
Definition: gait_common_pose.h:125
void setPose(double hipYaw, double hipRoll, double hipPitch, double kneePitch, double anklePitch, double ankleRoll)
Set the joint pose (directly set the joint pose parameters)
Definition: gait_joint_pose.h:57
void getJointAngles(double &shoulderPitch, double &shoulderRoll, double &elbowPitch) const
Retrieve the joint angles corresponding to the current joint arm pose.
Definition: gait_joint_pose.h:208
double hipYaw
The hip yaw joint position.
Definition: gait_joint_pose.h:131
void reset(bool left=true)
Reset function.
Definition: gait_joint_pose.h:46
void setFromInversePose(const InverseArmPose &pose)
Set the joint arm pose to a given inverse arm pose.
Definition: gait_joint_pose.cpp:55
Data struct that encompasses the joint representation of a robot pose.
Definition: gait_joint_pose.h:242
JointArmPose(bool left=true)
Default constructor.
Definition: gait_joint_pose.h:154
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_joint_pose.h:95
void setFromInversePose(const InverseLegPose &pose)
Set the joint leg pose to a given inverse leg pose.
Definition: gait_joint_pose.cpp:18
void blendTowards(const JointArmPose &other, double b)
Blend this joint pose towards another one by a given blending factor (b: 0 = Pose remains unchanged...
Definition: gait_joint_pose.cpp:69
Data struct that encompasses the abstract representation of an arm pose.
Definition: gait_abstract_pose.h:136
double hipPitch
The hip pitch joint position.
Definition: gait_joint_pose.h:133
void reset(bool left=true)
Reset function.
Definition: gait_common_pose.h:30
void setLinkLengths(double legLinkLength, double armLinkLength)
Set the arm and leg link lengths used for pose conversions.
Definition: gait_joint_pose.h:265
double anklePitch
The ankle pitch joint position.
Definition: gait_joint_pose.h:135
double linkLength
The assumed (equal) length of the upper and lower leg links (used for joint pose conversions) ...
Definition: gait_common_pose.h:114
double linkLength
The assumed (equal) length of the upper and lower arm links (used for joint pose conversions) ...
Definition: gait_common_pose.h:197
double elbowPitch
The elbow pitch joint position.
Definition: gait_joint_pose.h:232
void setLegsFromAbstractPose(const AbstractLegPose &left, const AbstractLegPose &right)
Set the joint leg poses to given abstract poses.
Definition: gait_joint_pose.h:291
Data struct that encompasses the inverse representation of an arm pose.
Definition: gait_inverse_pose.h:118
void writeJointPosArray(double(&pos)[NUM_JOINTS]) const
Transcribe the stored joint pose to a joint position array.
Definition: gait_joint_pose.cpp:163
void setFromAbstractPose(const AbstractArmPose &pose)
Set the joint arm pose to a given abstract arm pose.
Definition: gait_joint_pose.cpp:62
Data struct that encompasses the joint representation of an arm pose.
Definition: gait_joint_pose.h:147
double shoulderPitch
The shoulder pitch joint position.
Definition: gait_joint_pose.h:230
void setFromAbstractPose(const AbstractPose &pose)
Set the joint pose to a given abstract pose.
Definition: gait_joint_pose.cpp:94
double hipRoll
The hip roll joint position.
Definition: gait_joint_pose.h:132
void setLinkLength(double length)
Set the link length used for pose conversions.
Definition: gait_joint_pose.h:79
CommonLegData cld
Data that is shared by all leg pose representations.
Definition: gait_joint_pose.h:128
void setPoseMirrored(double shoulderPitch, double shoulderRoll, double elbowPitch)
Set the joint pose in mirror mode (directly set the joint pose parameters if this is the left arm...
Definition: gait_joint_pose.h:176
double kneePitch
The knee pitch joint position.
Definition: gait_joint_pose.h:134
double ankleRoll
The ankle roll joint position.
Definition: gait_joint_pose.h:136
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 blendTowards(const JointPose &other, double b)
Blend this joint pose towards another one by a given blending factor (b: 0 = Pose remains unchanged...
Definition: gait_joint_pose.cpp:223
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_joint_pose.h:200
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
bool isLeft
Boolean flag that is true if this is a left arm and false if this is a right arm. ...
Definition: gait_common_pose.h:193
Data struct that encompasses the abstract representation of a leg pose.
Definition: gait_abstract_pose.h:35
void reset(bool left=true)
Reset function.
Definition: gait_joint_pose.h:157
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 getJointAngles(double &hipYaw, double &hipRoll, double &hipPitch, double &kneePitch, double &anklePitch, double &ankleRoll) const
Retrieve the joint angles corresponding to the current joint leg pose.
Definition: gait_joint_pose.h:106
JointLegPose rightLeg
Joint pose of the right leg.
Definition: gait_joint_pose.h:340
void setPose(double shoulderPitch, double shoulderRoll, double elbowPitch)
Set the joint pose (directly set the joint pose parameters)
Definition: gait_joint_pose.h:168
double shoulderRoll
The shoulder roll joint position.
Definition: gait_joint_pose.h:231
void blendTowards(const JointLegPose &other, double b)
Blend this joint pose towards another one by a given blending factor (b: 0 = Pose remains unchanged...
Definition: gait_joint_pose.cpp:32
Data struct that contains the information pertaining to a leg pose that should be common amongst all ...
Definition: gait_common_pose.h:20
void readJointPosArray(const double(&pos)[NUM_JOINTS])
Set the joint pose to the values specified by a given joint position array.
Definition: gait_joint_pose.cpp:103
JointArmPose rightArm
Joint pose of the right arm.
Definition: gait_joint_pose.h:342
void setLinkLength(double length)
Set the link length used for pose conversions.
Definition: gait_common_pose.h:89
void writeJointEffortArray(double(&effort)[NUM_JOINTS]) const
Transcribe the stored joint efforts to a joint effort array.
Definition: gait_joint_pose.cpp:193
void setArmsFromAbstractPose(const AbstractArmPose &left, const AbstractArmPose &right)
Set the joint arm poses to given abstract poses.
Definition: gait_joint_pose.h:305