From 019831e237e7adac6c5419f4c13d59e1f5dcc5e5 Mon Sep 17 00:00:00 2001 From: EmaMaker Date: Mon, 1 Mar 2021 15:59:20 +0100 Subject: [PATCH] remove old unused line systems --- include/sensors/sensors.h | 2 - include/systems/lines/linesys_2019.h | 32 ---- include/systems/lines/linesys_camera_new.h | 40 ----- src/strategy_roles/keeper.cpp | 1 - src/system/lines/linesys_2019.cpp | 188 --------------------- src/system/lines/linesys_camera_new.cpp | 116 ------------- src/test_menu.cpp | 5 +- 7 files changed, 2 insertions(+), 382 deletions(-) delete mode 100644 include/systems/lines/linesys_2019.h delete mode 100644 include/systems/lines/linesys_camera_new.h delete mode 100644 src/system/lines/linesys_2019.cpp delete mode 100644 src/system/lines/linesys_camera_new.cpp diff --git a/include/sensors/sensors.h b/include/sensors/sensors.h index ef73bd4..95b323d 100644 --- a/include/sensors/sensors.h +++ b/include/sensors/sensors.h @@ -12,7 +12,6 @@ #include "behaviour_control/ds_ctrl.h" #include "motors_movement/drivecontroller.h" #include "motors_movement/motor.h" -#include "systems/lines/linesys_2019.h" #include "systems/lines/linesys_camera.h" #include "systems/position/positionsys_zone.h" #include "systems/systems.h" @@ -29,7 +28,6 @@ void updateSensors(); s_extr vector dUs; s_extr DataSourceCtrl* usCtrl; -s_extr LineSys2019* linesCtrl; s_extr DataSourceBNO055* compass; s_extr DataSourceBall* ball; diff --git a/include/systems/lines/linesys_2019.h b/include/systems/lines/linesys_2019.h deleted file mode 100644 index 58ce5dd..0000000 --- a/include/systems/lines/linesys_2019.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include - -#include "behaviour_control/ds_ctrl.h" -#include "systems/systems.h" - -#include "vars.h" - -#define LINE_THRESH 90 -#define EXTIME 200 -#define LINES_EXIT_SPD 350 - -class LineSys2019 : public LineSystem{ - - public: - LineSys2019(); - LineSys2019(vector in_, vector out); - - void update() override; - void test() override; - void outOfBounds(); - - private: - vector in, out; - DataSource* ds; - bool fboundsX, fboundsY, fboundsOX, fboundsOY, slow; - int inV, outV, linesensOldX, linesensOldY, value, linetriggerI[4], linetriggerO[4], i; - elapsedMillis exitTimer; - int outDir, outVel; - byte linesens; -}; \ No newline at end of file diff --git a/include/systems/lines/linesys_camera_new.h b/include/systems/lines/linesys_camera_new.h deleted file mode 100644 index 8de96bd..0000000 --- a/include/systems/lines/linesys_camera_new.h +++ /dev/null @@ -1,40 +0,0 @@ -// #pragma once - -// #include - -// #include "behaviour_control/ds_ctrl.h" -// #include "position/systems.h" - -// #include "vars.h" - -// #define S1I A14 -// #define S1O A15 -// #define S2I A16 -// #define S2O A17 -// #define S3I A20 -// #define S3O A0 -// #define S4I A1 -// #define S4O A2 - -// #define LINE_THRESH_CAM 90 -// #define EXTIME_CAM 75 -// #define LINES_EXIT_SPD_CAM 300 - -// class LineSysCamera : public LineSystem{ - -// public: -// LineSysCamera(); -// LineSysCamera(vector in_, vector out); - -// void update() override; -// void test() override; -// void outOfBounds(); - -// private: -// vector in, out; -// DataSource* ds; -// bool fboundsX, fboundsY, fboundsOX, fboundsOY, slow; -// int inV, outV, linesensOldX, linesensOldY, value, linetriggerI[4], linetriggerO[4], i; -// unsigned long exitTimer; -// byte linesens; -// }; \ No newline at end of file diff --git a/src/strategy_roles/keeper.cpp b/src/strategy_roles/keeper.cpp index d96e173..550af15 100644 --- a/src/strategy_roles/keeper.cpp +++ b/src/strategy_roles/keeper.cpp @@ -1,7 +1,6 @@ #include #include "behaviour_control/status_vector.h" -#include "systems/lines/linesys_2019.h" #include "sensors/sensors.h" #include "strategy_roles/keeper.h" #include "strategy_roles/games.h" diff --git a/src/system/lines/linesys_2019.cpp b/src/system/lines/linesys_2019.cpp deleted file mode 100644 index 8ad3276..0000000 --- a/src/system/lines/linesys_2019.cpp +++ /dev/null @@ -1,188 +0,0 @@ -#include "systems/lines/linesys_2019.h" -#include "sensors/sensors.h" - -using namespace std; -LineSys2019::LineSys2019() {} -LineSys2019::LineSys2019(vector in_, vector out_){ - this->in = in_; - this->out = out_; - - fboundsX = false; - fboundsY = false; - slow = false; - - linesensOldX = 0; - linesensOldY = 0; - - tookLine = false; - - for(int i = 0; i < 4; i++){ - linetriggerI[i] = 0; - linetriggerO[i] = 0; - } - - exitTimer = 0; - linesens = 0; -} - -void LineSys2019::update(){ - inV = 0; - outV = 0; - tookLine = false; - - for(DataSource* d : in) d->readSensor(); - for(DataSource* d : out) d->readSensor(); - - for(auto it = in.begin(); it != in.end(); it++){ - i = it - in.begin(); - ds = *it; - linetriggerI[i] = ds->getValue() > LINE_THRESH; - } - for(auto it = out.begin(); it != out.end(); it++){ - i = it - out.begin(); - ds = *it; - linetriggerO[i] = ds->getValue() > LINE_THRESH; - } - - for(int i = 0; i < 4; i++){ - inV = inV | (linetriggerI[i] << i); - outV = outV | (linetriggerO[i] << i); - } - - - if ((inV > 0) || (outV > 0)) { - if(exitTimer > EXTIME) { - fboundsX = true; - fboundsY = true; - } - exitTimer = 0; - } - - linesens |= inV | outV; - outOfBounds(); -} - -void LineSys2019::outOfBounds(){ - - if(fboundsX == true) { - if(linesens & 0x02) linesensOldX = 2; - else if(linesens & 0x08) linesensOldX = 8; - if(linesensOldX != 0) fboundsX = false; - } - if(fboundsY == true) { - if(linesens & 0x01) linesensOldY = 1; - else if(linesens & 0x04) linesensOldY = 4; - if(linesensOldY != 0) fboundsY = false; - } - - if (exitTimer <= EXTIME){ - //fase di rientro - if(linesens == 15) linesens = linesensOldY | linesensOldX; //ZOZZATA MAXIMA - drive->unlockTime = millis(); - - if(linesens == 1) outDir = 180; - else if(linesens == 2) outDir = 270; - else if(linesens == 4) outDir = 0; - else if(linesens == 8) outDir = 90; - else if(linesens == 3) outDir = 225; - else if(linesens == 6) outDir = 315; - else if(linesens == 12) outDir = 45; - else if(linesens == 9) outDir = 135; - else if(linesens == 7) outDir = 270; - else if(linesens == 13) outDir = 90; - else if(linesens == 11) outDir = 180; - else if(linesens == 14) outDir = 0; - else if(linesens == 5){ - if(linesensOldX == 2) outDir = 270; - else if(linesensOldY == 8) outDir = 90; - } - else if(linesens == 10){ - if(linesensOldY == 4) outDir = 0; - else if(linesensOldY == 1) outDir = 180; - } - - drive->prepareDrive(outDir, LINES_EXIT_SPD); - tookLine = true; - }else{ - //fine rientro - if(linesens == 1) drive->vyp = 1; - else if(linesens == 2) drive->vxp = 1; - else if(linesens == 4) drive->vyn = 1; - else if(linesens == 8) drive->vxn = 1; - else if(linesens == 3) { - drive->vyp = 1; - drive->vxp = 1; - } - else if(linesens == 6){ - drive->vxp = 1; - drive->vyn = 1; - } - else if(linesens == 12) { - drive->vyn = 1; - drive->vxn = 1; - } - else if(linesens == 9) { - drive->vyp = 1; - drive->vxn = 1; - } - else if(linesens == 7) { - drive->vyp = 1; - drive->vyn = 1; - drive->vxp = 1; - } - else if(linesens == 13){ - drive->vxp = 1; - drive->vxn = 1; - drive->vyn = 1; - } - else if(linesens == 11) { - drive->vyp = 1; - drive->vxn = 1; - drive->vxp = 1; - } - else if(linesens == 14) { - drive->vyn = 1; - drive->vxn = 1; - drive->vxp = 1; - } - else if(linesens == 5){ - if(linesensOldX == 2) drive->vyp = 1; - else if(linesensOldY == 8)drive->vyn = 1; - } - else if(linesens == 10){ - if(linesensOldY == 4) drive->vyn = 1; - else if(linesensOldY == 1) drive->vyp = 1; - } - drive->canUnlock = true; - linesens = 0; - linesensOldY = 0; - linesensOldX = 0; - } -} - -void LineSys2019::test(){ - update(); - DEBUG.print("In: "); - for(DataSource* d : in){ - d->update(); - DEBUG.print(d->getValue()); - DEBUG.print(" | "); - } - DEBUG.print(" |---| "); - DEBUG.print("Out: "); - for(DataSource* d : out){ - d->update(); - DEBUG.print(d->getValue()); - DEBUG.print(" | "); - } - DEBUG.println(); - for(int i = 0; i < 4; i++){ - DEBUG.print(linetriggerI[i]); - DEBUG.print(" | "); - DEBUG.println(linetriggerO[i]); - } - - DEBUG.println(inV); - DEBUG.println(outV); - DEBUG.println(); -} \ No newline at end of file diff --git a/src/system/lines/linesys_camera_new.cpp b/src/system/lines/linesys_camera_new.cpp deleted file mode 100644 index 5a906fe..0000000 --- a/src/system/lines/linesys_camera_new.cpp +++ /dev/null @@ -1,116 +0,0 @@ -// #include "sensors/linesys_camera.h" -// #include "position/positionsys_camera.h" -// #include "sensors/sensors.h" -// #include "strategy_roles/games.h" - -// using namespace std; -// LineSysCamera::LineSysCamera() {} -// LineSysCamera::LineSysCamera(vector in_, vector out_){ -// this->in = in_; -// this->out = out_; - -// fboundsX = false; -// fboundsY = false; -// slow = false; - -// linesensOldX = 0; -// linesensOldY = 0; - -// tookLine = false; - -// for(int i = 0; i < 4; i++){ -// linetriggerI[i] = 0; -// linetriggerO[i] = 0; -// } - -// exitTimer = 0; -// linesens = 0; -// } - -// void LineSysCamera::update(){ -// inV = 0; -// outV = 0; -// tookLine = false; - -// for(DataSource* d : in) d->readSensor(); -// for(DataSource* d : out) d->readSensor(); - -// for(auto it = in.begin(); it != in.end(); it++){ -// i = it - in.begin(); -// ds = *it; -// linetriggerI[i] = ds->getValue() > LINE_THRESH_CAM; -// } -// for(auto it = out.begin(); it != out.end(); it++){ -// i = it - out.begin(); -// ds = *it; -// linetriggerO[i] = ds->getValue() > LINE_THRESH_CAM; -// } - -// for(int i = 0; i < 4; i++){ -// inV = inV | (linetriggerI[i] << i); -// outV = outV | (linetriggerO[i] << i); -// } - - -// if ((inV > 0) || (outV > 0)) { -// if(millis() - exitTimer > EXTIME_CAM) { -// fboundsX = true; -// fboundsY = true; -// } -// exitTimer = millis(); -// } - -// linesens |= inV | outV; -// outOfBounds(); -// } - -// void LineSysCamera::outOfBounds(){ - -// if(fboundsX == true) { -// if(linesens & 0x02) linesensOldX = 2; -// else if(linesens & 0x08) linesensOldX = 8; -// if(linesensOldX != 0) fboundsX = false; -// } -// if(fboundsY == true) { -// if(linesens & 0x01) linesensOldY = 1; -// else if(linesens & 0x04) linesensOldY = 4; -// if(linesensOldY != 0) fboundsY = false; -// } - -// if (millis() - exitTimer <= EXTIME_CAM){ -// if(linesens > 0) ((PositionSysCamera*)goalie->ps)->goCenter(); - -// tookLine = true; -// }else{ -// linesens = 0; -// linesensOldY = 0; -// linesensOldX = 0; -// } -// } - -// void LineSysCamera::test(){ -// update(); -// DEBUG.print("In: "); -// for(DataSource* d : in){ -// d->update(); -// DEBUG.print(d->getValue()); -// DEBUG.print(" | "); -// } -// DEBUG.print(" |---| "); -// DEBUG.print("Out: "); -// for(DataSource* d : out){ -// d->update(); -// DEBUG.print(d->getValue()); -// DEBUG.print(" | "); -// } -// DEBUG.println(); -// for(int i = 0; i < 4; i++){ -// DEBUG.print(linetriggerI[i]); -// DEBUG.print(" | "); -// DEBUG.println(linetriggerO[i]); -// } - -// DEBUG.println(inV); -// DEBUG.println(outV); -// DEBUG.println(); -// } \ No newline at end of file diff --git a/src/test_menu.cpp b/src/test_menu.cpp index d6edd67..08125b3 100644 --- a/src/test_menu.cpp +++ b/src/test_menu.cpp @@ -4,7 +4,6 @@ #include "sensors/data_source_bt.h" #include "sensors/data_source_camera_conicmirror.h" #include "systems/lines/linesys_camera.h" -#include "systems/lines/linesys_2019.h" #include "sensors/sensors.h" #include "motors_movement/motor.h" #include "motors_movement/drivecontroller.h" @@ -90,11 +89,11 @@ void TestMenu :: testMenu(){ delay(100); break; case '7': - break; - case '8': CURRENT_DATA_READ.game->ls->test(); delay(200); break; + case '8': + break; case 'u': while(Serial2.available()) DEBUG.print((char)Serial2.read()); break;