44   double q_HAA_bf, q_HAA_br, q_HFE_br; 
    45   double q_HFE_bf, q_KFE_br, q_KFE_bf; 
    56   q_HAA_bf = q_HAA_br = -
atan2(xr[
Y],-xr[
Z]);
    59   R << 1.0, 0.0, 0.0, 0.0, 
cos(q_HAA_bf), -
sin(q_HAA_bf), 0.0, 
sin(q_HAA_bf), 
cos(q_HAA_bf);
    67   double tmp1 = 
pow(xr[
X],2)+
pow(xr[Z],2);
    73   double alpha = 
atan2(-xr[Z],xr[X]) - 0.5*M_PI;  
    76   double some_random_value_for_beta = (
pow(lu,2)+tmp1-
pow(ll,2))/(2.*lu*
sqrt(tmp1)); 
    77   if (some_random_value_for_beta > 1) {
    78     some_random_value_for_beta = 1;
    80   if (some_random_value_for_beta < -1) {
    81     some_random_value_for_beta = -1;
    83   double beta = 
acos(some_random_value_for_beta);
    86   q_HFE_bf = q_HFE_br = alpha + beta;
    89   double some_random_value_for_gamma = (
pow(ll,2)+
pow(lu,2)-tmp1)/(2.*ll*lu);
    91   if (some_random_value_for_gamma > 1) {
    92     some_random_value_for_gamma = 1;
    94   if (some_random_value_for_gamma < -1) {
    95     some_random_value_for_gamma = -1;
    97   double gamma  = 
acos(some_random_value_for_gamma);
   100   q_KFE_bf = q_KFE_br = gamma - M_PI;
   113     return Vector3d(q_HAA_bf, q_HFE_bf, q_KFE_bf);
   115     return Vector3d(q_HAA_br, -q_HFE_br, -q_KFE_br);
   122   const static double haa_min = -180;
   123   const static double haa_max =  90;
   125   const static double hfe_min = -90;
   126   const static double hfe_max =  90;
   128   const static double kfe_min = -180;
   129   const static double kfe_max =  0;
   132   static const std::map<HyqJointID, double> max_range {
   133     {
HAA, haa_max/180.0*M_PI},
   134     {
HFE, hfe_max/180.0*M_PI},
   135     {
KFE, kfe_max/180.0*M_PI}
   139   static const std::map<HyqJointID, double> min_range {
   140     {
HAA, haa_min/180.0*M_PI},
   141     {
HFE, hfe_min/180.0*M_PI},
   142     {
KFE, kfe_min/180.0*M_PI}
   145   double max = max_range.at(joint);
   146   val = val>max? max : val;
   148   double min = min_range.at(joint);
   149   val = val<min? min : val;
 
void EnforceLimits(double &q, HyqJointID joint) const 
Restricts the joint angles to lie inside the feasible range. 
Vector3d GetJointAngles(const Vector3d &ee_pos_H, KneeBend bend=Forward) const 
Returns the joint angles to reach a Cartesian foot position. 
double min(double a, double b)
INLINE Rall1d< T, V, S > sqrt(const Rall1d< T, V, S > &arg)
INLINE Rall1d< T, V, S > pow(const Rall1d< T, V, S > &arg, double m)
INLINE Rall1d< T, V, S > acos(const Rall1d< T, V, S > &x)
INLINE Rall1d< T, V, S > atan2(const Rall1d< T, V, S > &y, const Rall1d< T, V, S > &x)
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
double max(double a, double b)
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)