From 20b3aa1b0c40f7752011d61d0bdae8d263249401 Mon Sep 17 00:00:00 2001 From: EmaMaker Date: Mon, 9 Dec 2019 19:08:05 +0100 Subject: [PATCH] ported goalie and keeper from old code, condtion code working to decide game strategy --- .gitignore | 0 .travis.yml | 0 .vscode/extensions.json | 0 .vscode/settings.json | 0 README.md | 0 include/data_source.h | 0 include/data_source_ball.h | 0 include/data_source_bno055.h | 0 include/data_source_camera.h | 0 include/data_source_controller.h | 0 include/data_source_us.h | 0 include/drivecontroller.h | 4 +- include/ds_ctrl.h | 0 include/ds_ctrl_lines.h | 0 include/game.h | 19 +-- include/games.h | 17 +++ include/goalie.h | 16 ++- include/keeper.h | 22 +++- include/motor.h | 0 include/sensors.h | 41 +++---- include/vars.h | 0 lib/Adafruit-GFX/.gitignore | 0 lib/Adafruit-GFX/.travis.yml | 0 lib/Adafruit-GFX/Adafruit_GFX.cpp | 0 lib/Adafruit-GFX/Adafruit_GFX.h | 0 lib/Adafruit-GFX/Adafruit_SPITFT.cpp | 0 lib/Adafruit-GFX/Adafruit_SPITFT.h | 0 lib/Adafruit-GFX/Adafruit_SPITFT_Macros.h | 0 lib/Adafruit-GFX/Fonts/FreeMono12pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeMono18pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeMono24pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeMono9pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeMonoBold12pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeMonoBold18pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeMonoBold24pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeMonoBold9pt7b.h | 0 .../Fonts/FreeMonoBoldOblique12pt7b.h | 0 .../Fonts/FreeMonoBoldOblique18pt7b.h | 0 .../Fonts/FreeMonoBoldOblique24pt7b.h | 0 .../Fonts/FreeMonoBoldOblique9pt7b.h | 0 .../Fonts/FreeMonoOblique12pt7b.h | 0 .../Fonts/FreeMonoOblique18pt7b.h | 0 .../Fonts/FreeMonoOblique24pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeMonoOblique9pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSans12pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSans18pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSans24pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSans9pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSansBold12pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSansBold18pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSansBold24pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSansBold9pt7b.h | 0 .../Fonts/FreeSansBoldOblique12pt7b.h | 0 .../Fonts/FreeSansBoldOblique18pt7b.h | 0 .../Fonts/FreeSansBoldOblique24pt7b.h | 0 .../Fonts/FreeSansBoldOblique9pt7b.h | 0 .../Fonts/FreeSansOblique12pt7b.h | 0 .../Fonts/FreeSansOblique18pt7b.h | 0 .../Fonts/FreeSansOblique24pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSansOblique9pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSerif12pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSerif18pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSerif24pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSerif9pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSerifBold12pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSerifBold18pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSerifBold24pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSerifBold9pt7b.h | 0 .../Fonts/FreeSerifBoldItalic12pt7b.h | 0 .../Fonts/FreeSerifBoldItalic18pt7b.h | 0 .../Fonts/FreeSerifBoldItalic24pt7b.h | 0 .../Fonts/FreeSerifBoldItalic9pt7b.h | 0 .../Fonts/FreeSerifItalic12pt7b.h | 0 .../Fonts/FreeSerifItalic18pt7b.h | 0 .../Fonts/FreeSerifItalic24pt7b.h | 0 lib/Adafruit-GFX/Fonts/FreeSerifItalic9pt7b.h | 0 lib/Adafruit-GFX/Fonts/Org_01.h | 0 lib/Adafruit-GFX/Fonts/Picopixel.h | 0 lib/Adafruit-GFX/Fonts/Tiny3x3a2pt7b | 0 lib/Adafruit-GFX/Fonts/TomThumb.h | 0 lib/Adafruit-GFX/README.md | 0 .../examples/mock_ili9341/mock_ili9341.ino | 0 lib/Adafruit-GFX/fontconvert/Makefile | 0 lib/Adafruit-GFX/fontconvert/fontconvert.c | 0 .../fontconvert/fontconvert_win.md | 0 lib/Adafruit-GFX/fontconvert/makefonts.sh | 0 lib/Adafruit-GFX/gfxfont.h | 0 lib/Adafruit-GFX/glcdfont.c | 0 lib/Adafruit-GFX/library.properties | 0 lib/Adafruit-GFX/license.txt | 0 lib/Adafruit_BNO055/Adafruit_BNO055.cpp | 0 lib/Adafruit_BNO055/Adafruit_BNO055.h | 0 lib/Adafruit_BNO055/OBJLoader/OBJLoader.txt | 0 lib/Adafruit_BNO055/OBJLoader/OBJLoader.zip | Bin lib/Adafruit_BNO055/README.md | 0 lib/Adafruit_BNO055/examples/bunny/bunny.ino | 0 .../processing/cuberotate/cuberotate.pde | 0 .../processing/cuberotate/data/bunny.mtl | 0 .../processing/cuberotate/data/bunny.obj | 0 .../processing/cuberotate/serialconfig.txt | 0 .../examples/rawdata/rawdata.ino | 0 .../restore_offsets/restore_offsets.ino | 0 .../examples/sensorapi/sensorapi.ino | 0 lib/Adafruit_BNO055/library.properties | 0 lib/Adafruit_BNO055/utility/imumaths.h | 0 lib/Adafruit_BNO055/utility/matrix.h | 0 lib/Adafruit_BNO055/utility/quaternion.h | 0 lib/Adafruit_BNO055/utility/vector.h | 0 lib/Adafruit_Sensor-master/.gitignore | 0 lib/Adafruit_Sensor-master/Adafruit_Sensor.h | 0 lib/Adafruit_Sensor-master/README.md | 0 lib/Adafruit_Sensor-master/library.properties | 0 lib/Adafruit_VL53L0X/README.md | 0 lib/Adafruit_VL53L0X/doxyfile | 0 .../examples/vl53l0x/vl53l0x.ino | 0 .../examples/vl53l0x_oled/vl53l0x_oled.ino | 0 lib/Adafruit_VL53L0X/library.properties | 0 .../src/core/src/vl53l0x_api.cpp | 0 .../src/core/src/vl53l0x_api_calibration.cpp | 0 .../src/core/src/vl53l0x_api_core.cpp | 0 .../src/core/src/vl53l0x_api_ranging.cpp | 0 .../src/core/src/vl53l0x_api_strings.cpp | 0 .../src/platform/src/vl53l0x_i2c_comms.cpp | 0 .../src/platform/src/vl53l0x_platform.cpp | 0 lib/README | 0 platformio.ini | 0 src/data_source.cpp | 0 src/data_source_ball.cpp | 0 src/data_source_bno055.cpp | 0 src/data_source_camera.cpp | 0 src/data_source_us.cpp | 0 src/drivecontroller.cpp | 4 +- src/ds_ctrl.cpp | 0 src/ds_ctrl_lines.cpp | 0 src/game.cpp | 30 +---- src/games.cpp | 8 ++ src/goalie.cpp | 115 ++++++++++++++---- src/keeper.cpp | 51 ++++++-- src/main.cpp | 10 +- src/motor.cpp | 0 src/sensors.cpp | 7 +- test/README | 0 142 files changed, 235 insertions(+), 109 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 .travis.yml mode change 100644 => 100755 .vscode/extensions.json mode change 100644 => 100755 .vscode/settings.json mode change 100644 => 100755 README.md mode change 100644 => 100755 include/data_source.h mode change 100644 => 100755 include/data_source_ball.h mode change 100644 => 100755 include/data_source_bno055.h mode change 100644 => 100755 include/data_source_camera.h mode change 100644 => 100755 include/data_source_controller.h mode change 100644 => 100755 include/data_source_us.h mode change 100644 => 100755 include/drivecontroller.h mode change 100644 => 100755 include/ds_ctrl.h mode change 100644 => 100755 include/ds_ctrl_lines.h mode change 100644 => 100755 include/game.h create mode 100644 include/games.h mode change 100644 => 100755 include/goalie.h mode change 100644 => 100755 include/keeper.h mode change 100644 => 100755 include/motor.h mode change 100644 => 100755 include/sensors.h mode change 100644 => 100755 include/vars.h mode change 100644 => 100755 lib/Adafruit-GFX/.gitignore mode change 100644 => 100755 lib/Adafruit-GFX/.travis.yml mode change 100644 => 100755 lib/Adafruit-GFX/Adafruit_GFX.cpp mode change 100644 => 100755 lib/Adafruit-GFX/Adafruit_GFX.h mode change 100644 => 100755 lib/Adafruit-GFX/Adafruit_SPITFT.cpp mode change 100644 => 100755 lib/Adafruit-GFX/Adafruit_SPITFT.h mode change 100644 => 100755 lib/Adafruit-GFX/Adafruit_SPITFT_Macros.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeMono12pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeMono18pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeMono24pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeMono9pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeMonoBold12pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeMonoBold18pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeMonoBold24pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeMonoBold9pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeMonoBoldOblique12pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeMonoBoldOblique18pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeMonoBoldOblique24pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeMonoBoldOblique9pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeMonoOblique12pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeMonoOblique18pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeMonoOblique24pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeMonoOblique9pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSans12pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSans18pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSans24pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSans9pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSansBold12pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSansBold18pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSansBold24pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSansBold9pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSansBoldOblique12pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSansBoldOblique18pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSansBoldOblique24pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSansBoldOblique9pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSansOblique12pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSansOblique18pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSansOblique24pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSansOblique9pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSerif12pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSerif18pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSerif24pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSerif9pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSerifBold12pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSerifBold18pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSerifBold24pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSerifBold9pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSerifBoldItalic12pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSerifBoldItalic18pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSerifBoldItalic24pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSerifBoldItalic9pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSerifItalic12pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSerifItalic18pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSerifItalic24pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/FreeSerifItalic9pt7b.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/Org_01.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/Picopixel.h mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/Tiny3x3a2pt7b mode change 100644 => 100755 lib/Adafruit-GFX/Fonts/TomThumb.h mode change 100644 => 100755 lib/Adafruit-GFX/README.md mode change 100644 => 100755 lib/Adafruit-GFX/examples/mock_ili9341/mock_ili9341.ino mode change 100644 => 100755 lib/Adafruit-GFX/fontconvert/Makefile mode change 100644 => 100755 lib/Adafruit-GFX/fontconvert/fontconvert.c mode change 100644 => 100755 lib/Adafruit-GFX/fontconvert/fontconvert_win.md mode change 100644 => 100755 lib/Adafruit-GFX/fontconvert/makefonts.sh mode change 100644 => 100755 lib/Adafruit-GFX/gfxfont.h mode change 100644 => 100755 lib/Adafruit-GFX/glcdfont.c mode change 100644 => 100755 lib/Adafruit-GFX/library.properties mode change 100644 => 100755 lib/Adafruit-GFX/license.txt mode change 100644 => 100755 lib/Adafruit_BNO055/Adafruit_BNO055.cpp mode change 100644 => 100755 lib/Adafruit_BNO055/Adafruit_BNO055.h mode change 100644 => 100755 lib/Adafruit_BNO055/OBJLoader/OBJLoader.txt mode change 100644 => 100755 lib/Adafruit_BNO055/OBJLoader/OBJLoader.zip mode change 100644 => 100755 lib/Adafruit_BNO055/README.md mode change 100644 => 100755 lib/Adafruit_BNO055/examples/bunny/bunny.ino mode change 100644 => 100755 lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/cuberotate.pde mode change 100644 => 100755 lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/data/bunny.mtl mode change 100644 => 100755 lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/data/bunny.obj mode change 100644 => 100755 lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/serialconfig.txt mode change 100644 => 100755 lib/Adafruit_BNO055/examples/rawdata/rawdata.ino mode change 100644 => 100755 lib/Adafruit_BNO055/examples/restore_offsets/restore_offsets.ino mode change 100644 => 100755 lib/Adafruit_BNO055/examples/sensorapi/sensorapi.ino mode change 100644 => 100755 lib/Adafruit_BNO055/library.properties mode change 100644 => 100755 lib/Adafruit_BNO055/utility/imumaths.h mode change 100644 => 100755 lib/Adafruit_BNO055/utility/matrix.h mode change 100644 => 100755 lib/Adafruit_BNO055/utility/quaternion.h mode change 100644 => 100755 lib/Adafruit_BNO055/utility/vector.h mode change 100644 => 100755 lib/Adafruit_Sensor-master/.gitignore mode change 100644 => 100755 lib/Adafruit_Sensor-master/Adafruit_Sensor.h mode change 100644 => 100755 lib/Adafruit_Sensor-master/README.md mode change 100644 => 100755 lib/Adafruit_Sensor-master/library.properties mode change 100644 => 100755 lib/Adafruit_VL53L0X/README.md mode change 100644 => 100755 lib/Adafruit_VL53L0X/doxyfile mode change 100644 => 100755 lib/Adafruit_VL53L0X/examples/vl53l0x/vl53l0x.ino mode change 100644 => 100755 lib/Adafruit_VL53L0X/examples/vl53l0x_oled/vl53l0x_oled.ino mode change 100644 => 100755 lib/Adafruit_VL53L0X/library.properties mode change 100644 => 100755 lib/Adafruit_VL53L0X/src/core/src/vl53l0x_api.cpp mode change 100644 => 100755 lib/Adafruit_VL53L0X/src/core/src/vl53l0x_api_calibration.cpp mode change 100644 => 100755 lib/Adafruit_VL53L0X/src/core/src/vl53l0x_api_core.cpp mode change 100644 => 100755 lib/Adafruit_VL53L0X/src/core/src/vl53l0x_api_ranging.cpp mode change 100644 => 100755 lib/Adafruit_VL53L0X/src/core/src/vl53l0x_api_strings.cpp mode change 100644 => 100755 lib/Adafruit_VL53L0X/src/platform/src/vl53l0x_i2c_comms.cpp mode change 100644 => 100755 lib/Adafruit_VL53L0X/src/platform/src/vl53l0x_platform.cpp mode change 100644 => 100755 lib/README mode change 100644 => 100755 platformio.ini mode change 100644 => 100755 src/data_source.cpp mode change 100644 => 100755 src/data_source_ball.cpp mode change 100644 => 100755 src/data_source_bno055.cpp mode change 100644 => 100755 src/data_source_camera.cpp mode change 100644 => 100755 src/data_source_us.cpp mode change 100644 => 100755 src/drivecontroller.cpp mode change 100644 => 100755 src/ds_ctrl.cpp mode change 100644 => 100755 src/ds_ctrl_lines.cpp create mode 100644 src/games.cpp mode change 100644 => 100755 src/goalie.cpp mode change 100644 => 100755 src/keeper.cpp mode change 100644 => 100755 src/main.cpp mode change 100644 => 100755 src/motor.cpp mode change 100644 => 100755 src/sensors.cpp mode change 100644 => 100755 test/README diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.travis.yml b/.travis.yml old mode 100644 new mode 100755 diff --git a/.vscode/extensions.json b/.vscode/extensions.json old mode 100644 new mode 100755 diff --git a/.vscode/settings.json b/.vscode/settings.json old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/include/data_source.h b/include/data_source.h old mode 100644 new mode 100755 diff --git a/include/data_source_ball.h b/include/data_source_ball.h old mode 100644 new mode 100755 diff --git a/include/data_source_bno055.h b/include/data_source_bno055.h old mode 100644 new mode 100755 diff --git a/include/data_source_camera.h b/include/data_source_camera.h old mode 100644 new mode 100755 diff --git a/include/data_source_controller.h b/include/data_source_controller.h old mode 100644 new mode 100755 diff --git a/include/data_source_us.h b/include/data_source_us.h old mode 100644 new mode 100755 diff --git a/include/drivecontroller.h b/include/drivecontroller.h old mode 100644 new mode 100755 index 87785e4..6c6521f --- a/include/drivecontroller.h +++ b/include/drivecontroller.h @@ -15,8 +15,8 @@ class DriveController{ DriveController(Motor* m1_, Motor* m2_, Motor* m3_, Motor* m4_); - void drive(int dir, int speed, int tilt); - void prepareDrive(int dir, int speed, int tilt); + void drive(int dir=0, int speed=0, int tilt=0); + void prepareDrive(int dir=0, int speed=0, int tilt=0); void drivePrepared(); float updatePid(); float torad(float f); diff --git a/include/ds_ctrl.h b/include/ds_ctrl.h old mode 100644 new mode 100755 diff --git a/include/ds_ctrl_lines.h b/include/ds_ctrl_lines.h old mode 100644 new mode 100755 diff --git a/include/game.h b/include/game.h old mode 100644 new mode 100755 index 0b02f40..2776e2e --- a/include/game.h +++ b/include/game.h @@ -1,21 +1,12 @@ #pragma once -#include "data_source.h" -#include "data_source_ball.h" -#include "motor.h" -#include "drivecontroller.h" -#include "sensors.h" #include "vars.h" -#include "data_source_bno055.h" -#include "goalie.h" -#include "keeper.h" +#include "sensors.h" -class Game{ +class Game { public: Game(); - //void keeper(); - //void goalie(); - //void ballBack(); - bool role, attackGoal; //1->goalie 0->keeper, 1->yellow 0->blue - //~Game(); + void play(bool condition=true); + private: + virtual void realPlay() = 0; }; \ No newline at end of file diff --git a/include/games.h b/include/games.h new file mode 100644 index 0000000..df9148f --- /dev/null +++ b/include/games.h @@ -0,0 +1,17 @@ +#pragma once + +#ifdef GAMES_CPP +#define g_extr +#else +#define g_extr extern +#endif + +#include +#include "game.h" +#include "goalie.h" +#include "keeper.h" + +void initGames(); + +g_extr Game* goalie; +g_extr Game* keeper; \ No newline at end of file diff --git a/include/goalie.h b/include/goalie.h old mode 100644 new mode 100755 index fba8d97..d6fde1d --- a/include/goalie.h +++ b/include/goalie.h @@ -1,8 +1,10 @@ #pragma once #include "game.h" +#include "sensors.h" +#include "data_source_camera.h" -/* #define GOALIE_ATKSPD_LAT 255 +#define GOALIE_ATKSPD_LAT 255 #define GOALIE_ATKSPD_BAK 350 #define GOALIE_ATKSPD_FRT 345 #define GOALIE_ATKSPD_STRK 355 @@ -12,14 +14,18 @@ #define GOALIE_ATKDIR_PLUSANGBAK 40 #define GOALIE_ATKDIR_PLUSANG1_COR 60 #define GOALIE_ATKDIR_PLUSANG2_COR 70 -#define GOALIE_ATKDIR_PLUSANG3_COR 70 */ +#define GOALIE_ATKDIR_PLUSANG3_COR 70 -class Goalie{ +class Goalie : public Game{ public: Goalie(); + + void realPlay() override; void goalie(); void ballBack(); - //void rigore(); to be implemented - int atk_direction, atk_speed; + void storcimentoPorta(); + + int atk_speed, atk_direction; + float cstorc; }; diff --git a/include/keeper.h b/include/keeper.h old mode 100644 new mode 100755 index 527cd8d..d63c850 --- a/include/keeper.h +++ b/include/keeper.h @@ -2,10 +2,26 @@ #include "game.h" -class Keeper{ +//KEEPER +#define KEEPER_ATTACK_DISTANCE 200 +#define KEEPER_ALONE_ATTACK_TIME 5000 //in millis +#define KEEPER_COMRADE_ATTACK_TIME 3000//in millis +#define KEEPER_BASE_VEL 320 +#define KEEPER_VEL_MULT 1.4 +#define KEEPER_BALL_BACK_ANGLE 30 + + +class Keeper : public Game{ public: Keeper(); + private: + void realPlay() override; void keeper(); - //void keeperGoalie(); to be implemented -}; \ No newline at end of file + + int defSpeed, defDir; + + float angle, angleX, angleY; + elapsedMillis t, toh, keeperAttackTimer; + bool keeper_tookTimer, keeper_backToGoalPost; +}; diff --git a/include/motor.h b/include/motor.h old mode 100644 new mode 100755 diff --git a/include/sensors.h b/include/sensors.h old mode 100644 new mode 100755 index 0398e27..d9d5e91 --- a/include/sensors.h +++ b/include/sensors.h @@ -1,5 +1,13 @@ -#include #pragma once + + +#ifdef SENSORS_CPP +#define s_extr +#else +#define s_extr extern +#endif + +#include #include "data_source_bno055.h" #include "data_source_ball.h" #include "data_source_camera.h" @@ -8,31 +16,20 @@ #include "motor.h" #include "ds_ctrl.h" #include "drivecontroller.h" -#include "game.h" -#ifdef SENSORS_CPP -#define extr -#else -#define extr extern -#endif -class Game; -class Goalie; -class Keeper; void initSensors(); void updateSensors(); -extr vector lIn; -extr vector lOut; -extr vector dUs; +s_extr vector lIn; +s_extr vector lOut; +s_extr vector dUs; -extr DataSourceCtrl* usCtrl; -extr DataSourceCtrlLines* linesCtrl; +s_extr DataSourceCtrl* usCtrl; +s_extr DataSourceCtrlLines* linesCtrl; -extr DataSourceBNO055* compass; -extr DataSourceBall* ball; -extr DataSourceCamera* camera; -extr DriveController* drive; +s_extr DataSourceBNO055* compass; +s_extr DataSourceBall* ball; +s_extr DataSourceCamera* camera; +s_extr DriveController* drive; -extr Game* game; -extr Goalie* goalie; -extr Keeper* keeper; +s_extr int role; \ No newline at end of file diff --git a/include/vars.h b/include/vars.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/.gitignore b/lib/Adafruit-GFX/.gitignore old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/.travis.yml b/lib/Adafruit-GFX/.travis.yml old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Adafruit_GFX.cpp b/lib/Adafruit-GFX/Adafruit_GFX.cpp old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Adafruit_GFX.h b/lib/Adafruit-GFX/Adafruit_GFX.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Adafruit_SPITFT.cpp b/lib/Adafruit-GFX/Adafruit_SPITFT.cpp old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Adafruit_SPITFT.h b/lib/Adafruit-GFX/Adafruit_SPITFT.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Adafruit_SPITFT_Macros.h b/lib/Adafruit-GFX/Adafruit_SPITFT_Macros.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeMono12pt7b.h b/lib/Adafruit-GFX/Fonts/FreeMono12pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeMono18pt7b.h b/lib/Adafruit-GFX/Fonts/FreeMono18pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeMono24pt7b.h b/lib/Adafruit-GFX/Fonts/FreeMono24pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeMono9pt7b.h b/lib/Adafruit-GFX/Fonts/FreeMono9pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeMonoBold12pt7b.h b/lib/Adafruit-GFX/Fonts/FreeMonoBold12pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeMonoBold18pt7b.h b/lib/Adafruit-GFX/Fonts/FreeMonoBold18pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeMonoBold24pt7b.h b/lib/Adafruit-GFX/Fonts/FreeMonoBold24pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeMonoBold9pt7b.h b/lib/Adafruit-GFX/Fonts/FreeMonoBold9pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeMonoBoldOblique12pt7b.h b/lib/Adafruit-GFX/Fonts/FreeMonoBoldOblique12pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeMonoBoldOblique18pt7b.h b/lib/Adafruit-GFX/Fonts/FreeMonoBoldOblique18pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeMonoBoldOblique24pt7b.h b/lib/Adafruit-GFX/Fonts/FreeMonoBoldOblique24pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeMonoBoldOblique9pt7b.h b/lib/Adafruit-GFX/Fonts/FreeMonoBoldOblique9pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeMonoOblique12pt7b.h b/lib/Adafruit-GFX/Fonts/FreeMonoOblique12pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeMonoOblique18pt7b.h b/lib/Adafruit-GFX/Fonts/FreeMonoOblique18pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeMonoOblique24pt7b.h b/lib/Adafruit-GFX/Fonts/FreeMonoOblique24pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeMonoOblique9pt7b.h b/lib/Adafruit-GFX/Fonts/FreeMonoOblique9pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSans12pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSans12pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSans18pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSans18pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSans24pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSans24pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSans9pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSans9pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSansBold12pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSansBold12pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSansBold18pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSansBold18pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSansBold24pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSansBold24pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSansBold9pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSansBold9pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSansBoldOblique12pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSansBoldOblique12pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSansBoldOblique18pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSansBoldOblique18pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSansBoldOblique24pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSansBoldOblique24pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSansBoldOblique9pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSansBoldOblique9pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSansOblique12pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSansOblique12pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSansOblique18pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSansOblique18pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSansOblique24pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSansOblique24pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSansOblique9pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSansOblique9pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSerif12pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSerif12pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSerif18pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSerif18pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSerif24pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSerif24pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSerif9pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSerif9pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSerifBold12pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSerifBold12pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSerifBold18pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSerifBold18pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSerifBold24pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSerifBold24pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSerifBold9pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSerifBold9pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSerifBoldItalic12pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSerifBoldItalic12pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSerifBoldItalic18pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSerifBoldItalic18pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSerifBoldItalic24pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSerifBoldItalic24pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSerifBoldItalic9pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSerifBoldItalic9pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSerifItalic12pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSerifItalic12pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSerifItalic18pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSerifItalic18pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSerifItalic24pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSerifItalic24pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/FreeSerifItalic9pt7b.h b/lib/Adafruit-GFX/Fonts/FreeSerifItalic9pt7b.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/Org_01.h b/lib/Adafruit-GFX/Fonts/Org_01.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/Picopixel.h b/lib/Adafruit-GFX/Fonts/Picopixel.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/Tiny3x3a2pt7b b/lib/Adafruit-GFX/Fonts/Tiny3x3a2pt7b old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/Fonts/TomThumb.h b/lib/Adafruit-GFX/Fonts/TomThumb.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/README.md b/lib/Adafruit-GFX/README.md old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/examples/mock_ili9341/mock_ili9341.ino b/lib/Adafruit-GFX/examples/mock_ili9341/mock_ili9341.ino old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/fontconvert/Makefile b/lib/Adafruit-GFX/fontconvert/Makefile old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/fontconvert/fontconvert.c b/lib/Adafruit-GFX/fontconvert/fontconvert.c old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/fontconvert/fontconvert_win.md b/lib/Adafruit-GFX/fontconvert/fontconvert_win.md old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/fontconvert/makefonts.sh b/lib/Adafruit-GFX/fontconvert/makefonts.sh old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/gfxfont.h b/lib/Adafruit-GFX/gfxfont.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/glcdfont.c b/lib/Adafruit-GFX/glcdfont.c old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/library.properties b/lib/Adafruit-GFX/library.properties old mode 100644 new mode 100755 diff --git a/lib/Adafruit-GFX/license.txt b/lib/Adafruit-GFX/license.txt old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/Adafruit_BNO055.cpp b/lib/Adafruit_BNO055/Adafruit_BNO055.cpp old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/Adafruit_BNO055.h b/lib/Adafruit_BNO055/Adafruit_BNO055.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/OBJLoader/OBJLoader.txt b/lib/Adafruit_BNO055/OBJLoader/OBJLoader.txt old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/OBJLoader/OBJLoader.zip b/lib/Adafruit_BNO055/OBJLoader/OBJLoader.zip old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/README.md b/lib/Adafruit_BNO055/README.md old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/examples/bunny/bunny.ino b/lib/Adafruit_BNO055/examples/bunny/bunny.ino old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/cuberotate.pde b/lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/cuberotate.pde old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/data/bunny.mtl b/lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/data/bunny.mtl old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/data/bunny.obj b/lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/data/bunny.obj old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/serialconfig.txt b/lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/serialconfig.txt old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/examples/rawdata/rawdata.ino b/lib/Adafruit_BNO055/examples/rawdata/rawdata.ino old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/examples/restore_offsets/restore_offsets.ino b/lib/Adafruit_BNO055/examples/restore_offsets/restore_offsets.ino old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/examples/sensorapi/sensorapi.ino b/lib/Adafruit_BNO055/examples/sensorapi/sensorapi.ino old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/library.properties b/lib/Adafruit_BNO055/library.properties old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/utility/imumaths.h b/lib/Adafruit_BNO055/utility/imumaths.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/utility/matrix.h b/lib/Adafruit_BNO055/utility/matrix.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/utility/quaternion.h b/lib/Adafruit_BNO055/utility/quaternion.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit_BNO055/utility/vector.h b/lib/Adafruit_BNO055/utility/vector.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit_Sensor-master/.gitignore b/lib/Adafruit_Sensor-master/.gitignore old mode 100644 new mode 100755 diff --git a/lib/Adafruit_Sensor-master/Adafruit_Sensor.h b/lib/Adafruit_Sensor-master/Adafruit_Sensor.h old mode 100644 new mode 100755 diff --git a/lib/Adafruit_Sensor-master/README.md b/lib/Adafruit_Sensor-master/README.md old mode 100644 new mode 100755 diff --git a/lib/Adafruit_Sensor-master/library.properties b/lib/Adafruit_Sensor-master/library.properties old mode 100644 new mode 100755 diff --git a/lib/Adafruit_VL53L0X/README.md b/lib/Adafruit_VL53L0X/README.md old mode 100644 new mode 100755 diff --git a/lib/Adafruit_VL53L0X/doxyfile b/lib/Adafruit_VL53L0X/doxyfile old mode 100644 new mode 100755 diff --git a/lib/Adafruit_VL53L0X/examples/vl53l0x/vl53l0x.ino b/lib/Adafruit_VL53L0X/examples/vl53l0x/vl53l0x.ino old mode 100644 new mode 100755 diff --git a/lib/Adafruit_VL53L0X/examples/vl53l0x_oled/vl53l0x_oled.ino b/lib/Adafruit_VL53L0X/examples/vl53l0x_oled/vl53l0x_oled.ino old mode 100644 new mode 100755 diff --git a/lib/Adafruit_VL53L0X/library.properties b/lib/Adafruit_VL53L0X/library.properties old mode 100644 new mode 100755 diff --git a/lib/Adafruit_VL53L0X/src/core/src/vl53l0x_api.cpp b/lib/Adafruit_VL53L0X/src/core/src/vl53l0x_api.cpp old mode 100644 new mode 100755 diff --git a/lib/Adafruit_VL53L0X/src/core/src/vl53l0x_api_calibration.cpp b/lib/Adafruit_VL53L0X/src/core/src/vl53l0x_api_calibration.cpp old mode 100644 new mode 100755 diff --git a/lib/Adafruit_VL53L0X/src/core/src/vl53l0x_api_core.cpp b/lib/Adafruit_VL53L0X/src/core/src/vl53l0x_api_core.cpp old mode 100644 new mode 100755 diff --git a/lib/Adafruit_VL53L0X/src/core/src/vl53l0x_api_ranging.cpp b/lib/Adafruit_VL53L0X/src/core/src/vl53l0x_api_ranging.cpp old mode 100644 new mode 100755 diff --git a/lib/Adafruit_VL53L0X/src/core/src/vl53l0x_api_strings.cpp b/lib/Adafruit_VL53L0X/src/core/src/vl53l0x_api_strings.cpp old mode 100644 new mode 100755 diff --git a/lib/Adafruit_VL53L0X/src/platform/src/vl53l0x_i2c_comms.cpp b/lib/Adafruit_VL53L0X/src/platform/src/vl53l0x_i2c_comms.cpp old mode 100644 new mode 100755 diff --git a/lib/Adafruit_VL53L0X/src/platform/src/vl53l0x_platform.cpp b/lib/Adafruit_VL53L0X/src/platform/src/vl53l0x_platform.cpp old mode 100644 new mode 100755 diff --git a/lib/README b/lib/README old mode 100644 new mode 100755 diff --git a/platformio.ini b/platformio.ini old mode 100644 new mode 100755 diff --git a/src/data_source.cpp b/src/data_source.cpp old mode 100644 new mode 100755 diff --git a/src/data_source_ball.cpp b/src/data_source_ball.cpp old mode 100644 new mode 100755 diff --git a/src/data_source_bno055.cpp b/src/data_source_bno055.cpp old mode 100644 new mode 100755 diff --git a/src/data_source_camera.cpp b/src/data_source_camera.cpp old mode 100644 new mode 100755 diff --git a/src/data_source_us.cpp b/src/data_source_us.cpp old mode 100644 new mode 100755 diff --git a/src/drivecontroller.cpp b/src/drivecontroller.cpp old mode 100644 new mode 100755 index af2653d..db4b651 --- a/src/drivecontroller.cpp +++ b/src/drivecontroller.cpp @@ -34,7 +34,7 @@ DriveController::DriveController(Motor* m1_, Motor* m2_, Motor* m3_, Motor* m4_) integral = 0; } -void DriveController::prepareDrive(int dir, int speed, int tilt){ +void DriveController::prepareDrive(int dir=0, int speed=0, int tilt=0){ pDir = dir; pSpeed = speed; pTilt = tilt; @@ -48,7 +48,7 @@ float DriveController::torad(float f){ return (f * PI / 180.0); } -void DriveController::drive(int dir, int speed, int tilt){ +void DriveController::drive(int dir=0, int speed=0, int tilt=0){ vx = ((speed * cosins[dir])); vy = ((-speed * sins[dir])); diff --git a/src/ds_ctrl.cpp b/src/ds_ctrl.cpp old mode 100644 new mode 100755 diff --git a/src/ds_ctrl_lines.cpp b/src/ds_ctrl_lines.cpp old mode 100644 new mode 100755 diff --git a/src/game.cpp b/src/game.cpp index 04c054f..ee521a6 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1,29 +1,7 @@ #include "game.h" -Game::Game(){ +Game::Game() {} -} - -/* void Game::goalie(){ - /* //drive->prepareDrive(0, 150, 0); - digitalWrite(LED_G, HIGH); - if(ball->ballSeen){ - if(ball->angle >= 0 && ball->angle < 45) drive->drive(0, 75, 0); - else if(ball->angle >= 45 && ball->angle <= 60) drive->drive(45, 75, 0); - else if(ball->angle > 60 && ball->angle < 90) drive->drive(75, 75, 0); - else if(ball->angle >= 90 && ball->angle < 135) drive->drive(90, 75, 0); - } else { - drive->prepareDrive(0, 0, 0); - drive->drive(0, 0, 0); - } -} - -void Game::keeper(){ - digitalWrite(LED_Y, HIGH); - drive->prepareDrive(0, 0, 0); - drive->drive(0, 0, 0); -} - -void ballBack(){ - -} */ +void Game::play(bool condition=true){ + if(condition) realPlay(); +} \ No newline at end of file diff --git a/src/games.cpp b/src/games.cpp new file mode 100644 index 0000000..fd07bcb --- /dev/null +++ b/src/games.cpp @@ -0,0 +1,8 @@ +#define GAMES_CPP + +#include "games.h" + +void initGames(){ + goalie = new Goalie(); + keeper = new Keeper(); +} \ No newline at end of file diff --git a/src/goalie.cpp b/src/goalie.cpp old mode 100644 new mode 100755 index 2417f5f..2a45f60 --- a/src/goalie.cpp +++ b/src/goalie.cpp @@ -1,33 +1,106 @@ #include "goalie.h" +#include "sensors.h" +#include "vars.h" -Goalie::Goalie(){ } - -void Goalie::goalie(){ - digitalWrite(LED_G, HIGH); - if(ball->ballSeen){ - if(ball->angle >= 0 && ball->angle < 45) drive->prepareDrive(0, 75, 0); - /* else if(ball->angle >= 45 && ball->angle <= 60) drive->drive(ball->angle, 75, 0); - else if(ball->angle > 60 && ball->angle < 90) drive->drive(ball->angle, 75, 0); - else if(ball->angle >= 90 && ball->angle < 135) drive->drive(ball->angle, 75, 0); */ - } else { - drive->prepareDrive(0, 0, 0); - drive->drive(0, 0, 0); - } +Goalie::Goalie() : Game() { + atk_speed = 0; + atk_direction = 0; } -void Goalie::ballBack(){ -/* old int ballangle2; - int dir; - int plusang; +void Goalie::realPlay(){ + goalie(); +} +void Goalie::goalie() { + if(ball->angle >= 350 || ball->angle <= 10) { + if(ball->distance > 190) atk_direction = 0; + else atk_direction = ball->angle; + atk_speed = GOALIE_ATKSPD_FRT; + } + + if(ball->angle >= 90 && ball->angle <= 270) { + ballBack(); + atk_speed = GOALIE_ATKSPD_BAK; + } + if(digitalRead(SWITCH_DX) == 1) { + if(ball->angle > 10 && ball->angle < 30) { + atk_direction = ball->angle + GOALIE_ATKDIR_PLUSANG1; + atk_speed = GOALIE_ATKSPD_LAT; + } + if(ball->angle >= 30 && ball->angle < 45) { + atk_direction = ball->angle + GOALIE_ATKDIR_PLUSANG2; + atk_speed = GOALIE_ATKSPD_LAT; + } + if(ball->angle >= 45 && ball->angle < 90) { + atk_direction = ball->angle + GOALIE_ATKDIR_PLUSANG3; + atk_speed = GOALIE_ATKSPD_LAT; + } + if(ball->angle > 270 && ball->angle <= 315) { + atk_direction = ball->angle - GOALIE_ATKDIR_PLUSANG3_COR; + atk_speed = GOALIE_ATKSPD_LAT; + } + if(ball->angle > 315 && ball->angle <= 330) { + atk_direction = ball->angle - GOALIE_ATKDIR_PLUSANG2_COR; + atk_speed = GOALIE_ATKSPD_LAT; + } + if(ball->angle > 330 && ball->angle < 350) { + atk_direction = ball->angle - GOALIE_ATKDIR_PLUSANG1_COR; + atk_speed = GOALIE_ATKSPD_LAT; + } + } else { + if(ball->angle > 10 && ball->angle < 30) { + atk_direction = ball->angle + GOALIE_ATKDIR_PLUSANG1_COR; + atk_speed = GOALIE_ATKSPD_LAT; + } + if(ball->angle >= 30 && ball->angle < 45) { + atk_direction = ball->angle + GOALIE_ATKDIR_PLUSANG2_COR; + atk_speed = GOALIE_ATKSPD_LAT; + } + if(ball->angle >= 45 && ball->angle < 90) { + atk_direction = ball->angle + GOALIE_ATKDIR_PLUSANG3_COR; + atk_speed = GOALIE_ATKSPD_LAT; + } + if(ball->angle > 270 && ball->angle <= 315) { + atk_direction = ball->angle - GOALIE_ATKDIR_PLUSANG3; + atk_speed = GOALIE_ATKSPD_LAT; + } + if(ball->angle > 315 && ball->angle <= 330) { + atk_direction = ball->angle - GOALIE_ATKDIR_PLUSANG2; + atk_speed = GOALIE_ATKSPD_LAT; + } + if(ball->angle > 330 && ball->angle < 350) { + atk_direction = ball->angle - GOALIE_ATKDIR_PLUSANG1; + atk_speed = GOALIE_ATKSPD_LAT; + } + } + + if((ball->angle >= 330 || ball->angle <= 30) && ball->distance > 190) { //storcimento + atk_speed = GOALIE_ATKSPD_STRK; //dove i gigahertz hanno fallito + drive->prepareDrive(atk_direction, atk_speed, 0); + } + else drive->prepareDrive(atk_direction, atk_speed); +} + +void Goalie::storcimentoPorta() { + if (camera->getValueAtk(true) >= 3) cstorc+=9; + else if (camera->getValueAtk(true) < -3) cstorc-=9; + else cstorc *= 0.7; + cstorc = constrain(cstorc, -30, 30); +} + +void Goalie::ballBack() { + int degrees2; + int dir; + + int plusang; if(ball->distance > 130) plusang = GOALIE_ATKDIR_PLUSANGBAK; else plusang = 0; - if(ball->angle > 180) ballangle2 = ball->angle - 360; - else ballangle2 = ball->angle; - if(ballangle2 > 0) dir = ball->angle + plusang; //45 con 8 ruote + if(ball->angle > 180) degrees2 = ball->angle - 360; + else degrees2 = ball->angle; + if(degrees2 > 0) dir = ball->angle + plusang; //45 con 8 ruote else dir = ball->angle - plusang; //45 con 8 ruote if(dir < 0) dir = dir + 360; else dir = dir; - atk_direction = dir; */ + atk_direction = dir; } \ No newline at end of file diff --git a/src/keeper.cpp b/src/keeper.cpp old mode 100644 new mode 100755 index 667a7ce..b2dd38f --- a/src/keeper.cpp +++ b/src/keeper.cpp @@ -1,15 +1,46 @@ #include "keeper.h" +#include "sensors.h" +#include "games.h" +#include -Keeper::Keeper(){ - +Keeper::Keeper() : Game() { + defSpeed = 0; + defDir = 0; + angle = 0; + angleX = 0; + angleY = 0; + t = 0; + toh= 0; + keeperAttackTimer = 0; + keeper_tookTimer = false; + keeper_backToGoalPost = false; } -void Keeper::keeper(){ - digitalWrite(LED_Y, HIGH); - drive->prepareDrive(0, 0, 0); - drive->drive(0, 0, 0); -} +void Keeper::realPlay() { + + if(ball->distance > KEEPER_ATTACK_DISTANCE){ + // Ball is quite near + goalie->play(); + if(!keeper_tookTimer){ + keeperAttackTimer = 0; + keeper_tookTimer = true; + } + if(keeperAttackTimer > KEEPER_ALONE_ATTACK_TIME && keeper_tookTimer) keeper_backToGoalPost = true; -/* void Keeper::keeperGoalie(){ - to be implemented -} */ \ No newline at end of file + }else{ + + angle = (90 + ball->angle) * M_PI / 180; + angleX = abs(cos(angle)); + + if(ball->angle >= 0 && ball->angle <= 90 && camera->getValueDef(true) < 30) drive->prepareDrive(90, KEEPER_BASE_VEL*angleX*KEEPER_VEL_MULT); + else if(ball->angle >= 270 && ball->angle <= 360 && camera->getValueDef(true) > -30) drive->prepareDrive(270, KEEPER_BASE_VEL*angleX*KEEPER_VEL_MULT); + else if(ball->angle < 270 && ball->angle > 90){ + int ball_degrees2 = ball->angle > 180? ball->angle-360:ball->angle; + int dir = ball_degrees2 > 0 ? ball->angle + KEEPER_BALL_BACK_ANGLE : ball->angle - KEEPER_BALL_BACK_ANGLE; + dir = dir < 0? dir + 360: dir; + + drive->prepareDrive(dir, KEEPER_BASE_VEL); + } + //centerGoalPostCamera(false); + } +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp old mode 100644 new mode 100755 index 180c412..502ecd3 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,12 +1,15 @@ #include -#include "game.h" +#include "sensors.h" +#include "games.h" void setup() { delay(500); DEBUG.begin(9600); initSensors(); + initGames(); + delay(2000); } @@ -14,7 +17,10 @@ void setup() { void loop() { updateSensors(); - goalie->goalie(); + goalie->play(role==1); + keeper->play(role==0); + + //Check lines before final movement linesCtrl->update(); // Last thing to do: movement diff --git a/src/motor.cpp b/src/motor.cpp old mode 100644 new mode 100755 diff --git a/src/sensors.cpp b/src/sensors.cpp old mode 100644 new mode 100755 index 4455aca..20271b9 --- a/src/sensors.cpp +++ b/src/sensors.cpp @@ -18,12 +18,15 @@ void initSensors(){ usCtrl = new DataSourceCtrl(dUs); linesCtrl = new DataSourceCtrlLines(lIn, lOut); - game = new Game(); + /*game = new Game(); goalie = new Goalie(); - keeper = new Keeper(); + keeper = new Keeper();*/ } void updateSensors(){ + role = digitalRead(SWITCH_DX); + camera->goalOrientation = digitalRead(SWITCH_SX); + compass->update(); ball->update(); camera->update(); diff --git a/test/README b/test/README old mode 100644 new mode 100755