diff --git a/README.md b/README.md index f069b22..662ed5d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ -# SPQR-Team-2020 -culo +# SPQR1 2020 + +SPQR1 Team 2020 Robot project repo. +Based in ITIS G. Galilei Rome diff --git a/include/data_source_ball.h b/include/data_source_ball.h index dc6da55..6beb7be 100644 --- a/include/data_source_ball.h +++ b/include/data_source_ball.h @@ -8,6 +8,6 @@ class DataSourceBall : public DataSource{ void postProcess() override; void test() override; - int angle,distance; + int angle, distance; bool ballSeen; }; \ No newline at end of file diff --git a/include/data_source_controller.h b/include/data_source_controller.h new file mode 100644 index 0000000..e83332f --- /dev/null +++ b/include/data_source_controller.h @@ -0,0 +1,23 @@ +#pragma once +#include "data_source.h" +#include "vars.h" +#include +#include + +using namespace std; +class DataSourceController { + + public: + DataSourceController(); + DataSourceController(vector); + + public: + void update(); + void test(); + void postProcess(); + void readSensor(); + void getValue(); + + vector ds; + +}; \ No newline at end of file diff --git a/include/game.h b/include/game.h new file mode 100644 index 0000000..0b02f40 --- /dev/null +++ b/include/game.h @@ -0,0 +1,21 @@ +#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" + +class Game{ + public: + Game(); + //void keeper(); + //void goalie(); + //void ballBack(); + bool role, attackGoal; //1->goalie 0->keeper, 1->yellow 0->blue + //~Game(); +}; \ No newline at end of file diff --git a/include/goalie.h b/include/goalie.h new file mode 100644 index 0000000..029fe32 --- /dev/null +++ b/include/goalie.h @@ -0,0 +1,13 @@ +#pragma once + +#include "game.h" + +class Goalie{ + + public: + Goalie(); + void goalie(); + void ballBack(); + //void rigore(); to be implemented + +}; diff --git a/include/keeper.h b/include/keeper.h new file mode 100644 index 0000000..527cd8d --- /dev/null +++ b/include/keeper.h @@ -0,0 +1,11 @@ +#pragma once + +#include "game.h" + +class Keeper{ + + public: + Keeper(); + void keeper(); + //void keeperGoalie(); to be implemented +}; \ No newline at end of file diff --git a/include/sensors.h b/include/sensors.h index 3057e06..0398e27 100644 --- a/include/sensors.h +++ b/include/sensors.h @@ -1,4 +1,5 @@ #include +#pragma once #include "data_source_bno055.h" #include "data_source_ball.h" #include "data_source_camera.h" @@ -7,23 +8,31 @@ #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 DataSource* compass; -extr DataSource* ball; -extr DataSource* camera; -extr DataSourceCtrl* usCtrl; -extr DataSourceCtrlLines* linesCtrl; -extr DriveController* drive; - extr vector lIn; extr vector lOut; extr vector dUs; + +extr DataSourceCtrl* usCtrl; +extr DataSourceCtrlLines* linesCtrl; + +extr DataSourceBNO055* compass; +extr DataSourceBall* ball; +extr DataSourceCamera* camera; +extr DriveController* drive; + +extr Game* game; +extr Goalie* goalie; +extr Keeper* keeper; diff --git a/src/game.cpp b/src/game.cpp new file mode 100644 index 0000000..04c054f --- /dev/null +++ b/src/game.cpp @@ -0,0 +1,29 @@ +#include "game.h" + +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(){ + +} */ diff --git a/src/goalie.cpp b/src/goalie.cpp new file mode 100644 index 0000000..d99cf56 --- /dev/null +++ b/src/goalie.cpp @@ -0,0 +1,22 @@ +#include "goalie.h" + +Goalie::Goalie(){ + +} + +void Goalie::goalie(){ + digitalWrite(LED_G, HIGH); + if(ball->ballSeen){ + if(ball->angle >= 0 && ball->angle < 45) drive->drive(ball->angle, 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); + } +} + +void Goalie::ballBack(){ + +} \ No newline at end of file diff --git a/src/keeper.cpp b/src/keeper.cpp new file mode 100644 index 0000000..667a7ce --- /dev/null +++ b/src/keeper.cpp @@ -0,0 +1,15 @@ +#include "keeper.h" + +Keeper::Keeper(){ + +} + +void Keeper::keeper(){ + digitalWrite(LED_Y, HIGH); + drive->prepareDrive(0, 0, 0); + drive->drive(0, 0, 0); +} + +/* void Keeper::keeperGoalie(){ + to be implemented +} */ \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index d31801d..77614af 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,8 +1,6 @@ #include -#include "vars.h" -#include "data_source_bno055.h" -#include "drivecontroller.h" -#include "sensors.h" + +#include "game.h" void setup() { @@ -21,4 +19,4 @@ void loop() { drive->drivePrepared(); -} \ No newline at end of file +} diff --git a/src/sensors.cpp b/src/sensors.cpp index c156675..4455aca 100644 --- a/src/sensors.cpp +++ b/src/sensors.cpp @@ -17,6 +17,10 @@ void initSensors(){ camera = new DataSourceCamera(&Serial2, 19200); usCtrl = new DataSourceCtrl(dUs); linesCtrl = new DataSourceCtrlLines(lIn, lOut); + + game = new Game(); + goalie = new Goalie(); + keeper = new Keeper(); } void updateSensors(){