1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162 | /**
* @file IKPose.h
*
* @author <a href="mailto:xu@informatik.hu-berlin.de">Xu, Yuan</a>
* Declaration of Pose for IK motion
*/
#ifndef _IK_POSE_H_
#define _IK_POSE_H_
#include "Tools/Math/Pose3D.h"
#include "Motion/MorphologyProcessor/InverseKinematics.h"
#include "Tools/NaoInfo.h"
namespace InverseKinematic
{
class FeetPose
{
public:
Pose3D left, right;
void localInLeftFoot()
{
right = left.local(right);
left = Pose3D();
}
void localInRightFoot()
{
left = right.local(left);
right = Pose3D();
}
};
// actually the same as FeetPose
class ArmPose // more general BiEffectorPose ?
{
public:
Pose3D left, right;
void localInLeftFoot()
{
right = left.local(right);
left = Pose3D();
}
void localInRightFoot()
{
left = right.local(left);
right = Pose3D();
}
};
class BodyFeetPose
{
protected:
void localPose(Pose3D& p0, Pose3D& p1, Pose3D& p2)<--- Technically the member function 'InverseKinematic::BodyFeetPose::localPose' can be static. [+]The member function 'InverseKinematic::BodyFeetPose::localPose' can be made a static function. Making a function static can bring a performance benefit since no 'this' instance is passed to the function. This change should not cause compiler errors but it does not necessarily make sense conceptually. Think about your design and the task of the function first - is it a function that must not access members of class instances?
{
p1 = p0.local(p1);
p2 = p0.local(p2);
p0 = Pose3D();
}
void localInBody()
{
localPose(body(), feet.left, feet.right);
}
public:
FeetPose feet;
virtual Pose3D& body() = 0;
virtual const Pose3D& body() const = 0;
void localInLeftFoot()
{
localPose(feet.left, feet.right, body());
}
void localInRightFoot()
{
localPose(feet.right, feet.left, body());
}
};
// actually, the same as BodyFeetPose
class ChestArmsPose
{
protected:
void localPose(Pose3D& p0, Pose3D& p1, Pose3D& p2)<--- Technically the member function 'InverseKinematic::ChestArmsPose::localPose' can be static. [+]The member function 'InverseKinematic::ChestArmsPose::localPose' can be made a static function. Making a function static can bring a performance benefit since no 'this' instance is passed to the function. This change should not cause compiler errors but it does not necessarily make sense conceptually. Think about your design and the task of the function first - is it a function that must not access members of class instances?
{
p1 = p0.local(p1);
p2 = p0.local(p2);
p0 = Pose3D();
}
public:
ArmPose arms;
Pose3D chest;
Pose3D& body() { return chest; }
const Pose3D& body() const { return chest; }
void localInLeftFoot()
{
localPose(arms.left, arms.right, chest);
}
void localInRightFoot()
{
localPose(arms.right, arms.left, chest);
}
void localInChest()
{
localPose(chest, arms.left, arms.right);
}
};
class HipFeetPose: public BodyFeetPose
{
public:
Pose3D hip;
virtual Pose3D& body() { return hip; }
virtual const Pose3D& body() const { return hip; }
void localInHip()
{
localInBody();
}
};
class CoMFeetPose: public BodyFeetPose
{
public:
Pose3D com;
virtual Pose3D& body() { return com; }
virtual const Pose3D& body() const { return com; }
void localInCoM()
{
localInBody();
}
};
class ZMPFeetPose: public BodyFeetPose
{
public:
Pose3D zmp;
virtual Pose3D& body() { return zmp; }
virtual const Pose3D& body() const { return zmp; }
void localInZMP()
{
localInBody();
}
};
}
#endif //_IK_POSE_h_
|