From 4a7e330e5aec00f605959447bce7b768923df1a2 Mon Sep 17 00:00:00 2001 From: Shahrul Kamil bin Hassan <shahrulkamil98@g.ucla.edu> Date: Thu, 7 Oct 2021 22:48:21 +0000 Subject: [PATCH] Replace Camera.cpp --- Code/Kamil's Feather Code/Camera.cpp | 37 +++++++++------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/Code/Kamil's Feather Code/Camera.cpp b/Code/Kamil's Feather Code/Camera.cpp index 539896f..fb27cf8 100644 --- a/Code/Kamil's Feather Code/Camera.cpp +++ b/Code/Kamil's Feather Code/Camera.cpp @@ -69,36 +69,23 @@ bool Camera::exe_color_detection_biggestblob(int8_t l_min, int8_t l_max, int8_t } } -void Camera::exe_led_detection(){ - //int8_t color_thresholds[6] = {l_min, l_max, a_min, a_max, b_min, b_max}; - int8_t color_thresholds[6] = {26, 100, -108, -9, 0, -42}; - //struct { uint16_t cx, cy; } color_detection_result; - short buff[128 + 1] = {}; - if (interface->call(F("LED_detection"), color_thresholds, sizeof(color_thresholds), buff, sizeof(buff)-1)) { - int i = 0; - Serial.println("LED detected"); - while (buff[i] != '\0' && i<100) { - Serial.print(buff[i]); - i++; - } - Serial.println(""); - } -} -bool Camera::exe_goalfinder(int goal1, int goal2, int goal3, int&id, int&tx, int&ty, int&tz, int&rx, int&ry, int&rz){ - int goalid[3] = {goal1, goal2, goal3}; +bool Camera::exe_goalfinder(int8_t goal1, int8_t goal2, int8_t goal3, int&id, int&tx, int&ty, int&tz, int&rx, int&ry, int&rz){ + int8_t goalid[3] = {goal1, goal2, goal3}; struct { uint16_t cid, ctx, cty, ctz, crx, cry, crz; } goalfinder_result; - interface->call(F("goalfinder"), goalid, sizeof(goalid), goalfinder_result, sizeof(goalfinder_result)); + if(interface->call(F("goalfinder"), goalid, sizeof(goalid), &goalfinder_result, sizeof(goalfinder_result))){ + + } if (goalfinder_result.crx == 0 && goalfinder_result.cry == 0){ return false; } else { - goalfinder.cid = id; - goalfinder.ctx = tx; - goalfinder.cty = ty; - goalfinder.ctz = tz; - goalfinder.crx = rx; - goalfinder.cry = ry; - goalfinder.crz = rz; + id = goalfinder_result.cid; + tx = goalfinder_result.ctx; + ty = goalfinder_result.cty; + tz = goalfinder_result.ctz; + rx = goalfinder_result.crx; + ry = goalfinder_result.cry; + rz = goalfinder_result.crz; return true; } } -- GitLab