Merge remote-tracking branch 'origin/master'

This commit is contained in:
xinyang
2019-08-05 19:38:46 +08:00
4 changed files with 100 additions and 98 deletions

View File

@@ -82,7 +82,7 @@ void Energy::initEnergy() {
void Energy::initEnergyPartParam() { void Energy::initEnergyPartParam() {
// gimbal_energy_part_param_.GRAY_THRESH = 120;//home // gimbal_energy_part_param_.GRAY_THRESH = 120;//home
// gimbal_energy_part_param_.GRAY_THRESH = 200;//official // gimbal_energy_part_param_.GRAY_THRESH = 200;//official
gimbal_energy_part_param_.GRAY_THRESH = 180;//game gimbal_energy_part_param_.GRAY_THRESH =180;//game
gimbal_energy_part_param_.SPLIT_GRAY_THRESH = 180; gimbal_energy_part_param_.SPLIT_GRAY_THRESH = 180;
gimbal_energy_part_param_.FAN_GRAY_THRESH = 75; gimbal_energy_part_param_.FAN_GRAY_THRESH = 75;
gimbal_energy_part_param_.ARMOR_GRAY_THRESH = 80; gimbal_energy_part_param_.ARMOR_GRAY_THRESH = 80;

View File

@@ -18,34 +18,36 @@ 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;
MINMAX(sum_yaw, -100, 100); float yaw_I_component = BIG_YAW_AIM_KI * sum_yaw;
MINMAX(sum_pitch, -100, 100); float pitch_I_component = BIG_PITCH_AIM_KI * sum_pitch;
MINMAX(yaw_I_component, -2, 2);
MINMAX(pitch_I_component, -2, 2);
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);
pitch_rotation = BIG_PITCH_AIM_KP * pitch_rotation + BIG_PITCH_AIM_KI * sum_pitch + pitch_rotation = BIG_PITCH_AIM_KP * pitch_rotation + BIG_PITCH_AIM_KI * sum_pitch +
BIG_PITCH_AIM_KD * (pitch_rotation - last_pitch); BIG_PITCH_AIM_KD * (pitch_rotation - last_pitch);
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;
} 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;
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 - mcu_data.curr_yaw) + BIG_YAW_AIM_KI * sum_yaw; // yaw_rotation = BIG_YAW_AIM_KP * (yaw_rotation - mcu_data.curr_yaw) + BIG_YAW_AIM_KI * sum_yaw;
pitch_rotation = BIG_PITCH_AIM_KP * (pitch_rotation - mcu_data.curr_pitch) + BIG_PITCH_AIM_KI * sum_pitch; // pitch_rotation = BIG_PITCH_AIM_KP * (pitch_rotation - mcu_data.curr_pitch) + BIG_PITCH_AIM_KI * sum_pitch;
last_yaw = tmp_yaw; // last_yaw = tmp_yaw;
last_pitch = tmp_pitch; // last_pitch = tmp_pitch;
} }
} else if (is_small){ } else if (is_small){
sum_yaw += yaw_rotation;
sum_pitch += pitch_rotation;
MINMAX(sum_yaw, -100, 100);
MINMAX(sum_pitch, -100, 100);
double tmp_yaw = yaw_rotation; double tmp_yaw = yaw_rotation;
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);
MINMAX(pitch_rotation, -6, 6);
last_yaw = tmp_yaw; last_yaw = tmp_yaw;
last_pitch = tmp_pitch; last_pitch = tmp_pitch;
} }

View File

@@ -30,7 +30,7 @@ using namespace std;
McuData mcu_data = { // 单片机端回传结构体 McuData mcu_data = { // 单片机端回传结构体
0, // 当前云台yaw角 0, // 当前云台yaw角
0, // 当前云台pitch角 0, // 当前云台pitch角
ARMOR_STATE, // 当前状态,自瞄-大符-小符 BIG_ENERGY_STATE, // 当前状态,自瞄-大符-小符
0, // 云台角度标记位 0, // 云台角度标记位
1, // 是否启用数字识别 1, // 是否启用数字识别
ENEMY_RED, // 敌方颜色 ENEMY_RED, // 敌方颜色
@@ -66,8 +66,8 @@ int main(int argc, char *argv[]) {
video_gimbal = new CameraWrapper(ARMOR_CAMERA_GAIN, 2/*, "armor"*/); video_gimbal = new CameraWrapper(ARMOR_CAMERA_GAIN, 2/*, "armor"*/);
video_chassis = new CameraWrapper(ENERGY_CAMERA_GAIN, 2/*, "energy"*/); video_chassis = new CameraWrapper(ENERGY_CAMERA_GAIN, 2/*, "energy"*/);
} else { } else {
video_gimbal = new VideoWrapper(PROJECT_DIR"/gimbal_video/0.avi"); video_gimbal = new VideoWrapper("/home/sun/桌面/shiying/18.avi");
video_chassis = new VideoWrapper(PROJECT_DIR"/gimbal_video/0.avi"); video_chassis = new VideoWrapper("/home/sun/桌面/shiying/18.avi");
} }
if (video_gimbal->init()) { if (video_gimbal->init()) {
LOGM("video_gimbal source initialization successfully."); LOGM("video_gimbal source initialization successfully.");
@@ -122,8 +122,8 @@ int main(int argc, char *argv[]) {
if (!from_camera) extract(gimbal_src, chassis_src); if (!from_camera) extract(gimbal_src, chassis_src);
if (save_video) saveVideos(gimbal_src, chassis_src);//保存视频 if (save_video) saveVideos(gimbal_src, chassis_src);//保存视频
if (show_origin) showOrigin(gimbal_src, chassis_src);//显示原始图像 if (show_origin) showOrigin(gimbal_src, chassis_src);//显示原始图像
energy.runBig(gimbal_src, chassis_src); // energy.runBig(gimbal_src, chassis_src);
// energy.runBig(gimbal_src); energy.runBig(gimbal_src);
} else if (mcu_data.state == SMALL_ENERGY_STATE) { } else if (mcu_data.state == SMALL_ENERGY_STATE) {
if (last_state != SMALL_ENERGY_STATE) { if (last_state != SMALL_ENERGY_STATE) {
LOGM(STR_CTR(WORD_GREEN, "Start Small Energy!")); LOGM(STR_CTR(WORD_GREEN, "Start Small Energy!"));
@@ -164,7 +164,7 @@ int main(int argc, char *argv[]) {
} }
last_state = mcu_data.state; last_state = mcu_data.state;
CNT_TIME(STR_CTR(WORD_GREEN, "read img"), { CNT_TIME(STR_CTR(WORD_GREEN, "read img"), {
if(!checkReconnect(video_gimbal->read(gimbal_src))) continue; if (!checkReconnect(video_gimbal->read(gimbal_src))) continue;
}); });
#ifdef GIMBAL_FLIP_MODE #ifdef GIMBAL_FLIP_MODE
flip(gimbal_src, gimbal_src, GIMBAL_FLIP_MODE); flip(gimbal_src, gimbal_src, GIMBAL_FLIP_MODE);

View File

@@ -32,34 +32,34 @@
#define ENERGY_CAMERA_GAIN (20) #define ENERGY_CAMERA_GAIN (20)
#endif #endif
#ifndef SMALL_YAW_AIM_KD #ifndef SMALL_YAW_AIM_KD
#define SMALL_YAW_AIM_KD (0) #define SMALL_YAW_AIM_KD (0.35)
#endif #endif
#ifndef SMALL_YAW_AIM_KP #ifndef SMALL_YAW_AIM_KP
#define SMALL_YAW_AIM_KP (4) #define SMALL_YAW_AIM_KP (0.85)
#endif #endif
#ifndef SMALL_PITCH_AIM_KD #ifndef SMALL_PITCH_AIM_KD
#define SMALL_PITCH_AIM_KD (0) #define SMALL_PITCH_AIM_KD (0.35)
#endif #endif
#ifndef SMALL_PITCH_AIM_KP #ifndef SMALL_PITCH_AIM_KP
#define SMALL_PITCH_AIM_KP (3.7) #define SMALL_PITCH_AIM_KP (0.85)
#endif #endif
#ifndef BIG_YAW_AIM_KD #ifndef BIG_YAW_AIM_KD
#define BIG_YAW_AIM_KD (0) #define BIG_YAW_AIM_KD (0.35)
#endif #endif
#ifndef BIG_YAW_AIM_KP #ifndef BIG_YAW_AIM_KP
#define BIG_YAW_AIM_KP (6.5) #define BIG_YAW_AIM_KP (0.85)
#endif #endif
#ifndef BIG_YAW_AIM_KI #ifndef BIG_YAW_AIM_KI
#define BIG_YAW_AIM_KI (0.1) #define BIG_YAW_AIM_KI (0)
#endif #endif
#ifndef BIG_PITCH_AIM_KD #ifndef BIG_PITCH_AIM_KD
#define BIG_PITCH_AIM_KD (0) #define BIG_PITCH_AIM_KD (0.35)
#endif #endif
#ifndef BIG_PITCH_AIM_KP #ifndef BIG_PITCH_AIM_KP
#define BIG_PITCH_AIM_KP (6.5) #define BIG_PITCH_AIM_KP (0.85)
#endif #endif
#ifndef BIG_PITCH_AIM_KI #ifndef BIG_PITCH_AIM_KI
#define BIG_PITCH_AIM_KI (0.1) #define BIG_PITCH_AIM_KI (0)
#endif #endif
#ifndef COMPENSATE_YAW #ifndef COMPENSATE_YAW
#define COMPENSATE_YAW (5) #define COMPENSATE_YAW (5)
@@ -68,7 +68,7 @@
#define COMPENSATE_PITCH (74) #define COMPENSATE_PITCH (74)
#endif #endif
#ifndef EXTRA_DELTA_X #ifndef EXTRA_DELTA_X
#define EXTRA_DELTA_X (10) #define EXTRA_DELTA_X (0)
#endif #endif
#ifndef EXTRA_DELTA_Y #ifndef EXTRA_DELTA_Y
#define EXTRA_DELTA_Y (10) #define EXTRA_DELTA_Y (10)