thormang3_balance_control.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_balance_control.h
19  *
20  * Created on: 2016. 12. 14
21  * Author: Jay Song
22  */
23 
24 #ifndef THORMANG3_BALANCE_CONTROL_THORMANG3_BALANCE_CONTROL_H_
25 #define THORMANG3_BALANCE_CONTROL_THORMANG3_BALANCE_CONTROL_H_
26 
27 #include <eigen3/Eigen/Eigen>
29 
30 namespace thormang3
31 {
32 
34 {
35 public:
36  static const int NoError = 0;
37  static const int BalanceLimit = 2;
38 };
39 
41 {
42 public:
44  DampingController(double time_unit_sec);
46 
47  double getDampingControllerOutput(double present_sensor_output);
48 
49  double desired_;
50 
51  double gain_;
53  double output_;
54 
56 
57 private:
59 };
60 
62 {
63 public:
66 
67  double desired_;
68 
69  double p_gain_;
70  double d_gain_;
71 
72  double getFeedBack(double present_sensor_output);
73 
74 private:
75  double curr_err_;
76  double prev_err_;
77 };
78 
80 {
81 public:
83  BalanceLowPassFilter(double control_cycle_sec, double cut_off_frequency);
85 
86  void initialize(double control_cycle_sec_, double cut_off_frequency);
87  void setCutOffFrequency(double cut_off_frequency);
88  double getCutOffFrequency(void);
89  double getFilteredOutput(double present_raw_value);
90 
91 private:
92  double cut_off_freq_;
94  double alpha_;
95 
96  double prev_output_;
97 };
98 
100 {
101 public:
104 
105  void initialize(const int control_cycle_msec);
106 
107  void setGyroBalanceEnable(bool enable);
108  void setOrientationBalanceEnable(bool enable);
109  void setForceTorqueBalanceEnable(bool enable);
110 
111  void process(int *balance_error, Eigen::MatrixXd *robot_to_cob_modified, Eigen::MatrixXd *robot_to_right_foot_modified, Eigen::MatrixXd *robot_to_left_foot_modified);
112 
113  void setDesiredPose(const Eigen::MatrixXd &robot_to_cob, const Eigen::MatrixXd &robot_to_right_foot, const Eigen::MatrixXd &robot_to_left_foot);
114 
115  // all arguments are with respect to robot coordinate.
116  void setDesiredCOBGyro(double gyro_roll, double gyro_pitch);
117  void setDesiredCOBOrientation(double cob_orientation_roll, double cob_orientation_pitch);
118  void setDesiredFootForceTorque(double r_force_x_N, double r_force_y_N, double r_force_z_N,
119  double r_torque_roll_Nm, double r_torque_pitch_Nm, double r_torque_yaw_Nm,
120  double l_force_x_N, double l_force_y_N, double l_force_z_N,
121  double l_torque_roll_Nm, double l_torque_pitch_Nm, double l_torque_yaw_Nm);
122 
123  // with respect to robot coordinate.
124  void setCurrentGyroSensorOutput(double gyro_roll, double gyro_pitch);
125  void setCurrentOrientationSensorOutput(double cob_orientation_roll, double cob_orientation_pitch);
126 
127  // with respect to robot coordinate.
128  void setCurrentFootForceTorqueSensorOutput(double r_force_x_N, double r_force_y_N, double r_force_z_N,
129  double r_torque_roll_Nm, double r_torque_pitch_Nm, double r_torque_yaw_Nm,
130  double l_force_x_N, double l_force_y_N, double l_force_z_N,
131  double l_torque_roll_Nm, double l_torque_pitch_Nm, double l_torque_yaw_Nm);
132 
133 
134  // set maximum adjustment
135  void setMaximumAdjustment(double cob_x_max_adjustment_m, double cob_y_max_adjustment_m, double cob_z_max_adjustment_m,
136  double cob_roll_max_adjustment_rad, double cob_pitch_max_adjustment_rad, double cob_yaw_max_adjustment_rad,
137  double foot_x_max_adjustment_m, double foot_y_max_adjustment_m, double foot_z_max_adjustment_m,
138  double foot_roll_max_adjustment_rad, double foot_pitch_max_adjustment_rad, double foot_yaw_max_adjustment_rad);
139 
140  //Manual Adjustment
141  void setCOBManualAdjustment(double cob_x_adjustment_m, double cob_y_adjustment_m, double cob_z_adjustment_m);
142  double getCOBManualAdjustmentX();
143  double getCOBManualAdjustmentY();
144  double getCOBManualAdjustmentZ();
145 
146  void setGyroBalanceGainRatio(double gyro_balance_gain_ratio);
147  double getGyroBalanceGainRatio(void);
148 
149  // damping controllers
152 
156 
161 
166 
167 private:
170 
171  // balance enable
172  double gyro_enable_;
174  double ft_enable_;
175 
176 
177  // desired pose
178  Eigen::MatrixXd desired_robot_to_cob_;
181 
182  // for gyro balancing
188  double gyro_roll_filtered_, gyro_pitch_filtered_;
189  double desired_gyro_roll_, desired_gyro_pitch_;
190 
191  // sensed values
192  double current_gyro_roll_rad_per_sec_, current_gyro_pitch_rad_per_sec_;
193 
194  double current_orientation_roll_rad_, current_orientation_pitch_rad_;
195 
196  double current_right_fx_N_, current_right_fy_N_, current_right_fz_N_;
197  double current_right_tx_Nm_, current_right_ty_Nm_, current_right_tz_Nm_;
198  double current_left_fx_N_, current_left_fy_N_, current_left_fz_N_;
199  double current_left_tx_Nm_, current_left_ty_Nm_, current_left_tz_Nm_;
200 
201  // manual cob adjustment
205 
206  // result of balance control
209 
212 
216 
221 
226 
227  // sum of results of balance control
228  Eigen::VectorXd pose_cob_adjustment_;
230  Eigen::VectorXd pose_left_foot_adjustment_;
231 
232  Eigen::MatrixXd mat_robot_to_cob_modified_;
235 
236  // maximum adjustment
243 
250 
251 };
252 
254 {
255 public:
258 
259  void initialize(const int control_cycle_msec);
260 
261  void setGyroBalanceEnable(bool enable);
262  void setOrientationBalanceEnable(bool enable);
263  void setForceTorqueBalanceEnable(bool enable);
264 
265  void process(int *balance_error, Eigen::MatrixXd *robot_to_cob_modified, Eigen::MatrixXd *robot_to_right_foot_modified, Eigen::MatrixXd *robot_to_left_foot_modified);
266 
267  void setDesiredPose(const Eigen::MatrixXd &robot_to_cob, const Eigen::MatrixXd &robot_to_right_foot, const Eigen::MatrixXd &robot_to_left_foot);
268 
269  // all arguments are with respect to robot coordinate.
270  void setDesiredCOBGyro(double gyro_roll, double gyro_pitch);
271  void setDesiredCOBOrientation(double cob_orientation_roll, double cob_orientation_pitch);
272  void setDesiredFootForceTorque(double r_force_x_N, double r_force_y_N, double r_force_z_N,
273  double r_torque_roll_Nm, double r_torque_pitch_Nm, double r_torque_yaw_Nm,
274  double l_force_x_N, double l_force_y_N, double l_force_z_N,
275  double l_torque_roll_Nm, double l_torque_pitch_Nm, double l_torque_yaw_Nm);
276 
277  // with respect to robot coordinate.
278  void setCurrentGyroSensorOutput(double gyro_roll, double gyro_pitch);
279  void setCurrentOrientationSensorOutput(double cob_orientation_roll, double cob_orientation_pitch);
280 
281  // with respect to robot coordinate.
282  void setCurrentFootForceTorqueSensorOutput(double r_force_x_N, double r_force_y_N, double r_force_z_N,
283  double r_torque_roll_Nm, double r_torque_pitch_Nm, double r_torque_yaw_Nm,
284  double l_force_x_N, double l_force_y_N, double l_force_z_N,
285  double l_torque_roll_Nm, double l_torque_pitch_Nm, double l_torque_yaw_Nm);
286 
287 
288  // set maximum adjustment
289  void setMaximumAdjustment(double cob_x_max_adjustment_m, double cob_y_max_adjustment_m, double cob_z_max_adjustment_m,
290  double cob_roll_max_adjustment_rad, double cob_pitch_max_adjustment_rad, double cob_yaw_max_adjustment_rad,
291  double foot_x_max_adjustment_m, double foot_y_max_adjustment_m, double foot_z_max_adjustment_m,
292  double foot_roll_max_adjustment_rad, double foot_pitch_max_adjustment_rad, double foot_yaw_max_adjustment_rad);
293 
294  //Manual Adjustment
295  void setCOBManualAdjustment(double cob_x_adjustment_m, double cob_y_adjustment_m, double cob_z_adjustment_m);
296  double getCOBManualAdjustmentX();
297  double getCOBManualAdjustmentY();
298  double getCOBManualAdjustmentZ();
299 
300  // damping controllers
305 
308 
313 
318 
319 
322 
325 
331 
337 
338 private:
341 
342  // balance enable
343  double gyro_enable_;
345  double ft_enable_;
346 
347  // desired pose
348  Eigen::MatrixXd desired_robot_to_cob_;
351 
352  // sensed values
353  double current_gyro_roll_rad_per_sec_, current_gyro_pitch_rad_per_sec_;
354 
355  double current_orientation_roll_rad_, current_orientation_pitch_rad_;
356 
357  double current_right_fx_N_, current_right_fy_N_, current_right_fz_N_;
358  double current_right_tx_Nm_, current_right_ty_Nm_, current_right_tz_Nm_;
359  double current_left_fx_N_, current_left_fy_N_, current_left_fz_N_;
360  double current_left_tx_Nm_, current_left_ty_Nm_, current_left_tz_Nm_;
361 
362  // manual cob adjustment
366 
367  // result of balance control
370 
373 
376 
381 
386 
387  // sum of results of balance control
388  Eigen::VectorXd pose_cob_adjustment_;
390  Eigen::VectorXd pose_left_foot_adjustment_;
391 
392  Eigen::MatrixXd mat_robot_to_cob_modified_;
395 
396  // maximum adjustment
403 
410 };
411 
412 }
413 
414 #endif /* THORMANG3_BALANCE_CONTROL_THORMANG3_BALANCE_CONTROL_H_ */
ROSCONSOLE_DECL void initialize()


thormang3_balance_control
Author(s): Jay Song, Kayman
autogenerated on Mon Jun 10 2019 15:37:45