7#include <angles/angles.h>
12#include <control_toolbox/pid.h>
13#include <geometry_msgs/Quaternion.h>
14#include <hardware_interface/joint_command_interface.h>
22static inline double get_LM(
const double& l)
24 return 0.218f * l + 0.075f;
27static inline double get_i_p(
const double& l)
29 return 0.4f * l + 0.07f;
32static inline double get_theta_leg_offset(
const double& l)
44inline void generateAB(
const std::shared_ptr<ModelParams>& model_params, Eigen::Matrix<double, STATE_DIM, STATE_DIM>& a,
45 Eigen::Matrix<double, STATE_DIM, CONTROL_DIM>& b,
double leg_length)
47 double A[36] = { 0. }, B[12]{ 0. };
50 double Lm = get_LM(leg_length);
51 double L = leg_length - Lm;
52 double i_p = get_i_p(leg_length);
68 gen_A(model_params->i_m, i_p, model_params->i_w, L, Lm, model_params->M, model_params->r, model_params->g,
69 model_params->l, model_params->m_p, model_params->m_w, A);
70 gen_B(model_params->i_m, i_p, model_params->i_w, L, Lm, model_params->M, model_params->r, model_params->l,
71 model_params->m_p, model_params->m_w, B);
74 a<< 0. ,1.,0.,0.,0. ,0.,
75 A[1],0.,0.,0.,A[25],0.,
77 A[3],0.,0.,0.,A[27],0.,
79 A[5],0.,0.,0.,A[29],0.;
98 const LegCommand& right_cmd,
double wheel_left = 0.,
double wheel_right = 0.)
100 if (joints.size() != 6)
101 throw std::runtime_error(
"Joint handle vector size must be 6!");
103 joints[0]->setCommand(left_cmd.
input[0]);
104 joints[1]->setCommand(left_cmd.
input[1]);
105 joints[2]->setCommand(right_cmd.
input[0]);
106 joints[3]->setCommand(right_cmd.
input[1]);
107 joints[4]->setCommand(wheel_left);
108 joints[5]->setCommand(wheel_right);
118inline void quatToRPY(
const geometry_msgs::Quaternion& q,
double& roll,
double& pitch,
double& yaw)
120 double as = std::min(-2. * (q.x * q.z - q.w * q.y), .99999);
121 yaw = std::atan2(2 * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z);
122 pitch = std::asin(as);
123 roll = std::atan2(2 * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z);
126inline void clamp(
double& val,
const double& minVal,
const double& maxVal)
void gen_A(double Im, double Ip, double Iw, double L, double Lm, double M, double R, double g, double l, double mp, double mw, double A[36])
Definition gen_A.c:32
void gen_B(double Im, double Ip, double Iw, double L, double Lm, double M, double R, double l, double mp, double mw, double B[12])
Definition gen_B.c:29
Definition active_suspension.h:16
void setJointCommands(std::vector< hardware_interface::JointHandle * > &joints, const LegCommand &left_cmd, const LegCommand &right_cmd, double wheel_left=0., double wheel_right=0.)
Definition helper_functions.h:97
void quatToRPY(const geometry_msgs::Quaternion &q, double &roll, double &pitch, double &yaw)
Definition helper_functions.h:118
void generateAB(const std::shared_ptr< ModelParams > &model_params, Eigen::Matrix< double, STATE_DIM, STATE_DIM > &a, Eigen::Matrix< double, STATE_DIM, CONTROL_DIM > &b, double leg_length)
Definition helper_functions.h:44
void clamp(double &val, const double &minVal, const double &maxVal)
Definition helper_functions.h:126
Definition definitions.h:84
double input[2]
Definition definitions.h:87