23 double dsp_ratio,
double lipm_height,
double foot_height_max,
double zmp_offset_x,
double zmp_offset_y,
24 std::vector<double_t> x_lipm, std::vector<double_t> y_lipm,
94 for (
int i=0; i<3; i++)
96 x_lipm_.coeffRef(i,0) = x_lipm[i];
97 y_lipm_.coeffRef(i,0) = y_lipm[i];
113 std::vector<double_t> init_body_pos, std::vector<double_t> init_body_Q,
114 std::vector<double_t> init_r_foot_pos, std::vector<double_t> init_r_foot_Q,
115 std::vector<double_t> init_l_foot_pos, std::vector<double_t> init_l_foot_Q)
120 Eigen::Quaterniond body_Q(init_body_Q[3],init_body_Q[0],init_body_Q[1],init_body_Q[2]);
133 Eigen::Quaterniond l_foot_Q(init_l_foot_Q[3],init_l_foot_Q[0],init_l_foot_Q[1],init_l_foot_Q[2]);
137 Eigen::Quaterniond r_foot_Q(init_r_foot_Q[3],init_r_foot_Q[0],init_r_foot_Q[1],init_r_foot_Q[2]);
157 std::vector<double_t> init_body_pos, std::vector<double_t> init_body_Q,
158 std::vector<double_t> init_r_foot_pos, std::vector<double_t> init_r_foot_Q,
159 std::vector<double_t> init_l_foot_pos, std::vector<double_t> init_l_foot_Q)
164 Eigen::Quaterniond body_Q(init_body_Q[3],init_body_Q[0],init_body_Q[1],init_body_Q[2]);
177 Eigen::Quaterniond l_foot_Q(init_l_foot_Q[3],init_l_foot_Q[0],init_l_foot_Q[1],init_l_foot_Q[2]);
181 Eigen::Quaterniond r_foot_Q(init_r_foot_Q[3],init_r_foot_Q[0],init_r_foot_Q[1],init_r_foot_Q[2]);
239 double fin_time =
fin_time_ - dsp_length;
242 double ik_tol = 1e-4;
244 bool ik_success =
false;
247 if (time < init_time)
252 else if (time > fin_time)
266 double count = (time - init_time) / fin_time;
276 Eigen::MatrixXd des_r_foot_pos = Eigen::MatrixXd::Zero(3,1);
281 if (time < init_time)
283 else if (time > fin_time)
287 double count = (time - init_time) / fin_time;
292 Eigen::MatrixXd des_l_foot_pos = Eigen::MatrixXd::Zero(3,1);
297 if (time < init_time)
299 else if (time > fin_time)
303 double count = (time - init_time) / fin_time;
313 int walking_start_leg;
328 int walking_leg = walking_start_leg;
333 geometry_msgs::Pose2D msg;
353 walking_leg = walking_start_leg++ %
LEG_COUNT;
354 double lr = walking_leg;
357 lr += -1.0; lr *= -1.0;
363 lr += -1.0; lr *= -1.0;
395 i == foot_step_size_-2 ||
396 i == foot_step_size_-1)
404 msg.theta = foot_angle;
430 std::vector<double_t> init_r_foot_pos, init_l_foot_pos;
431 init_r_foot_pos.resize(2, 0.0);
435 init_l_foot_pos.resize(2, 0.0);
439 std::vector<double_t> goal_r_foot_pos, goal_l_foot_pos;
440 goal_r_foot_pos.resize(2, 0.0);
441 goal_l_foot_pos.resize(2, 0.0);
443 op3_online_walking_module_msgs::FootStepArray foot_step_param;
447 op3_online_walking_module_msgs::Step2D msg =
foot_step_2d_.footsteps_2d[step];
449 foot_step_param.moving_foot.push_back(msg.moving_foot);
450 geometry_msgs::Pose2D foot_pose_2d;
451 foot_pose_2d.theta = msg.step2d.theta;
452 foot_step_param.data.push_back(foot_pose_2d);
454 if (step == foot_step_size_ - 1)
456 goal_r_foot_pos = init_r_foot_pos;
457 goal_l_foot_pos = init_l_foot_pos;
465 goal_l_foot_pos[0] = msg.step2d.x;
466 goal_l_foot_pos[1] = msg.step2d.y;
468 goal_r_foot_pos = init_r_foot_pos;
474 goal_r_foot_pos[0] = msg.step2d.x;
475 goal_r_foot_pos[1] = msg.step2d.y;
477 goal_l_foot_pos = init_l_foot_pos;
486 init_r_foot_pos = goal_r_foot_pos;
487 init_l_foot_pos = goal_l_foot_pos;
533 std::vector<double_t> via_l_foot_pos, via_l_foot_vel, via_l_foot_accel;
534 via_l_foot_pos.resize(3, 0.0);
535 via_l_foot_vel.resize(3, 0.0);
536 via_l_foot_accel.resize(3, 0.0);
542 if (step == 0 || step == 1)
543 via_l_foot_pos[2] = 0.0;
546 via_l_foot_pos[2] = 0.0;
552 via_l_foot_pos, via_l_foot_vel, via_l_foot_accel);
581 std::vector<double_t> via_r_foot_pos, via_r_foot_vel, via_r_foot_accel;
582 via_r_foot_pos.resize(3, 0.0);
583 via_r_foot_vel.resize(3, 0.0);
584 via_r_foot_accel.resize(3, 0.0);
590 if (step == 0 || step == 1)
591 via_r_foot_pos[2] = 0.0;
594 via_r_foot_pos[2] = 0.0;
600 via_r_foot_pos, via_r_foot_vel, via_r_foot_accel);
643 if (step == 0 || step == 1)
675 std::vector<double_t> init_r_foot_pos, init_l_foot_pos;
676 init_r_foot_pos.resize(2, 0.0);
680 init_l_foot_pos.resize(2, 0.0);
684 std::vector<double_t> goal_r_foot_pos, goal_l_foot_pos;
685 goal_r_foot_pos.resize(2, 0.0);
686 goal_l_foot_pos.resize(2, 0.0);
696 goal_l_foot_pos[0] = init_r_foot_pos[0]
699 goal_l_foot_pos[1] = init_r_foot_pos[1]
703 goal_r_foot_pos = init_r_foot_pos;
709 goal_r_foot_pos[0] = init_l_foot_pos[0]
712 goal_r_foot_pos[1] = init_l_foot_pos[1]
716 goal_l_foot_pos = init_l_foot_pos;
724 init_r_foot_pos = goal_r_foot_pos;
725 init_l_foot_pos = goal_l_foot_pos;
736 if (step == 0 || step == 1)
759 if (step == 0 || step == 1)
780 std::vector<double_t> P,
int P_row,
int P_col)
805 std::vector<double_t> matrix_K = K;
809 std::vector<double_t> matrix_P = P;
811 K_.resize(row_K,col_K);
812 P_.resize(row_P,col_P);
814 for(
int j=0 ; j<row_K ; j++)
816 for(
int i=0 ; i<col_K ; i++)
817 K_.coeffRef(j,i) = matrix_K[i*row_K+j];
820 for(
int j=0; j<row_P; j++)
822 for(
int i=0 ; i<col_P; i++)
823 P_.coeffRef(j,i) = matrix_P[i*row_P+j];
828 k_x_ <<
K_.coeff(0,1),
K_.coeff(0,2),
K_.coeff(0,3);
860 int step_new = step + index_new/fin_index;
865 double preview_zmp_x =
f_.coeff(0,i)*ref_zmp_x;
866 double preview_zmp_y =
f_.coeff(0,i)*ref_zmp_y;
905 std::vector<double_t> &r_foot_pos,
906 std::vector<double_t> &body_pos)
918 std::vector<double_t> &r_foot_vel,
919 std::vector<double_t> &body_vel)
929 std::vector<double_t> &r_foot_accel,
930 std::vector<double_t> &body_accel)
940 std::vector<double_t> &r_foot_Q,
941 std::vector<double_t> &body_Q)
961 x_lipm.resize(3, 0.0);
962 y_lipm.resize(3, 0.0);
964 for (
int i=0; i<3; i++)
966 x_lipm[i] =
x_lipm_.coeff(i,0);
967 y_lipm[i] =
y_lipm_.coeff(i,0);
void getWalkingPosition(std::vector< double_t > &l_foot_pos, std::vector< double_t > &r_foot_pos, std::vector< double_t > &body_pos)
void transformFootStep2D()
std::vector< double_t > des_l_foot_pos_
std::vector< double_t > init_r_foot_pos_
op3_online_walking_module_msgs::FootStepCommand foot_step_command_
Eigen::Quaterniond des_l_foot_Q_
void calcRefZMP(int step)
std::vector< double_t > getVelocity(double time)
std::vector< double_t > goal_l_foot_accel_
void getWalkingState(int &walking_leg, int &walking_phase)
std::vector< double_t > init_l_foot_accel_
void initialize(op3_online_walking_module_msgs::FootStepCommand foot_step_command, std::vector< double_t > init_body_pos, std::vector< double_t > init_body_Q, std::vector< double_t > init_r_foot_pos, std::vector< double_t > init_r_foot_Q, std::vector< double_t > init_l_foot_pos, std::vector< double_t > init_l_foot_Q)
std::vector< double_t > des_body_vel_
WalkingControl(double control_cycle, double dsp_ratio, double lipm_height, double foot_height_max, double zmp_offset_x, double zmp_offset_y, std::vector< double_t > x_lipm, std::vector< double_t > y_lipm, double foot_distance)
double foot_origin_shift_x_
void calcFootTrajectory(int step)
robotis_framework::PreviewControl * preview_control_
std::vector< double_t > des_body_accel_
robotis_framework::MinimumJerkViaPoint * r_foot_tra_
std::vector< double_t > goal_r_foot_vel_
Eigen::Quaterniond convertRPYToQuaternion(double roll, double pitch, double yaw)
void getWalkingVelocity(std::vector< double_t > &l_foot_vel, std::vector< double_t > &r_foot_vel, std::vector< double_t > &body_vel)
double init_body_yaw_angle_
std::vector< double_t > goal_body_accel_
std::vector< double_t > des_r_foot_accel_
Eigen::MatrixXd goal_l_foot_pos_buffer_
virtual ~WalkingControl()
Eigen::Quaterniond convertRotationToQuaternion(const Eigen::Matrix3d &rotation)
Eigen::Quaterniond des_body_Q_
double preview_sum_zmp_y_
std::vector< double_t > init_r_foot_vel_
std::vector< double_t > des_l_foot_accel_
std::vector< double_t > init_body_pos_
Eigen::Vector3d convertQuaternionToRPY(const Eigen::Quaterniond &quaternion)
double calcRefZMPx(int step)
std::vector< double_t > goal_body_pos_
Eigen::Quaterniond init_r_foot_Q_
void calcPreviewParam(std::vector< double_t > K, int K_row, int K_col, std::vector< double_t > P, int P_row, int P_col)
Eigen::Matrix3d convertQuaternionToRotation(const Eigen::Quaterniond &quaternion)
double preview_sum_zmp_x_
void calcFootStepPose(double time, int step)
Eigen::Quaterniond goal_body_Q_
std::vector< double_t > goal_r_foot_pos_
std::vector< double_t > getAcceleration(double time)
Eigen::Quaterniond des_r_foot_Q_
Eigen::Quaterniond init_body_Q_
Eigen::MatrixXd calcPreviewParam(double preview_time, double control_cycle, double lipm_height, Eigen::MatrixXd K, Eigen::MatrixXd P)
void getWalkingAccleration(std::vector< double_t > &l_foot_accel, std::vector< double_t > &r_foot_accel, std::vector< double_t > &body_accel)
robotis_framework::MinimumJerkViaPoint * l_foot_tra_
double calcRefZMPy(int step)
std::vector< double_t > des_r_foot_vel_
Eigen::Quaterniond goal_r_foot_Q_
std::vector< double_t > des_body_pos_
op3_online_walking_module_msgs::Step2DArray foot_step_2d_
std::vector< double_t > des_r_foot_pos_
std::vector< double_t > getPosition(double time)
double foot_origin_shift_y_
std::vector< double_t > des_l_foot_vel_
std::vector< double_t > init_body_accel_
Eigen::Quaterniond init_l_foot_Q_
std::vector< double_t > init_body_vel_
std::vector< double_t > init_l_foot_pos_
std::vector< double_t > goal_l_foot_pos_
std::vector< double_t > init_l_foot_vel_
std::vector< double_t > goal_l_foot_vel_
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
std::vector< double_t > init_r_foot_accel_
void getWalkingOrientation(std::vector< double_t > &l_foot_Q, std::vector< double_t > &r_foot_Q, std::vector< double_t > &body_Q)
void getLIPM(std::vector< double_t > &x_lipm, std::vector< double_t > &y_lipm)
op3_online_walking_module_msgs::FootStepArray foot_step_param_
Eigen::Quaterniond goal_l_foot_Q_
void set(double time, int step, bool foot_step_2d)
std::vector< double_t > goal_r_foot_accel_
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)
std::vector< double_t > goal_body_vel_
void calcPreviewControl(double time, int step)
Eigen::MatrixXd goal_r_foot_pos_buffer_