energy changed

This commit is contained in:
sun
2019-08-05 23:51:41 +08:00
parent 74fa004567
commit 00fe7bbab9
2 changed files with 23 additions and 10 deletions

View File

@@ -18,12 +18,16 @@ void Energy::sendEnergy() {
if (camera_cnt == 1) { if (camera_cnt == 1) {
sum_yaw += yaw_rotation; sum_yaw += yaw_rotation;
sum_pitch += pitch_rotation; sum_pitch += pitch_rotation;
if(ROBOT_ID == 3 || ROBOT_ID == 4 || ROBOT_ID == 8){
MINMAX(sum_yaw, -100, 100); MINMAX(sum_yaw, -100, 100);
MINMAX(sum_yaw, -100, 100); MINMAX(sum_yaw, -100, 100);
// float yaw_I_component = BIG_YAW_AIM_KI * sum_yaw; } else if(ROBOT_ID ==7){
// float pitch_I_component = BIG_PITCH_AIM_KI * sum_pitch; float yaw_I_component = BIG_YAW_AIM_KI * sum_yaw;
// MINMAX(yaw_I_component, -3, 3); float pitch_I_component = BIG_PITCH_AIM_KI * sum_pitch;
// MINMAX(pitch_I_component, -3, 3); MINMAX(yaw_I_component, -3, 3);
MINMAX(pitch_I_component, -3, 3);
}
double tmp_yaw = yaw_rotation; double tmp_yaw = yaw_rotation;
double tmp_pitch = pitch_rotation; double tmp_pitch = pitch_rotation;
yaw_rotation = BIG_YAW_AIM_KP * yaw_rotation + BIG_YAW_AIM_KI * sum_yaw + BIG_YAW_AIM_KD * (yaw_rotation - last_yaw); yaw_rotation = BIG_YAW_AIM_KP * yaw_rotation + BIG_YAW_AIM_KI * sum_yaw + BIG_YAW_AIM_KD * (yaw_rotation - last_yaw);
@@ -31,8 +35,10 @@ void Energy::sendEnergy() {
BIG_PITCH_AIM_KD * (pitch_rotation - last_pitch); BIG_PITCH_AIM_KD * (pitch_rotation - last_pitch);
last_yaw = tmp_yaw; last_yaw = tmp_yaw;
last_pitch = tmp_pitch; last_pitch = tmp_pitch;
// MINMAX(yaw_rotation, -6, 6); if(ROBOT_ID == 7){
// MINMAX(pitch_rotation, -6, 6); MINMAX(yaw_rotation, -6, 6);
MINMAX(pitch_rotation, -6, 6);
}
} else if (is_chassis) { } else if (is_chassis) {
// sum_yaw += yaw_rotation - mcu_data.curr_yaw; // sum_yaw += yaw_rotation - mcu_data.curr_yaw;
// sum_pitch += pitch_rotation - mcu_data.curr_pitch; // sum_pitch += pitch_rotation - mcu_data.curr_pitch;
@@ -48,8 +54,10 @@ void Energy::sendEnergy() {
double tmp_pitch = pitch_rotation; double tmp_pitch = pitch_rotation;
yaw_rotation = SMALL_YAW_AIM_KP * yaw_rotation + SMALL_YAW_AIM_KD * (yaw_rotation - last_yaw); yaw_rotation = SMALL_YAW_AIM_KP * yaw_rotation + SMALL_YAW_AIM_KD * (yaw_rotation - last_yaw);
pitch_rotation = SMALL_PITCH_AIM_KP * pitch_rotation + SMALL_PITCH_AIM_KD * (pitch_rotation - last_pitch); pitch_rotation = SMALL_PITCH_AIM_KP * pitch_rotation + SMALL_PITCH_AIM_KD * (pitch_rotation - last_pitch);
// MINMAX(yaw_rotation, -6, 6); if(ROBOT_ID == 7){
// MINMAX(pitch_rotation, -6, 6); MINMAX(yaw_rotation, -6, 6);
MINMAX(pitch_rotation, -6, 6);
}
last_yaw = tmp_yaw; last_yaw = tmp_yaw;
last_pitch = tmp_pitch; last_pitch = tmp_pitch;
} }

View File

@@ -31,6 +31,11 @@
#ifndef ENERGY_CAMERA_GAIN #ifndef ENERGY_CAMERA_GAIN
#define ENERGY_CAMERA_GAIN (20) #define ENERGY_CAMERA_GAIN (20)
#endif #endif
#ifndef ROBOT_ID
#define ROBOT_ID (0)
#endif
#ifndef SMALL_YAW_AIM_KD #ifndef SMALL_YAW_AIM_KD
#define SMALL_YAW_AIM_KD (0.35) #define SMALL_YAW_AIM_KD (0.35)
#endif #endif