From c934aa111c8404b31f10b0ca2ad9887bb406eaf7 Mon Sep 17 00:00:00 2001 From: xinyang Date: Wed, 24 Jul 2019 23:43:20 +0800 Subject: [PATCH] fix bug. --- energy/src/energy/find/energy_finder.cpp | 13 ++++++++----- energy/src/energy/find/target_finder.cpp | 5 ++++- energy/src/energy/get/aim_point_get.cpp | 1 + energy/src/energy/judge/judge_shoot.cpp | 2 +- energy/src/energy/mark/mark.cpp | 2 +- energy/src/energy/send/send.cpp | 2 +- others/src/additions/additions.cpp | 2 +- 7 files changed, 17 insertions(+), 10 deletions(-) diff --git a/energy/src/energy/find/energy_finder.cpp b/energy/src/energy/find/energy_finder.cpp index 7f1da0d..d87fb85 100644 --- a/energy/src/energy/find/energy_finder.cpp +++ b/energy/src/energy/find/energy_finder.cpp @@ -1,7 +1,10 @@ // // Created by xixiliadorabarry on 1/24/19. // +#define LOG_LEVEL LOG_NONE + #include "energy/energy.h" +#include "log.h" using namespace cv; using std::cout; @@ -151,8 +154,8 @@ bool Energy::findCenterR(const cv::Mat src) { // cout << cur_rect.center << endl; return true; } - cout << "find center R false!" << endl; -// cv::waitKey(0); + LOGM(STR_CTR(WORD_RED_CODE, "find center R false!")); + // cv::waitKey(0); return false; } @@ -198,7 +201,7 @@ bool Energy::findFlowStripFan(const cv::Mat src) { } // cout << "flow_strip_fans_cnt: " << flow_strip_fans.size() << endl; if (flow_strip_fans.empty()) { - cout << "flow strip fan false!" << endl; + LOGM(STR_CTR(WORD_RED_CODE, "flow strip fan false!")); return false; } else { return true; @@ -266,11 +269,11 @@ bool Energy::findFlowStrip(const cv::Mat src) { } // cout << "flow strip cnt: " << flow_strips.size() << endl; if (flow_strips.empty()) { - cout << "flow strip false!" << endl; + LOGM(STR_CTR(WORD_RED_CODE, "flow strip false!")); // waitKey(0); return false; } else if (flow_strips.size() > 1) { - cout << "Too many flow strips!" << endl; + LOGM(STR_CTR(WORD_RED_CODE, "Too many flow strips!")); // waitKey(0); return false; } else { diff --git a/energy/src/energy/find/target_finder.cpp b/energy/src/energy/find/target_finder.cpp index 0703bd2..980ad57 100644 --- a/energy/src/energy/find/target_finder.cpp +++ b/energy/src/energy/find/target_finder.cpp @@ -1,7 +1,10 @@ // // Created by xixiliadorabarry on 1/24/19. // +#define LOG_LEVEL LOG_NONE + #include "energy/energy.h" +#include "log.h" using namespace cv; using std::cout; @@ -67,7 +70,7 @@ bool Energy::findTargetInFlowStripFan() { } // cout << "target armor cnt: " << target_armors.size() << endl; if (target_armors.empty()) { - cout << "find target armor false" << endl; + LOGM(STR_CTR(WORD_RED_CODE, "find target armor false")); return false; } else { return true; diff --git a/energy/src/energy/get/aim_point_get.cpp b/energy/src/energy/get/aim_point_get.cpp index 9881b07..2c83150 100644 --- a/energy/src/energy/get/aim_point_get.cpp +++ b/energy/src/energy/get/aim_point_get.cpp @@ -21,5 +21,6 @@ void Energy::getAimPoint(cv::Point target_point) { pitch_rotation = atan(dy / FOCUS_PIXAL) * 180 / PI; // cout << "yaw: " << yaw_rotation << '\t' << "pitch: " << pitch_rotation << endl; // cout << "mcuData.delta_x: " << mcuData.delta_x << '\t' << "mcuData.delta_y: " << mcuData.delta_y << endl; +// cout << "manual delta: " << manual_delta_x << '\t' << manual_delta_y << endl; } diff --git a/energy/src/energy/judge/judge_shoot.cpp b/energy/src/energy/judge/judge_shoot.cpp index bece200..cbc2660 100644 --- a/energy/src/energy/judge/judge_shoot.cpp +++ b/energy/src/energy/judge/judge_shoot.cpp @@ -40,5 +40,5 @@ void Energy::judgeShootInGimbal() { } else shoot = 2; - cout << "yaw: " << yaw_rotation << '\t' << "pitch: " << pitch_rotation << endl; +// cout << "yaw: " << yaw_rotation << '\t' << "pitch: " << pitch_rotation << endl; } diff --git a/energy/src/energy/mark/mark.cpp b/energy/src/energy/mark/mark.cpp index be09f0d..2711b92 100644 --- a/energy/src/energy/mark/mark.cpp +++ b/energy/src/energy/mark/mark.cpp @@ -12,7 +12,7 @@ using namespace cv; // 此函数用于记录操作手的微调dx和dy // --------------------------------------------------------------------------------------------------------------------- void Energy::writeDownSlightChange(cv::Mat &src) { - if (findFans(src) == 4){ + if (findFans(src) >= 4) { FILE *fp_delta = fopen(PROJECT_DIR"/Mark/delta.txt", "w"); if (fp_delta) { fprintf(fp_delta, "delta_x: %d, delta_y: %d\n", mcuData.delta_x, mcuData.delta_y); diff --git a/energy/src/energy/send/send.cpp b/energy/src/energy/send/send.cpp index 10b77d3..f109ebd 100644 --- a/energy/src/energy/send/send.cpp +++ b/energy/src/energy/send/send.cpp @@ -87,7 +87,7 @@ void Energy::sendTarget(Serial &serial, float x, float y, uint16_t z, uint16_t u time_t t = time(nullptr); if (last_time != t) { last_time = t; - cout << "fps:" << fps << ", (" << x << "," << y << "," << z << ")" << endl; + cout << "energy fps:" << fps << ", (" << x << "," << y << "," << z << "," << u << ")" << endl; fps = 0; } fps += 1; diff --git a/others/src/additions/additions.cpp b/others/src/additions/additions.cpp index 85c3f38..29946b2 100644 --- a/others/src/additions/additions.cpp +++ b/others/src/additions/additions.cpp @@ -37,7 +37,7 @@ void uartReceive(Serial *pSerial) { pSerial->ReadData((uint8_t *) buffer, sizeof(mcuData)+1); if (buffer[sizeof(mcuData)] == '\n') { memcpy(&mcuData, buffer, sizeof(mcuData)); - LOGM("Get, state:%c, mark:%d!", mcuData.state, (int) mcuData.mark); +// LOGM("Get, state:%c, mark:%d!", mcuData.state, (int) mcuData.mark); // LOGM("Get yaw: %f, pitch: %f!", mcuData.curr_yaw, mcuData.curr_pitch); // LOGM("Get delta x: %d, delta y: %d!", mcuData.delta_x, mcuData.delta_y); // static int t = time(nullptr);