thormang3_online_walking.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright 2018 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 /*
18  * thormang3_online_walking.h
19  *
20  * Created on: 2016. 6. 10.
21  * Author: Jay Song
22  */
23 
24 
25 #ifndef THORMANG3_WALKING_MODULE_THORMANG3_ONLINEL_WALKING_H_
26 #define THORMANG3_WALKING_MODULE_THORMANG3_ONLINEL_WALKING_H_
27 
28 #include <vector>
29 #include <ros/ros.h>
30 #include <ros/package.h>
31 #include <boost/thread.hpp>
32 #include <eigen3/Eigen/Eigen>
33 #include <yaml-cpp/yaml.h>
34 
37 
40 
41 #define _USE_PD_BALANCE_
42 
43 namespace thormang3
44 {
45 
46 class THORMANG3OnlineWalking : public robotis_framework::Singleton<THORMANG3OnlineWalking>
47 {
48 public:
50  virtual ~THORMANG3OnlineWalking();
51 
52  void initialize();
53  void reInitialize();
54  void start();
55  void stop();
56  void process();
57  bool isRunning();
58 
60  void eraseLastStepData();
62  void getReferenceStepDatafotAddition(robotis_framework::StepData *ref_step_data_for_addition);
63 
64  void setRefZMPDecisionParameter(double X_ZMP_CenterShift, double Y_ZMP_CenterShift, double Y_ZMP_Convergence);
65 
66  bool setInitialPose(double r_foot_x, double r_foot_y, double r_foot_z, double r_foot_roll, double r_foot_pitch, double r_foot_yaw,
67  double l_foot_x, double l_foot_y, double l_foot_z, double l_foot_roll, double l_foot_pitch, double l_foot_yaw,
68  double center_of_body_x, double center_of_body_y, double center_of_body_z,
69  double center_of_body_roll, double center_of_body_pitch, double center_of_body_yaw);
70 
71  void setInitalWaistYawAngle(double waist_yaw_angle_rad);
72 
73  void setInitialRightShoulderAngle(double shoulder_angle_rad);
74  void setInitialLeftShoulderAngle(double shoulder_angle_rad);
75  void setInitialRightElbowAngle(double elbow_angle_rad);
76  void setInitialLeftElbowAngle(double elbow_angle_rad);
77 
78  void setCurrentIMUSensorOutput(double gyro_x, double gyro_y, double quat_x, double quat_y, double quat_z, double quat_w);
79 
80  Eigen::MatrixXd mat_cob_to_g_, mat_g_to_cob_;
82  Eigen::MatrixXd mat_robot_to_g_, mat_g_to_robot_;
85 
86  Eigen::MatrixXd mat_g_to_rfoot_, mat_g_to_lfoot_;
87 
94  double out_angle_rad_[16];
95 
97 
98  double curr_angle_rad_[12];
100 
101  // balance control
104 
105 
106  // sensor value
111 
112  Eigen::Quaterniond quat_current_imu_;
113  Eigen::MatrixXd mat_current_imu_;
116 
117 private:
118  void calcStepIdxData();
119  void calcRefZMP();
120  void calcDesiredPose();
121 
122  double wsin(double time, double period, double period_shift, double mag, double mag_shift);
123  double wsigmoid(double time, double period, double time_shift, double mag, double mag_shift, double sigmoid_ratio, double distortion_ratio);
124 
127  Eigen::MatrixXd des_balance_offset_;
130  double mov_time_;
132 
133  void parseBalanceOffsetData(const std::string &path);
134  void initBalanceOffset();
135  void setBalanceOffset();
136 
138 
143 
147 
149  Eigen::MatrixXd mat_robot_to_rf_modified_;
150  Eigen::MatrixXd mat_robot_to_lf_modified_;
151  Eigen::MatrixXd mat_robot_to_rfoot_;
152  Eigen::MatrixXd mat_robot_to_lfoot_;
153 
154  std::vector<robotis_framework::StepData> added_step_data_;
155 
170 
178 
180  Eigen::MatrixXd rot_x_pi_3d_, rot_z_pi_3d_;
181 
182  Eigen::VectorXi step_idx_data_;
183  boost::mutex step_data_mutex_lock_;
184  boost::mutex imu_data_mutex_lock_;
185 
186  //Time for Preview Control and Dynamics Regulator
189 
190  //These matrix and parameters are for preview control
191  Eigen::MatrixXd A_, b_, c_;
192  Eigen::MatrixXd k_x_;
193  Eigen::MatrixXd f_;
194  double k_s_;
195  double sum_of_zmp_x_ ;
196  double sum_of_zmp_y_ ;
197  double sum_of_cx_ ;
198  double sum_of_cy_ ;
199  Eigen::MatrixXd u_x, u_y;
200  Eigen::MatrixXd x_lipm_, y_lipm_;
201 
203 
206 
208 
209  double walking_time_; //Absolute Time
210  double reference_time_; //Absolute Time
213 };
214 
215 }
216 
217 #endif /* THORMANG3_WALKING_MODULE_THORMANG3_ONLINEL_WALKING_H_ */
robotis_framework::Pose3D present_left_foot_pose_
robotis_framework::Pose3D rhip_to_rfoot_pose_
void setInitialLeftShoulderAngle(double shoulder_angle_rad)
robotis_framework::Pose3D initial_left_foot_pose_
robotis_framework::Pose3D present_body_pose_
void getReferenceStepDatafotAddition(robotis_framework::StepData *ref_step_data_for_addition)
robotis_framework::FifthOrderPolynomialTrajectory foot_x_tra_
robotis_framework::Pose3D initial_body_pose_
robotis_framework::FifthOrderPolynomialTrajectory foot_z_tra_
void setInitialRightElbowAngle(double elbow_angle_rad)
robotis_framework::FifthOrderPolynomialTrajectory body_z_tra_
void parseBalanceOffsetData(const std::string &path)
robotis_framework::Pose3D lhip_to_lfoot_pose_
robotis_framework::StepData reference_step_data_for_addition_
thormang3::BalanceControlUsingPDController balance_ctrl_
robotis_framework::MinimumJerkViaPoint * feed_forward_tra_
robotis_framework::Pose3D present_right_foot_pose_
bool setInitialPose(double r_foot_x, double r_foot_y, double r_foot_z, double r_foot_roll, double r_foot_pitch, double r_foot_yaw, double l_foot_x, double l_foot_y, double l_foot_z, double l_foot_roll, double l_foot_pitch, double l_foot_yaw, double center_of_body_x, double center_of_body_y, double center_of_body_z, double center_of_body_roll, double center_of_body_pitch, double center_of_body_yaw)
robotis_framework::FifthOrderPolynomialTrajectory foot_z_swap_tra_
robotis_framework::Pose3D previous_step_body_pose_
robotis_framework::FifthOrderPolynomialTrajectory waist_yaw_tra_
void setInitialRightShoulderAngle(double shoulder_angle_rad)
robotis_framework::Pose3D previous_step_left_foot_pose_
std::vector< robotis_framework::StepData > added_step_data_
robotis_framework::FifthOrderPolynomialTrajectory foot_roll_tra_
void setCurrentIMUSensorOutput(double gyro_x, double gyro_y, double quat_x, double quat_y, double quat_z, double quat_w)
robotis_framework::FifthOrderPolynomialTrajectory body_pitch_tra_
void setInitalWaistYawAngle(double waist_yaw_angle_rad)
double wsin(double time, double period, double period_shift, double mag, double mag_shift)
robotis_framework::FifthOrderPolynomialTrajectory body_yaw_tra_
bool addStepData(robotis_framework::StepData step_data)
robotis_framework::FifthOrderPolynomialTrajectory hip_roll_swap_tra_
robotis_framework::Pose3D previous_step_right_foot_pose_
robotis_framework::FifthOrderPolynomialTrajectory body_roll_tra_
robotis_framework::FifthOrderPolynomialTrajectory foot_pitch_tra_
robotis_framework::StepData current_step_data_
robotis_framework::Pose3D initial_right_foot_pose_
thormang3::BalancePDController leg_angle_feed_back_[12]
void setRefZMPDecisionParameter(double X_ZMP_CenterShift, double Y_ZMP_CenterShift, double Y_ZMP_Convergence)
double wsigmoid(double time, double period, double time_shift, double mag, double mag_shift, double sigmoid_ratio, double distortion_ratio)
void setInitialLeftElbowAngle(double elbow_angle_rad)
robotis_framework::FifthOrderPolynomialTrajectory foot_yaw_tra_
robotis_framework::FifthOrderPolynomialTrajectory body_z_swap_tra_
robotis_framework::FifthOrderPolynomialTrajectory foot_y_tra_


thormang3_walking_module
Author(s): Zerom , SCH , Kayman , Jay Song
autogenerated on Mon Jun 10 2019 15:37:56