walking_control.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright 2017 ROBOTIS CO., LTD.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *******************************************************************************/
16 
17 /* Author: SCH */
18 
19 #ifndef OP3_ONLINE_WALKING_MODULE_WALKING_CONTROL_
20 #define OP3_ONLINE_WALKING_MODULE_WALKING_CONTROL_
21 
22 #pragma once
23 
24 #include <math.h>
25 #include <stdint.h>
26 #include <string>
27 #include <vector>
28 #include <map>
29 #include <geometry_msgs/Pose2D.h>
30 #include <eigen3/Eigen/Eigen>
31 #include "op3_online_walking_module_msgs/FootStepCommand.h"
32 #include "op3_online_walking_module_msgs/FootStepArray.h"
33 #include "op3_online_walking_module_msgs/PreviewResponse.h"
34 #include "op3_online_walking_module_msgs/Step2D.h"
35 #include "op3_online_walking_module_msgs/Step2DArray.h"
36 //#include "op3_kinematics_dynamics/op3_kinematics_dynamics.h"
38 
40  LEFT_LEG = 0,
41  RIGHT_LEG = 1,
43 };
44 
46  DSP = 0, // Double Support Phase
47  SSP = 1, // Single Support Phase
49 };
50 
52 {
53 public:
54  WalkingControl(double control_cycle,
55  double dsp_ratio, double lipm_height, double foot_height_max, double zmp_offset_x, double zmp_offset_y,
56  std::vector<double_t> x_lipm, std::vector<double_t> y_lipm,
57  double foot_distance);
58  virtual ~WalkingControl();
59 
60  void initialize(op3_online_walking_module_msgs::FootStepCommand foot_step_command,
61  std::vector<double_t> init_body_pos, std::vector<double_t> init_body_Q,
62  std::vector<double_t> init_r_foot_pos, std::vector<double_t> init_r_foot_Q,
63  std::vector<double_t> init_l_foot_pos, std::vector<double_t> init_l_foot_Q);
64  void initialize(op3_online_walking_module_msgs::Step2DArray foot_step_2d,
65  std::vector<double_t> init_body_pos, std::vector<double_t> init_body_Q,
66  std::vector<double_t> init_r_foot_pos, std::vector<double_t> init_r_foot_Q,
67  std::vector<double_t> init_l_foot_pos, std::vector<double_t> init_l_foot_Q);
68  void next();
69  void finalize();
70  void set(double time, int step, bool foot_step_2d);
71 
72  double getLipmHeight();
73 
74  void calcFootStepParam();
75 
76  void transformFootStep2D();
77 
78  void calcFootTrajectory(int step);
79  void calcFootStepPose(double time, int step);
80  void calcRefZMP(int step);
81  void calcPreviewParam(std::vector<double_t> K, int K_row, int K_col,
82  std::vector<double_t> P, int P_row, int P_col);
83  void calcPreviewControl(double time, int step);
84 
85  void calcGoalFootPose();
86 
87  double calcRefZMPx(int step);
88  double calcRefZMPy(int step);
89 
90  void getWalkingPosition(std::vector<double_t> &l_foot_pos,
91  std::vector<double_t> &r_foot_pos,
92  std::vector<double_t> &body_pos);
93  void getWalkingVelocity(std::vector<double_t> &l_foot_vel,
94  std::vector<double_t> &r_foot_vel,
95  std::vector<double_t> &body_vel);
96  void getWalkingAccleration(std::vector<double_t> &l_foot_accel,
97  std::vector<double_t> &r_foot_accel,
98  std::vector<double_t> &body_accel);
99  void getWalkingOrientation(std::vector<double_t> &l_foot_Q,
100  std::vector<double_t> &r_foot_Q,
101  std::vector<double_t> &body_Q);
102  void getLIPM(std::vector<double_t> &x_lipm, std::vector<double_t> &y_lipm);
103  void getWalkingState(int &walking_leg, int &walking_phase);
104 
105 protected:
106 // thormang3::KinematicsDynamics *robot_;
107 
111 
113 
116 
119 
120  // Foot Trajectory
121  double foot_size_x_;
122  double foot_size_y_;
125 
126  double dsp_ratio_;
128 
130  op3_online_walking_module_msgs::FootStepCommand foot_step_command_;
131  op3_online_walking_module_msgs::FootStepArray foot_step_param_;
132  op3_online_walking_module_msgs::PreviewResponse preview_response_;
133 
134  op3_online_walking_module_msgs::Step2DArray foot_step_2d_;
135 
136  // Preview Control
139  double lipm_height_;
142  Eigen::MatrixXd A_, b_, c_;
143  Eigen::MatrixXd k_x_;
144  double k_s_;
145  Eigen::MatrixXd f_;
146  Eigen::MatrixXd u_x_, u_y_;
147  Eigen::MatrixXd x_lipm_, y_lipm_;
148 
149  Eigen::MatrixXd K_, P_;
150 
154 
156  Eigen::MatrixXd ref_zmp_buffer_;
157 
158  // Pose Information
160 
162  std::vector<double_t> des_body_pos_, des_body_vel_, des_body_accel_;
164  Eigen::Quaterniond init_body_Q_, des_body_Q_, goal_body_Q_;
165 
170 
175 };
176 
177 #endif
void getWalkingPosition(std::vector< double_t > &l_foot_pos, std::vector< double_t > &r_foot_pos, std::vector< double_t > &body_pos)
op3_online_walking_module_msgs::PreviewResponse preview_response_
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 > 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_
Eigen::MatrixXd ref_zmp_buffer_
robotis_framework::MinimumJerkViaPoint * r_foot_tra_
std::vector< double_t > goal_r_foot_vel_
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_
Eigen::MatrixXd u_x_
virtual ~WalkingControl()
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_
WALKING_PHASE
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::MatrixXd A_
double preview_sum_zmp_x_
void calcFootStepPose(double time, int step)
robotis_framework::MinimumJerk * body_trajectory_
Eigen::MatrixXd y_lipm_
WALKING_LEG
Eigen::Quaterniond goal_body_Q_
std::vector< double_t > goal_r_foot_pos_
Eigen::Quaterniond des_r_foot_Q_
Eigen::MatrixXd b_
Eigen::Quaterniond init_body_Q_
Eigen::MatrixXd u_y_
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_
Eigen::MatrixXd k_x_
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_
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_
Eigen::MatrixXd c_
std::vector< double_t > goal_l_foot_pos_
std::vector< double_t > init_l_foot_vel_
std::vector< double_t > goal_l_foot_vel_
Eigen::MatrixXd x_lipm_
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_
Eigen::MatrixXd P_
Eigen::MatrixXd f_
std::vector< double_t > goal_r_foot_accel_
std::vector< double_t > goal_body_vel_
void calcPreviewControl(double time, int step)
Eigen::MatrixXd goal_r_foot_pos_buffer_
Eigen::MatrixXd K_


op3_online_walking_module
Author(s): SCH
autogenerated on Mon Jun 10 2019 14:41:22