merged code
commit
c3bb06f89d
|
@ -1,2 +1,4 @@
|
|||
# SPQR-Team-2020
|
||||
culo
|
||||
# SPQR1 2020
|
||||
|
||||
SPQR1 Team 2020 Robot project repo.
|
||||
Based in ITIS G. Galilei Rome
|
||||
|
|
|
@ -8,6 +8,6 @@ class DataSourceBall : public DataSource{
|
|||
void postProcess() override;
|
||||
void test() override;
|
||||
|
||||
int angle,distance;
|
||||
int angle, distance;
|
||||
bool ballSeen;
|
||||
};
|
|
@ -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;
|
||||
|
||||
};
|
|
@ -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();
|
||||
};
|
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "game.h"
|
||||
|
||||
class Goalie{
|
||||
|
||||
public:
|
||||
Goalie();
|
||||
void goalie();
|
||||
void ballBack();
|
||||
//void rigore(); to be implemented
|
||||
|
||||
};
|
|
@ -0,0 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include "game.h"
|
||||
|
||||
class Keeper{
|
||||
|
||||
public:
|
||||
Keeper();
|
||||
void keeper();
|
||||
//void keeperGoalie(); to be implemented
|
||||
};
|
|
@ -1,4 +1,5 @@
|
|||
#include <Arduino.h>
|
||||
#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<DataSource*> lIn;
|
||||
extr vector<DataSource*> lOut;
|
||||
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;
|
||||
|
|
|
@ -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(){
|
||||
|
||||
} */
|
|
@ -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(){
|
||||
|
||||
}
|
|
@ -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
|
||||
} */
|
|
@ -1,8 +1,6 @@
|
|||
#include <Arduino.h>
|
||||
#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();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(){
|
||||
|
|
Loading…
Reference in New Issue