From 6db65be3df7161f142942a3a9868e8cdfa82e4e0 Mon Sep 17 00:00:00 2001 From: EmaMaker Date: Mon, 2 Dec 2019 14:59:55 +0100 Subject: [PATCH 1/8] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f069b22..ee31603 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ -# SPQR-Team-2020 -culo +# SPQR1 2020 + +SPQR1 Team 2020, based in ITIS G. Galilei Rome From 2eb40084c7aaf1a2f0d2a9278e9b3d8014475033 Mon Sep 17 00:00:00 2001 From: EmaMaker Date: Mon, 2 Dec 2019 15:00:17 +0100 Subject: [PATCH 2/8] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ee31603..662ed5d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ # SPQR1 2020 -SPQR1 Team 2020, based in ITIS G. Galilei Rome +SPQR1 Team 2020 Robot project repo. +Based in ITIS G. Galilei Rome From c346312bc90e00f0dd13096a1b6acc006cde35a5 Mon Sep 17 00:00:00 2001 From: Siria Date: Mon, 2 Dec 2019 17:25:22 +0100 Subject: [PATCH 3/8] having troubles testing --- include/data_source_ball.h | 2 +- include/data_source_controller.h | 1 + include/game.h | 18 ++++++++++++++++++ include/sensors.h | 11 +++++++---- src/game.cpp | 21 +++++++++++++++++++++ src/main.cpp | 12 +++++++----- src/sensors.cpp | 2 ++ 7 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 include/game.h create mode 100644 src/game.cpp 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 index 90b6c3c..e83332f 100644 --- a/include/data_source_controller.h +++ b/include/data_source_controller.h @@ -1,3 +1,4 @@ +#pragma once #include "data_source.h" #include "vars.h" #include diff --git a/include/game.h b/include/game.h new file mode 100644 index 0000000..8eaf387 --- /dev/null +++ b/include/game.h @@ -0,0 +1,18 @@ +#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" + +class Game{ + public: + Game(); + void keeper(); + void goalie(); + bool role, attackGoal; //1->goalie 0->keeper, 1->yellow 0->blue + //~Game(); +}; \ No newline at end of file diff --git a/include/sensors.h b/include/sensors.h index b5e1ad1..7ded117 100644 --- a/include/sensors.h +++ b/include/sensors.h @@ -6,19 +6,22 @@ #include "motor.h" #include "data_source_controller.h" #include "drivecontroller.h" - +#pragma once +#include "game.h" #ifdef SENSORS_CPP #define extr #else #define extr extern #endif +class Game; void initSensors(); void updateSensors(); -extr DataSource* compass; -extr DataSource* ball; -extr DataSource* camera; +extr DataSourceBNO055* compass; +extr DataSourceBall* ball; +extr DataSourceCamera* camera; //extr DataSource* us; extr DataSourceController* usCtrl; extr DriveController* drive; +extr Game* game; \ No newline at end of file diff --git a/src/game.cpp b/src/game.cpp new file mode 100644 index 0000000..05c974f --- /dev/null +++ b/src/game.cpp @@ -0,0 +1,21 @@ +#include "game.h" + +Game::Game(){ + +} + +void Game::goalie(){ + digitalWrite(LED_G, HIGH); + //if(ball->ballSeen){ + //if(ball->angle >= 0) { + drive->prepareDrive(0, 150, 0); + drive->drive(0, 150, 0); + //} + //} else drive->prepareDrive(0, 0, 0); +} + +void Game::keeper(){ + digitalWrite(LED_Y, HIGH); +} + + diff --git a/src/main.cpp b/src/main.cpp index cc0a32e..95f1375 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() { @@ -17,6 +15,10 @@ void loop() { updateSensors(); /*if(millis() % 100 == 0) DEBUG_PRINT.println(us->getValue());*/ - usCtrl->test(); + if(game->role) game->goalie(); + else game->keeper(); + game->role = digitalRead(SWITCH_DX); + game->attackGoal = digitalRead(SWITCH_SX); + //usCtrl->test(); delay(200); } \ No newline at end of file diff --git a/src/sensors.cpp b/src/sensors.cpp index b14aeec..c262ef9 100644 --- a/src/sensors.cpp +++ b/src/sensors.cpp @@ -12,6 +12,8 @@ void initSensors(){ ball = new DataSourceBall(&Serial4, 57600); camera = new DataSourceCamera(&Serial2, 19200); usCtrl = new DataSourceController(dUs); + + game = new Game(); } void updateSensors(){ From e1b50fcf03a1e8c9d6a1324c4678c48c01a11fd9 Mon Sep 17 00:00:00 2001 From: u-siri-ous Date: Mon, 2 Dec 2019 16:59:20 +0100 Subject: [PATCH 4/8] going straight...slowly --- src/game.cpp | 14 ++++++++------ src/main.cpp | 8 +++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 05c974f..527fbd2 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -5,16 +5,18 @@ Game::Game(){ } void Game::goalie(){ + compass->readSensor(); digitalWrite(LED_G, HIGH); - //if(ball->ballSeen){ - //if(ball->angle >= 0) { - drive->prepareDrive(0, 150, 0); - drive->drive(0, 150, 0); - //} - //} else drive->prepareDrive(0, 0, 0); + if(ball->ballSeen){ + if(ball->angle >= 0) { + drive->prepareDrive(0, 50, 0); + drive->drive(0, 50, 0); + } + } else drive->prepareDrive(0, 0, 0); } void Game::keeper(){ + compass->readSensor(); digitalWrite(LED_Y, HIGH); } diff --git a/src/main.cpp b/src/main.cpp index 95f1375..5084296 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,13 +12,15 @@ void setup() { } void loop() { - updateSensors(); + //updateSensors(); /*if(millis() % 100 == 0) DEBUG_PRINT.println(us->getValue());*/ - if(game->role) game->goalie(); - else game->keeper(); + /* if(game->role) game->goalie(); + else game->keeper(); */ + game->goalie(); game->role = digitalRead(SWITCH_DX); game->attackGoal = digitalRead(SWITCH_SX); + //compass->test(); //usCtrl->test(); delay(200); } \ No newline at end of file From e11b061226b5d83fd321db161d5fec53a299167c Mon Sep 17 00:00:00 2001 From: u-siri-ous Date: Mon, 2 Dec 2019 17:47:03 +0100 Subject: [PATCH 5/8] ao --- src/game.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 527fbd2..aa8be28 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -6,18 +6,22 @@ Game::Game(){ void Game::goalie(){ compass->readSensor(); + //drive->prepareDrive(0, 150, 0); digitalWrite(LED_G, HIGH); if(ball->ballSeen){ - if(ball->angle >= 0) { - drive->prepareDrive(0, 50, 0); - drive->drive(0, 50, 0); + if(ball->angle >= 0) drive->drive(0, 100, 0); + else if(ball->angle <= 45) drive->drive(45, 100, 0); + } else { + drive->prepareDrive(0, 0, 0); + drive->drive(0, 0, 0); } - } else drive->prepareDrive(0, 0, 0); } void Game::keeper(){ compass->readSensor(); digitalWrite(LED_Y, HIGH); + drive->prepareDrive(0, 0, 0); + drive->drive(0, 0, 0); } From db244dd35ce702f5cce077b0a2569e314e610ce2 Mon Sep 17 00:00:00 2001 From: u-siri-ous Date: Tue, 3 Dec 2019 11:22:42 +0100 Subject: [PATCH 6/8] ema scemo --- src/data_source_us.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/data_source_us.cpp b/src/data_source_us.cpp index a214de9..637af38 100644 --- a/src/data_source_us.cpp +++ b/src/data_source_us.cpp @@ -93,5 +93,4 @@ void DataSourceUS::usReceive() { // receive low byte as lower 8 bit reading |= i2c->read(); value = reading; - DEBUG_PRINT.println(reading); } \ No newline at end of file From 75610d3dde07ae8a358d2f12cde1c8035482cea6 Mon Sep 17 00:00:00 2001 From: u-siri-ous Date: Wed, 4 Dec 2019 17:25:25 +0100 Subject: [PATCH 7/8] first trial to follow the ball --- include/game.h | 1 + src/game.cpp | 11 +++++++++-- src/main.cpp | 8 ++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/game.h b/include/game.h index 8eaf387..4421355 100644 --- a/include/game.h +++ b/include/game.h @@ -13,6 +13,7 @@ class Game{ 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/src/game.cpp b/src/game.cpp index aa8be28..b71998c 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -9,8 +9,11 @@ void Game::goalie(){ //drive->prepareDrive(0, 150, 0); digitalWrite(LED_G, HIGH); if(ball->ballSeen){ - if(ball->angle >= 0) drive->drive(0, 100, 0); - else if(ball->angle <= 45) drive->drive(45, 100, 0); + if(ball->angle >= 0 && ball->angle <= 45) drive->drive(0, 75, 0); + //else if(ball->angle <= 45) drive->drive(45, 75, 0); + else if(ball->angle > 45 && ball->angle <= 90) drive->drive(90, 75, 0); + //else if(ball->angle <= 135) drive->drive(135, 75, 0); + else if(ball->angle > 90 && ball->angle <= 180) drive->drive(180, 75, 0); } else { drive->prepareDrive(0, 0, 0); drive->drive(0, 0, 0); @@ -24,4 +27,8 @@ void Game::keeper(){ drive->drive(0, 0, 0); } +void ballBack(){ + +} + diff --git a/src/main.cpp b/src/main.cpp index 5084296..4cc77e7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,12 +15,12 @@ void loop() { //updateSensors(); /*if(millis() % 100 == 0) DEBUG_PRINT.println(us->getValue());*/ - /* if(game->role) game->goalie(); - else game->keeper(); */ - game->goalie(); game->role = digitalRead(SWITCH_DX); game->attackGoal = digitalRead(SWITCH_SX); + if(game->role) game->goalie(); + else game->keeper(); + //game->goalie(); + //drive->drivePrepared(); //compass->test(); //usCtrl->test(); - delay(200); } \ No newline at end of file From f3e49b2a7af55e84e259cc8785d02b71a26498ac Mon Sep 17 00:00:00 2001 From: u-siri-ous Date: Thu, 5 Dec 2019 11:50:58 +0100 Subject: [PATCH 8/8] started writing goalie(), kinda dumb but seems to work --- include/game.h | 8 +++++--- include/goalie.h | 13 +++++++++++++ include/keeper.h | 11 +++++++++++ include/sensors.h | 9 +++++++-- src/game.cpp | 19 +++++++------------ src/goalie.cpp | 22 ++++++++++++++++++++++ src/keeper.cpp | 15 +++++++++++++++ src/main.cpp | 10 +++++----- src/sensors.cpp | 2 ++ 9 files changed, 87 insertions(+), 22 deletions(-) create mode 100644 include/goalie.h create mode 100644 include/keeper.h create mode 100644 src/goalie.cpp create mode 100644 src/keeper.cpp diff --git a/include/game.h b/include/game.h index 4421355..0b02f40 100644 --- a/include/game.h +++ b/include/game.h @@ -7,13 +7,15 @@ #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(); + //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 7ded117..bd98eb6 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" @@ -6,7 +7,6 @@ #include "motor.h" #include "data_source_controller.h" #include "drivecontroller.h" -#pragma once #include "game.h" #ifdef SENSORS_CPP #define extr @@ -15,6 +15,8 @@ #endif class Game; +class Goalie; +class Keeper; void initSensors(); void updateSensors(); @@ -24,4 +26,7 @@ extr DataSourceCamera* camera; //extr DataSource* us; extr DataSourceController* usCtrl; extr DriveController* drive; -extr Game* game; \ No newline at end of file + +extr Game* game; +extr Goalie* goalie; +extr Keeper* keeper; \ No newline at end of file diff --git a/src/game.cpp b/src/game.cpp index b71998c..04c054f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -4,16 +4,14 @@ Game::Game(){ } -void Game::goalie(){ - compass->readSensor(); - //drive->prepareDrive(0, 150, 0); +/* 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) drive->drive(45, 75, 0); - else if(ball->angle > 45 && ball->angle <= 90) drive->drive(90, 75, 0); - //else if(ball->angle <= 135) drive->drive(135, 75, 0); - else if(ball->angle > 90 && ball->angle <= 180) drive->drive(180, 75, 0); + 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); @@ -21,7 +19,6 @@ void Game::goalie(){ } void Game::keeper(){ - compass->readSensor(); digitalWrite(LED_Y, HIGH); drive->prepareDrive(0, 0, 0); drive->drive(0, 0, 0); @@ -29,6 +26,4 @@ void Game::keeper(){ 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 4cc77e7..103da14 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,14 +12,14 @@ void setup() { } void loop() { - //updateSensors(); + updateSensors(); /*if(millis() % 100 == 0) DEBUG_PRINT.println(us->getValue());*/ - game->role = digitalRead(SWITCH_DX); + /* game->role = digitalRead(SWITCH_DX); game->attackGoal = digitalRead(SWITCH_SX); - if(game->role) game->goalie(); - else game->keeper(); - //game->goalie(); + if(game->role) goalie->goalie(); + else keeper->keeper(); */ + goalie->goalie(); //drive->drivePrepared(); //compass->test(); //usCtrl->test(); diff --git a/src/sensors.cpp b/src/sensors.cpp index c262ef9..55e09a0 100644 --- a/src/sensors.cpp +++ b/src/sensors.cpp @@ -14,6 +14,8 @@ void initSensors(){ usCtrl = new DataSourceController(dUs); game = new Game(); + goalie = new Goalie(); + keeper = new Keeper(); } void updateSensors(){