merged code

pull/1/head
EmaMaker 2019-12-05 11:57:18 +01:00
commit c3bb06f89d
12 changed files with 163 additions and 16 deletions

View File

@ -1,2 +1,4 @@
# SPQR-Team-2020 # SPQR1 2020
culo
SPQR1 Team 2020 Robot project repo.
Based in ITIS G. Galilei Rome

View File

@ -0,0 +1,23 @@
#pragma once
#include "data_source.h"
#include "vars.h"
#include <Arduino.h>
#include <vector>
using namespace std;
class DataSourceController {
public:
DataSourceController();
DataSourceController(vector<DataSource*>);
public:
void update();
void test();
void postProcess();
void readSensor();
void getValue();
vector<DataSource*> ds;
};

21
include/game.h Normal file
View File

@ -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();
};

13
include/goalie.h Normal file
View File

@ -0,0 +1,13 @@
#pragma once
#include "game.h"
class Goalie{
public:
Goalie();
void goalie();
void ballBack();
//void rigore(); to be implemented
};

11
include/keeper.h Normal file
View File

@ -0,0 +1,11 @@
#pragma once
#include "game.h"
class Keeper{
public:
Keeper();
void keeper();
//void keeperGoalie(); to be implemented
};

View File

@ -1,4 +1,5 @@
#include <Arduino.h> #include <Arduino.h>
#pragma once
#include "data_source_bno055.h" #include "data_source_bno055.h"
#include "data_source_ball.h" #include "data_source_ball.h"
#include "data_source_camera.h" #include "data_source_camera.h"
@ -7,23 +8,31 @@
#include "motor.h" #include "motor.h"
#include "ds_ctrl.h" #include "ds_ctrl.h"
#include "drivecontroller.h" #include "drivecontroller.h"
#include "game.h"
#ifdef SENSORS_CPP #ifdef SENSORS_CPP
#define extr #define extr
#else #else
#define extr extern #define extr extern
#endif #endif
class Game;
class Goalie;
class Keeper;
void initSensors(); void initSensors();
void updateSensors(); void updateSensors();
extr DataSource* compass;
extr DataSource* ball;
extr DataSource* camera;
extr DataSourceCtrl* usCtrl;
extr DataSourceCtrlLines* linesCtrl;
extr DriveController* drive;
extr vector<DataSource*> lIn; extr vector<DataSource*> lIn;
extr vector<DataSource*> lOut; extr vector<DataSource*> lOut;
extr vector<DataSource*> dUs; extr vector<DataSource*> 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;

29
src/game.cpp Normal file
View File

@ -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(){
} */

22
src/goalie.cpp Normal file
View File

@ -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(){
}

15
src/keeper.cpp Normal file
View File

@ -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
} */

View File

@ -1,8 +1,6 @@
#include <Arduino.h> #include <Arduino.h>
#include "vars.h"
#include "data_source_bno055.h" #include "game.h"
#include "drivecontroller.h"
#include "sensors.h"
void setup() { void setup() {

View File

@ -17,6 +17,10 @@ void initSensors(){
camera = new DataSourceCamera(&Serial2, 19200); camera = new DataSourceCamera(&Serial2, 19200);
usCtrl = new DataSourceCtrl(dUs); usCtrl = new DataSourceCtrl(dUs);
linesCtrl = new DataSourceCtrlLines(lIn, lOut); linesCtrl = new DataSourceCtrlLines(lIn, lOut);
game = new Game();
goalie = new Goalie();
keeper = new Keeper();
} }
void updateSensors(){ void updateSensors(){