From c3ebf4913f3e3f9333a6f707113ac44afcd0e5c4 Mon Sep 17 00:00:00 2001 From: u-siri-ous Date: Mon, 3 Feb 2020 18:59:44 +0100 Subject: [PATCH 1/2] storcimento kinda working --- src/goalie.cpp | 4 ++-- src/main.cpp | 2 -- utility/OpenMV/conic_eff.py | 4 ++-- utility/OpenMV/main_test_conic.py | 18 +++++++++--------- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/goalie.cpp b/src/goalie.cpp index 912087a..1787c64 100755 --- a/src/goalie.cpp +++ b/src/goalie.cpp @@ -45,8 +45,8 @@ void Goalie::goalie(int plusang) { } void Goalie::storcimentoPorta() { - if (camera->getValueAtk(false) >= 10 && camera->getValueAtk(false) <= 90) cstorc+=9; - else if (camera->getValueAtk(false) <= 350 && camera->getValueAtk(false) >= 270) cstorc-=9; + if (camera->getValueAtk(true ) >= 10 && camera->getValueAtk(true) <= 90) cstorc+=9; + else if (camera->getValueAtk(true) <= 350 && camera->getValueAtk(true) >= 270) cstorc-=9; // else cstorc *= 0.7; cstorc = constrain(cstorc, -45, 45); } \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index a9f117f..4acf77c 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,8 +16,6 @@ void setup() { void loop() { updateSensors(); - camera->test(); - // compass->test(); goalie->play(role==1); keeper->play(role==0); diff --git a/utility/OpenMV/conic_eff.py b/utility/OpenMV/conic_eff.py index 1f9f231..2c496cb 100644 --- a/utility/OpenMV/conic_eff.py +++ b/utility/OpenMV/conic_eff.py @@ -39,8 +39,8 @@ blue_led.on() -thresholds = [ (49, 99, -24, 17, 23, 64), # thresholds yellow goal - (-128,-128,-128,-128,-128,-128)] # thresholds blue goal (6, 31, -15, 4, -35, 0) +thresholds = [ (30, 70, -12, 19, 10, 57), # thresholds yellow goal + (0, 31, -2, 39, -68, -25)] # thresholds blue goal (6, 31, -15, 4, -35, 0) roi = (0, 6, 318, 152) diff --git a/utility/OpenMV/main_test_conic.py b/utility/OpenMV/main_test_conic.py index 31bce7c..f3009fe 100644 --- a/utility/OpenMV/main_test_conic.py +++ b/utility/OpenMV/main_test_conic.py @@ -29,8 +29,8 @@ blue_led.on() #thresholds = [ (54, 93, -10, 25, 55, 70), # thresholds yellow goal # (30, 45, 1, 40, -60, -19)] # thresholds blue goal # -thresholds = [ (55, 98, -14, 12, 7, 55), # thresholds yellow goal - (20, 51, -23, 26, -69, -31)] # thresholds blue goal (6, 31, -15, 4, -35, 0) +thresholds = [ (30, 70, -12, 19, 41, 68) , # thresholds yellow goal + (0, 70, -2, 34, -59, -21)] # thresholds blue goal (6, 31, -15, 4, -35, 0) roi = (0, 6, 318, 152) @@ -50,11 +50,11 @@ clock = time.clock()''' sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) -sensor.set_contrast(+0) -sensor.set_saturation(+0) -sensor.set_brightness(0) +sensor.set_contrast(+2) +sensor.set_saturation(+1) +sensor.set_brightness(-2) sensor.set_quality(0) -sensor.set_auto_exposure(False, 8000) +sensor.set_auto_exposure(False, 6000) sensor.set_auto_gain(True) sensor.skip_frames(time = 300) @@ -79,7 +79,7 @@ while(True): tt_blue = [(0,999,0,2)] ## creo una lista di tuple per il blue, valore x = 999 : non trovata img = sensor.snapshot() - for blob in img.find_blobs(thresholds, pixels_threshold=75, area_threshold=100, merge = True): + for blob in img.find_blobs(thresholds, pixels_threshold=150, area_threshold=150, merge = True): img.draw_rectangle(blob.rect()) img.draw_cross(blob.cx(), blob.cy()) @@ -100,7 +100,7 @@ while(True): cy = img.height() / 2 - cy angle = math.pi/2 - math.atan2(cy, cx) dist = math.sqrt(cx*cx + cy*cy) - string_yellow = "Y"+str(cx)+" | "+str(cy)+" | "+str(angle)+" | "+str(dist)+"y" + string_yellow = "Y"+str(cx)+" | "+str(cy)+" | "+str(angle)+" | "+str(dist)+str(area)+"y" print (string_yellow) # test on serial terminal '''Blue''' @@ -109,7 +109,7 @@ while(True): cy = img.height() / 2 - cy angle = math.pi/2 - math.atan2(cy, cx) dist = math.sqrt(cx*cx + cy*cy) - string_blue = "B"+str(cx)+" | "+str(cy)+" | |"+str(angle)+" | "+str(dist)+"b" + string_blue = "B"+str(cx)+" | "+str(cy)+" | |"+str(angle)+" | "+str(dist)+str(area)+"b" print (string_blue) # test on serial terminal #print ("..................................") From 3c09f031f1833bf48d5dc14c166307217dee7fcf Mon Sep 17 00:00:00 2001 From: u-siri-ous Date: Wed, 5 Feb 2020 18:57:11 +0100 Subject: [PATCH 2/2] status vector c: --- include/status_vector.h | 19 +++++++++++++++++++ src/status_vector.cpp | 7 +++++++ 2 files changed, 26 insertions(+) create mode 100644 include/status_vector.h create mode 100644 src/status_vector.cpp diff --git a/include/status_vector.h b/include/status_vector.h new file mode 100644 index 0000000..9b142c2 --- /dev/null +++ b/include/status_vector.h @@ -0,0 +1,19 @@ +#pragma once +#define dim 20 +#include + +typedef struct input{ + int IMUAngle, USfr, USsx, USdx, USrr, BT; + byte ballByte, cameraByte, lineByte; + bool SW_DX, SW_SX; +}input; + +typedef struct data{ + int IMUAngle, ballAngle, ballDistance, cameraAngle, cameraDistance, + speed, tilt, dir, USfr, USsx, USdx, USrr, lineOutDir, matePos, role; + byte xb, yb, xy, yy, lineSeen, lineActive; + bool mate, ATKgoal, DEFgoal; +}data; + +input inputs[dim]; +data datas[dim]; \ No newline at end of file diff --git a/src/status_vector.cpp b/src/status_vector.cpp new file mode 100644 index 0000000..b430b02 --- /dev/null +++ b/src/status_vector.cpp @@ -0,0 +1,7 @@ +#include +void initStructs(){ + for(int i=0; i>=dim; i++){ + inputs[i] = input(); + datas[i] = data(); + } +} \ No newline at end of file