This commit is contained in:
xinyang
2019-07-24 23:43:20 +08:00
parent c794bd1b9d
commit c934aa111c
7 changed files with 17 additions and 10 deletions

View File

@@ -1,7 +1,10 @@
// //
// Created by xixiliadorabarry on 1/24/19. // Created by xixiliadorabarry on 1/24/19.
// //
#define LOG_LEVEL LOG_NONE
#include "energy/energy.h" #include "energy/energy.h"
#include "log.h"
using namespace cv; using namespace cv;
using std::cout; using std::cout;
@@ -151,7 +154,7 @@ bool Energy::findCenterR(const cv::Mat src) {
// cout << cur_rect.center << endl; // cout << cur_rect.center << endl;
return true; return true;
} }
cout << "find center R false!" << endl; LOGM(STR_CTR(WORD_RED_CODE, "find center R false!"));
// cv::waitKey(0); // cv::waitKey(0);
return false; return false;
@@ -198,7 +201,7 @@ bool Energy::findFlowStripFan(const cv::Mat src) {
} }
// cout << "flow_strip_fans_cnt: " << flow_strip_fans.size() << endl; // cout << "flow_strip_fans_cnt: " << flow_strip_fans.size() << endl;
if (flow_strip_fans.empty()) { if (flow_strip_fans.empty()) {
cout << "flow strip fan false!" << endl; LOGM(STR_CTR(WORD_RED_CODE, "flow strip fan false!"));
return false; return false;
} else { } else {
return true; return true;
@@ -266,11 +269,11 @@ bool Energy::findFlowStrip(const cv::Mat src) {
} }
// cout << "flow strip cnt: " << flow_strips.size() << endl; // cout << "flow strip cnt: " << flow_strips.size() << endl;
if (flow_strips.empty()) { if (flow_strips.empty()) {
cout << "flow strip false!" << endl; LOGM(STR_CTR(WORD_RED_CODE, "flow strip false!"));
// waitKey(0); // waitKey(0);
return false; return false;
} else if (flow_strips.size() > 1) { } else if (flow_strips.size() > 1) {
cout << "Too many flow strips!" << endl; LOGM(STR_CTR(WORD_RED_CODE, "Too many flow strips!"));
// waitKey(0); // waitKey(0);
return false; return false;
} else { } else {

View File

@@ -1,7 +1,10 @@
// //
// Created by xixiliadorabarry on 1/24/19. // Created by xixiliadorabarry on 1/24/19.
// //
#define LOG_LEVEL LOG_NONE
#include "energy/energy.h" #include "energy/energy.h"
#include "log.h"
using namespace cv; using namespace cv;
using std::cout; using std::cout;
@@ -67,7 +70,7 @@ bool Energy::findTargetInFlowStripFan() {
} }
// cout << "target armor cnt: " << target_armors.size() << endl; // cout << "target armor cnt: " << target_armors.size() << endl;
if (target_armors.empty()) { if (target_armors.empty()) {
cout << "find target armor false" << endl; LOGM(STR_CTR(WORD_RED_CODE, "find target armor false"));
return false; return false;
} else { } else {
return true; return true;

View File

@@ -21,5 +21,6 @@ void Energy::getAimPoint(cv::Point target_point) {
pitch_rotation = atan(dy / FOCUS_PIXAL) * 180 / PI; pitch_rotation = atan(dy / FOCUS_PIXAL) * 180 / PI;
// cout << "yaw: " << yaw_rotation << '\t' << "pitch: " << pitch_rotation << endl; // 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 << "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;
} }

View File

@@ -40,5 +40,5 @@ void Energy::judgeShootInGimbal() {
} else } else
shoot = 2; shoot = 2;
cout << "yaw: " << yaw_rotation << '\t' << "pitch: " << pitch_rotation << endl; // cout << "yaw: " << yaw_rotation << '\t' << "pitch: " << pitch_rotation << endl;
} }

View File

@@ -12,7 +12,7 @@ using namespace cv;
// 此函数用于记录操作手的微调dx和dy // 此函数用于记录操作手的微调dx和dy
// --------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
void Energy::writeDownSlightChange(cv::Mat &src) { void Energy::writeDownSlightChange(cv::Mat &src) {
if (findFans(src) == 4){ if (findFans(src) >= 4) {
FILE *fp_delta = fopen(PROJECT_DIR"/Mark/delta.txt", "w"); FILE *fp_delta = fopen(PROJECT_DIR"/Mark/delta.txt", "w");
if (fp_delta) { if (fp_delta) {
fprintf(fp_delta, "delta_x: %d, delta_y: %d\n", mcuData.delta_x, mcuData.delta_y); fprintf(fp_delta, "delta_x: %d, delta_y: %d\n", mcuData.delta_x, mcuData.delta_y);

View File

@@ -87,7 +87,7 @@ void Energy::sendTarget(Serial &serial, float x, float y, uint16_t z, uint16_t u
time_t t = time(nullptr); time_t t = time(nullptr);
if (last_time != t) { if (last_time != t) {
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 = 0;
} }
fps += 1; fps += 1;

View File

@@ -37,7 +37,7 @@ void uartReceive(Serial *pSerial) {
pSerial->ReadData((uint8_t *) buffer, sizeof(mcuData)+1); pSerial->ReadData((uint8_t *) buffer, sizeof(mcuData)+1);
if (buffer[sizeof(mcuData)] == '\n') { if (buffer[sizeof(mcuData)] == '\n') {
memcpy(&mcuData, buffer, sizeof(mcuData)); 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 yaw: %f, pitch: %f!", mcuData.curr_yaw, mcuData.curr_pitch);
// LOGM("Get delta x: %d, delta y: %d!", mcuData.delta_x, mcuData.delta_y); // LOGM("Get delta x: %d, delta y: %d!", mcuData.delta_x, mcuData.delta_y);
// static int t = time(nullptr); // static int t = time(nullptr);