energy changed
This commit is contained in:
@@ -82,7 +82,8 @@ 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;//single game
|
||||||
|
gimbal_energy_part_param_.GRAY_THRESH =100;//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;
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ void Energy::runBig(cv::Mat &gimbal_src) {
|
|||||||
getPredictPoint(target_point);
|
getPredictPoint(target_point);
|
||||||
getAimPoint(predict_point);
|
getAimPoint(predict_point);
|
||||||
judgeShootInGimbal();
|
judgeShootInGimbal();
|
||||||
|
// cout << "yaw: " << yaw_rotation << '\t' << "pitch: " << pitch_rotation << '\t' << "shoot: " << shoot << endl;
|
||||||
|
// waitKey(0);
|
||||||
sendEnergy();
|
sendEnergy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ void Energy::sendEnergy() {
|
|||||||
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, -10, 10);
|
||||||
last_yaw = tmp_yaw;
|
last_yaw = tmp_yaw;
|
||||||
last_pitch = tmp_pitch;
|
last_pitch = tmp_pitch;
|
||||||
} else if (is_chassis) {
|
} else if (is_chassis) {
|
||||||
|
|||||||
144
main.cpp
144
main.cpp
@@ -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/blue_1.avi");
|
||||||
video_chassis = new VideoWrapper(PROJECT_DIR"/gimbal_video/0.avi");
|
video_chassis = new VideoWrapper("/home/sun/桌面/shiying/blue_1.avi");
|
||||||
}
|
}
|
||||||
if (video_gimbal->init()) {
|
if (video_gimbal->init()) {
|
||||||
LOGM("video_gimbal source initialization successfully.");
|
LOGM("video_gimbal source initialization successfully.");
|
||||||
@@ -94,90 +94,90 @@ int main(int argc, char *argv[]) {
|
|||||||
cout << "start running" << endl;
|
cout << "start running" << endl;
|
||||||
do {
|
do {
|
||||||
CNT_TIME("Total", {
|
CNT_TIME("Total", {
|
||||||
if (mcu_data.state == BIG_ENERGY_STATE) {//大能量机关模式
|
if (mcu_data.state == BIG_ENERGY_STATE) {//大能量机关模式
|
||||||
if (last_state != BIG_ENERGY_STATE) {//若上一帧不是大能量机关模式,即刚往完成切换,则需要初始化
|
if (last_state != BIG_ENERGY_STATE) {//若上一帧不是大能量机关模式,即刚往完成切换,则需要初始化
|
||||||
LOGM(STR_CTR(WORD_BLUE, "Start Big Energy!"));
|
LOGM(STR_CTR(WORD_BLUE, "Start Big Energy!"));
|
||||||
destroyAllWindows();
|
destroyAllWindows();
|
||||||
if (from_camera) {
|
if (from_camera) {
|
||||||
delete video_gimbal;
|
delete video_gimbal;
|
||||||
video_gimbal = new CameraWrapper(ENERGY_CAMERA_GAIN, 2/*, "armor"*/);
|
video_gimbal = new CameraWrapper(ENERGY_CAMERA_GAIN, 2/*, "armor"*/);
|
||||||
if (video_gimbal->init()) {
|
if (video_gimbal->init()) {
|
||||||
LOGM("video_gimbal source initialization successfully.");
|
LOGM("video_gimbal source initialization successfully.");
|
||||||
} else {
|
} else {
|
||||||
LOGW("video_gimbal source unavailable!");
|
LOGW("video_gimbal source unavailable!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
checkReconnect(video_chassis->read(chassis_src));
|
||||||
|
energy.setBigEnergyInit();
|
||||||
}
|
}
|
||||||
checkReconnect(video_chassis->read(chassis_src));
|
last_state = mcu_data.state;//更新上一帧状态
|
||||||
energy.setBigEnergyInit();
|
ok = checkReconnect(video_gimbal->read(gimbal_src));
|
||||||
}
|
video_chassis->read(chassis_src);
|
||||||
last_state = mcu_data.state;//更新上一帧状态
|
|
||||||
ok = checkReconnect(video_gimbal->read(gimbal_src));
|
|
||||||
video_chassis->read(chassis_src);
|
|
||||||
#ifdef GIMBAL_FLIP_MODE
|
#ifdef GIMBAL_FLIP_MODE
|
||||||
flip(gimbal_src, gimbal_src, GIMBAL_FLIP_MODE);
|
flip(gimbal_src, gimbal_src, GIMBAL_FLIP_MODE);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CHASSIS_FLIP_MODE
|
#ifdef CHASSIS_FLIP_MODE
|
||||||
flip(chassis_src, chassis_src, CHASSIS_FLIP_MODE);
|
flip(chassis_src, chassis_src, CHASSIS_FLIP_MODE);
|
||||||
#endif
|
#endif
|
||||||
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!"));
|
||||||
destroyAllWindows();
|
destroyAllWindows();
|
||||||
if (from_camera) {
|
if (from_camera) {
|
||||||
delete video_gimbal;
|
delete video_gimbal;
|
||||||
video_gimbal = new CameraWrapper(ENERGY_CAMERA_GAIN, 2/*, "armor"*/);
|
video_gimbal = new CameraWrapper(ENERGY_CAMERA_GAIN, 2/*, "armor"*/);
|
||||||
if (video_gimbal->init()) {
|
if (video_gimbal->init()) {
|
||||||
LOGM("video_gimbal source initialization successfully.");
|
LOGM("video_gimbal source initialization successfully.");
|
||||||
} else {
|
} else {
|
||||||
LOGW("video_gimbal source unavailable!");
|
LOGW("video_gimbal source unavailable!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
energy.setSmallEnergyInit();
|
||||||
|
}
|
||||||
|
last_state = mcu_data.state;//更新上一帧状态
|
||||||
|
ok = checkReconnect(video_gimbal->read(gimbal_src));
|
||||||
|
#ifdef GIMBAL_FLIP_MODE
|
||||||
|
flip(gimbal_src, gimbal_src, GIMBAL_FLIP_MODE);
|
||||||
|
#endif
|
||||||
|
if (!from_camera) extract(gimbal_src);
|
||||||
|
if (save_video) saveVideos(gimbal_src);//保存视频
|
||||||
|
if (show_origin) showOrigin(gimbal_src);//显示原始图像
|
||||||
|
energy.runSmall(gimbal_src);
|
||||||
|
} else { // 自瞄模式
|
||||||
|
if (last_state != ARMOR_STATE) {
|
||||||
|
LOGM(STR_CTR(WORD_RED, "Start Armor!"));
|
||||||
|
destroyAllWindows();
|
||||||
|
if (from_camera) {
|
||||||
|
delete video_gimbal;
|
||||||
|
video_gimbal = new CameraWrapper(ARMOR_CAMERA_GAIN, 2/*, "armor"*/);
|
||||||
|
if (video_gimbal->init()) {
|
||||||
|
LOGM("video_gimbal source initialization successfully.");
|
||||||
|
} else {
|
||||||
|
LOGW("video_gimbal source unavailable!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
energy.setSmallEnergyInit();
|
last_state = mcu_data.state;
|
||||||
}
|
CNT_TIME(STR_CTR(WORD_GREEN, "read img"), {
|
||||||
last_state = mcu_data.state;//更新上一帧状态
|
if (!checkReconnect(video_gimbal->read(gimbal_src))) continue;
|
||||||
ok = checkReconnect(video_gimbal->read(gimbal_src));
|
});
|
||||||
#ifdef GIMBAL_FLIP_MODE
|
#ifdef GIMBAL_FLIP_MODE
|
||||||
flip(gimbal_src, gimbal_src, GIMBAL_FLIP_MODE);
|
flip(gimbal_src, gimbal_src, GIMBAL_FLIP_MODE);
|
||||||
#endif
|
|
||||||
if (!from_camera) extract(gimbal_src);
|
|
||||||
if (save_video) saveVideos(gimbal_src);//保存视频
|
|
||||||
if (show_origin) showOrigin(gimbal_src);//显示原始图像
|
|
||||||
energy.runSmall(gimbal_src);
|
|
||||||
} else { // 自瞄模式
|
|
||||||
if (last_state != ARMOR_STATE) {
|
|
||||||
LOGM(STR_CTR(WORD_RED, "Start Armor!"));
|
|
||||||
destroyAllWindows();
|
|
||||||
if (from_camera) {
|
|
||||||
delete video_gimbal;
|
|
||||||
video_gimbal = new CameraWrapper(ARMOR_CAMERA_GAIN, 2/*, "armor"*/);
|
|
||||||
if (video_gimbal->init()) {
|
|
||||||
LOGM("video_gimbal source initialization successfully.");
|
|
||||||
} else {
|
|
||||||
LOGW("video_gimbal source unavailable!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
last_state = mcu_data.state;
|
|
||||||
CNT_TIME(STR_CTR(WORD_GREEN, "read img"), {
|
|
||||||
if(!checkReconnect(video_gimbal->read(gimbal_src))) continue;
|
|
||||||
});
|
|
||||||
#ifdef GIMBAL_FLIP_MODE
|
|
||||||
flip(gimbal_src, gimbal_src, GIMBAL_FLIP_MODE);
|
|
||||||
#endif
|
#endif
|
||||||
// CNT_TIME("something whatever", {
|
// CNT_TIME("something whatever", {
|
||||||
if (!from_camera) extract(gimbal_src);
|
if (!from_camera) extract(gimbal_src);
|
||||||
if (save_video) saveVideos(gimbal_src);
|
if (save_video) saveVideos(gimbal_src);
|
||||||
if (show_origin) showOrigin(gimbal_src);
|
if (show_origin) showOrigin(gimbal_src);
|
||||||
// });
|
// });
|
||||||
CNT_TIME(STR_CTR(WORD_CYAN, "Armor Time"), {
|
CNT_TIME(STR_CTR(WORD_CYAN, "Armor Time"), {
|
||||||
armor_finder.run(gimbal_src);
|
armor_finder.run(gimbal_src);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// cv::waitKey(0);
|
// cv::waitKey(0);
|
||||||
});
|
});
|
||||||
} while (ok);
|
} while (ok);
|
||||||
|
|||||||
Reference in New Issue
Block a user