organized code in 5 folders, left vars.h and main.cpp out of them for easy changing purposes. also did two currently_unused folder in sensors for us and things soon-to-be taken out from the robot (like v-shaped mirror)
parent
9afd6bf8b6
commit
cefd106a5e
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "data_source.h"
|
#include "behaviour_control/data_source.h"
|
||||||
#include "vars.h"
|
#include "vars.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <vector>
|
#include <vector>
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "game.h"
|
#include "strategy_roles/game.h"
|
||||||
#include "systems.h"
|
#include "position/systems.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* STATUS VECTOR:
|
* STATUS VECTOR:
|
7
include/drivecontroller.h → include/motors_movement/drivecontroller.h
Executable file → Normal file
7
include/drivecontroller.h → include/motors_movement/drivecontroller.h
Executable file → Normal file
|
@ -1,9 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "motor.h"
|
|
||||||
|
#include "behaviour_control/complementary_filter.h"
|
||||||
|
#include "motors_movement/motor.h"
|
||||||
|
|
||||||
#include "PID_v2.h"
|
#include "PID_v2.h"
|
||||||
#include "complementary_filter.h"
|
|
||||||
|
|
||||||
//PID Constants
|
//PID Constants
|
||||||
#define KP 1.5
|
#define KP 1.5
|
|
@ -1,10 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ds_ctrl.h"
|
|
||||||
#include "systems.h"
|
|
||||||
#include "vars.h"
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#include "behaviour_control/ds_ctrl.h"
|
||||||
|
#include "position/systems.h"
|
||||||
|
|
||||||
|
#include "vars.h"
|
||||||
|
|
||||||
#define S1I A14
|
#define S1I A14
|
||||||
#define S1O A15
|
#define S1O A15
|
||||||
#define S2I A16
|
#define S2I A16
|
|
@ -1,5 +1,6 @@
|
||||||
#include "PID_v2.h"
|
#include "PID_v2.h"
|
||||||
#include "systems.h"
|
|
||||||
|
#include "position/systems.h"
|
||||||
|
|
||||||
#define CAMERA_CENTER_X 0
|
#define CAMERA_CENTER_X 0
|
||||||
#define CAMERA_CENTER_Y -18
|
#define CAMERA_CENTER_Y -18
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "systems.h"
|
#include "position/systems.h"
|
||||||
|
|
||||||
//POSITION
|
//POSITION
|
||||||
#define CENTERGOALPOST_VEL1 220
|
#define CENTERGOALPOST_VEL1 220
|
|
@ -1,38 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SENSORS_CPP
|
|
||||||
#define s_extr
|
|
||||||
#else
|
|
||||||
#define s_extr extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include "data_source_bno055.h"
|
|
||||||
#include "data_source_ball.h"
|
|
||||||
#include "data_source_camera_conicmirror.h"
|
|
||||||
#include "data_source_camera_vshapedmirror.h"
|
|
||||||
#include "data_source_us.h"
|
|
||||||
#include "motor.h"
|
|
||||||
#include "ds_ctrl.h"
|
|
||||||
#include "drivecontroller.h"
|
|
||||||
#include "data_source_bt.h"
|
|
||||||
#include "systems.h"
|
|
||||||
#include "linesys_2019.h"
|
|
||||||
#include "positionsys_zone.h"
|
|
||||||
|
|
||||||
void initSensors();
|
|
||||||
void updateSensors();
|
|
||||||
|
|
||||||
s_extr vector<DataSource*> dUs;
|
|
||||||
|
|
||||||
s_extr DataSourceCtrl* usCtrl;
|
|
||||||
s_extr LineSys2019* linesCtrl;
|
|
||||||
|
|
||||||
s_extr DataSourceBNO055* compass;
|
|
||||||
s_extr DataSourceBall* ball;
|
|
||||||
s_extr DataSourceCameraConic* camera;
|
|
||||||
s_extr DriveController* drive;
|
|
||||||
s_extr DataSourceBT* bt;
|
|
||||||
|
|
||||||
s_extr int role;
|
|
2
include/data_source_us.h → include/sensors/currently_unused/data_source_us.h
Executable file → Normal file
2
include/data_source_us.h → include/sensors/currently_unused/data_source_us.h
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "data_source.h"
|
#include "behaviour_control/data_source.h"
|
||||||
|
|
||||||
#define US_WAIT_TIME 70
|
#define US_WAIT_TIME 70
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "data_source.h"
|
#include "behaviour_control/data_source.h"
|
||||||
|
|
||||||
class DataSourceBall : public DataSource{
|
class DataSourceBall : public DataSource{
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Adafruit_BNO055.h>
|
#include <Adafruit_BNO055.h>
|
||||||
#include "data_source.h"
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#include "behaviour_control/data_source.h"
|
||||||
|
|
||||||
#define DATA_CLOCK 10
|
#define DATA_CLOCK 10
|
||||||
|
|
||||||
class DataSourceBNO055 : public DataSource{
|
class DataSourceBNO055 : public DataSource{
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "data_source.h"
|
|
||||||
|
#include "behaviour_control/data_source.h"
|
||||||
#include "vars.h"
|
#include "vars.h"
|
||||||
|
|
||||||
class DataSourceBT : public DataSource{
|
class DataSourceBT : public DataSource{
|
2
include/data_source_camera_conicmirror.h → include/sensors/data_source_camera_conicmirror.h
Executable file → Normal file
2
include/data_source_camera_conicmirror.h → include/sensors/data_source_camera_conicmirror.h
Executable file → Normal file
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "data_source.h"
|
#include "behaviour_control/data_source.h"
|
||||||
|
|
||||||
#define startp 105
|
#define startp 105
|
||||||
#define endp 115
|
#define endp 115
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "data_source.h"
|
|
||||||
|
#include "behaviour_control/data_source.h"
|
||||||
|
|
||||||
class DataSourceCameraVShaped : public DataSource{
|
class DataSourceCameraVShaped : public DataSource{
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef SENSORS_CPP
|
||||||
|
#define s_extr
|
||||||
|
#else
|
||||||
|
#define s_extr extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#include "behaviour_control/ds_ctrl.h"
|
||||||
|
#include "motors_movement/drivecontroller.h"
|
||||||
|
#include "motors_movement/motor.h"
|
||||||
|
#include "position/linesys_2019.h"
|
||||||
|
#include "position/positionsys_zone.h"
|
||||||
|
#include "position/systems.h"
|
||||||
|
#include "sensors/data_source_ball.h"
|
||||||
|
#include "sensors/data_source_bt.h"
|
||||||
|
#include "sensors/data_source_bno055.h"
|
||||||
|
#include "sensors/data_source_camera_conicmirror.h"
|
||||||
|
#include "sensors/data_source_camera_vshapedmirror.h"
|
||||||
|
#include "sensors/currently_unused/data_source_us.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void initSensors();
|
||||||
|
void updateSensors();
|
||||||
|
|
||||||
|
s_extr vector<DataSource*> dUs;
|
||||||
|
|
||||||
|
s_extr DataSourceCtrl* usCtrl;
|
||||||
|
s_extr LineSys2019* linesCtrl;
|
||||||
|
|
||||||
|
s_extr DataSourceBNO055* compass;
|
||||||
|
s_extr DataSourceBall* ball;
|
||||||
|
s_extr DataSourceCameraConic* camera;
|
||||||
|
s_extr DriveController* drive;
|
||||||
|
s_extr DataSourceBT* bt;
|
||||||
|
|
||||||
|
s_extr int role;
|
|
@ -1,8 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "vars.h"
|
#include "vars.h"
|
||||||
#include "sensors.h"
|
#include "position/systems.h"
|
||||||
#include "systems.h"
|
#include "sensors/sensors.h"
|
||||||
|
|
||||||
class Game {
|
class Game {
|
||||||
public:
|
public:
|
|
@ -7,9 +7,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "game.h"
|
#include "strategy_roles/game.h"
|
||||||
#include "goalie.h"
|
#include "strategy_roles/goalie.h"
|
||||||
#include "keeper.h"
|
#include "strategy_roles/keeper.h"
|
||||||
|
|
||||||
void initGames();
|
void initGames();
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "game.h"
|
#include "sensors/data_source_camera_vshapedmirror.h"
|
||||||
#include "sensors.h"
|
#include "sensors/sensors.h"
|
||||||
#include "data_source_camera_vshapedmirror.h"
|
#include "strategy_roles/game.h"
|
||||||
|
|
||||||
#define TILT_MULT 1.8
|
#define TILT_MULT 1.8
|
||||||
#define TILT_DIST 180
|
#define TILT_DIST 180
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "game.h"
|
#include "strategy_roles/game.h"
|
||||||
|
|
||||||
#define KEEPER_ATTACK_DISTANCE 190
|
#define KEEPER_ATTACK_DISTANCE 190
|
||||||
#define KEEPER_ALONE_ATTACK_TIME 5000 //in millis
|
#define KEEPER_ALONE_ATTACK_TIME 5000 //in millis
|
|
@ -1,4 +1,4 @@
|
||||||
#include "complementary_filter.h"
|
#include "behaviour_control/complementary_filter.h"
|
||||||
|
|
||||||
ComplementaryFilter::ComplementaryFilter(float k){
|
ComplementaryFilter::ComplementaryFilter(float k){
|
||||||
this->K = k;
|
this->K = k;
|
|
@ -1,4 +1,4 @@
|
||||||
#include "data_source.h"
|
#include "behaviour_control/data_source.h"
|
||||||
|
|
||||||
DataSource::DataSource(void){
|
DataSource::DataSource(void){
|
||||||
protocol = P_NULL;
|
protocol = P_NULL;
|
|
@ -1,4 +1,4 @@
|
||||||
#include "ds_ctrl.h"
|
#include "behaviour_control/ds_ctrl.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#define STATUS_VECTOR_CPP
|
#define STATUS_VECTOR_CPP
|
||||||
#include "status_vector.h"
|
#include "behaviour_control/status_vector.h"
|
||||||
|
|
||||||
void initStatusVector(){
|
void initStatusVector(){
|
||||||
currentSVIndex = 0;
|
currentSVIndex = 0;
|
|
@ -1,9 +1,9 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "sensors.h"
|
#include "behaviour_control/status_vector.h"
|
||||||
#include "games.h"
|
#include "position/positionsys_zone.h"
|
||||||
#include "status_vector.h"
|
#include "sensors/sensors.h"
|
||||||
#include "positionsys_zone.h"
|
#include "strategy_roles/games.h"
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
delay(1500);
|
delay(1500);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "drivecontroller.h"
|
#include "motors_movement/drivecontroller.h"
|
||||||
#include "sensors.h"
|
#include "sensors/sensors.h"
|
||||||
#include "status_vector.h"
|
#include "behaviour_control/status_vector.h"
|
||||||
|
|
||||||
DriveController::DriveController(Motor* m1_, Motor* m2_, Motor* m3_, Motor* m4_){
|
DriveController::DriveController(Motor* m1_, Motor* m2_, Motor* m3_, Motor* m4_){
|
||||||
m1 = m1_;
|
m1 = m1_;
|
|
@ -1,4 +1,4 @@
|
||||||
#include "motor.h"
|
#include "motors_movement/motor.h"
|
||||||
#include "vars.h"
|
#include "vars.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "positionsys_camera.h"
|
#include "behaviour_control/status_vector.h"
|
||||||
#include "status_vector.h"
|
#include "position/positionsys_camera.h"
|
||||||
|
#include "sensors/sensors.h"
|
||||||
#include "vars.h"
|
#include "vars.h"
|
||||||
#include "sensors.h"
|
|
||||||
|
|
||||||
PositionSysCamera::PositionSysCamera() {
|
PositionSysCamera::PositionSysCamera() {
|
||||||
setCameraPID();
|
setCameraPID();
|
|
@ -1,7 +1,7 @@
|
||||||
#include "positionsys_zone.h"
|
#include "behaviour_control/status_vector.h"
|
||||||
|
#include "position/positionsys_zone.h"
|
||||||
|
#include "sensors/sensors.h"
|
||||||
#include "vars.h"
|
#include "vars.h"
|
||||||
#include "sensors.h"
|
|
||||||
#include "status_vector.h"
|
|
||||||
|
|
||||||
PositionSysZone::PositionSysZone(){
|
PositionSysZone::PositionSysZone(){
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
4
src/data_source_us.cpp → src/sensors/currently_unused/data_source_us.cpp
Executable file → Normal file
4
src/data_source_us.cpp → src/sensors/currently_unused/data_source_us.cpp
Executable file → Normal file
|
@ -1,6 +1,6 @@
|
||||||
#include "data_source_us.h"
|
#include "behaviour_control/status_vector.h"
|
||||||
|
#include "sensors/currently_unused/data_source_us.h"
|
||||||
#include "vars.h"
|
#include "vars.h"
|
||||||
#include "status_vector.h"
|
|
||||||
|
|
||||||
|
|
||||||
DataSourceUS::DataSourceUS(TwoWire* i2c_, int addr) : DataSource(i2c_, addr){
|
DataSourceUS::DataSourceUS(TwoWire* i2c_, int addr) : DataSource(i2c_, addr){
|
|
@ -1,6 +1,6 @@
|
||||||
#include "data_source_ball.h"
|
#include "behaviour_control/status_vector.h"
|
||||||
|
#include "sensors/data_source_ball.h"
|
||||||
#include "vars.h"
|
#include "vars.h"
|
||||||
#include "status_vector.h"
|
|
||||||
|
|
||||||
DataSourceBall :: DataSourceBall(HardwareSerial* ser_, int baud) : DataSource(ser_, baud) {
|
DataSourceBall :: DataSourceBall(HardwareSerial* ser_, int baud) : DataSource(ser_, baud) {
|
||||||
ballSeen = false;
|
ballSeen = false;
|
|
@ -1,5 +1,5 @@
|
||||||
#include "data_source_bno055.h"
|
#include "behaviour_control/status_vector.h"
|
||||||
#include "status_vector.h"
|
#include "sensors/data_source_bno055.h"
|
||||||
|
|
||||||
//bool loaded = false;
|
//bool loaded = false;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "data_source_bt.h"
|
#include "sensors/data_source_bt.h"
|
||||||
|
|
||||||
DataSourceBT :: DataSourceBT(HardwareSerial* ser_, int baud) : DataSource(ser_, baud){
|
DataSourceBT :: DataSourceBT(HardwareSerial* ser_, int baud) : DataSource(ser_, baud){
|
||||||
// connect();
|
// connect();
|
6
src/data_source_camera_conicmirror.cpp → src/sensors/data_source_camera_conicmirror.cpp
Executable file → Normal file
6
src/data_source_camera_conicmirror.cpp → src/sensors/data_source_camera_conicmirror.cpp
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
||||||
#include "data_source_camera_conicmirror.h"
|
#include "behaviour_control/status_vector.h"
|
||||||
#include "status_vector.h"
|
#include "sensors/data_source_camera_conicmirror.h"
|
||||||
|
|
||||||
DataSourceCameraConic::DataSourceCameraConic(HardwareSerial *ser_, int baud) : DataSource(ser_, baud)
|
DataSourceCameraConic::DataSourceCameraConic(HardwareSerial *ser_, int baud) : DataSource(ser_, baud)
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ void DataSourceCameraConic ::readSensor() {
|
||||||
count = 0;
|
count = 0;
|
||||||
} else if (value == endp) {
|
} else if (value == endp) {
|
||||||
data_received = false;
|
data_received = false;
|
||||||
if (count = 4 && start == true) {
|
if ((count = 4) && (start == true)) {
|
||||||
data_received = true;
|
data_received = true;
|
||||||
|
|
||||||
true_xb = xb - 50;
|
true_xb = xb - 50;
|
|
@ -1,6 +1,6 @@
|
||||||
#include "data_source_camera_vshapedmirror.h"
|
#include "behaviour_control/status_vector.h"
|
||||||
#include "sensors.h"
|
#include "sensors/data_source_camera_vshapedmirror.h"
|
||||||
#include "status_vector.h"
|
#include "sensors/sensors.h"
|
||||||
|
|
||||||
|
|
||||||
DataSourceCameraVShaped::DataSourceCameraVShaped(HardwareSerial* ser_, int baud) : DataSource(ser_, baud){}
|
DataSourceCameraVShaped::DataSourceCameraVShaped(HardwareSerial* ser_, int baud) : DataSource(ser_, baud){}
|
|
@ -1,5 +1,5 @@
|
||||||
#include "linesys_2019.h"
|
#include "position/linesys_2019.h"
|
||||||
#include "sensors.h"
|
#include "sensors/sensors.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
LineSys2019::LineSys2019() {}
|
LineSys2019::LineSys2019() {}
|
|
@ -1,5 +1,5 @@
|
||||||
#define SENSORS_CPP
|
#define SENSORS_CPP
|
||||||
#include "sensors.h"
|
#include "sensors/sensors.h"
|
||||||
|
|
||||||
void initSensors(){
|
void initSensors(){
|
||||||
pinMode(SWITCH_DX, INPUT);
|
pinMode(SWITCH_DX, INPUT);
|
|
@ -1,5 +1,5 @@
|
||||||
#include "game.h"
|
#include "behaviour_control/status_vector.h"
|
||||||
#include "status_vector.h"
|
#include "strategy_roles/game.h"
|
||||||
|
|
||||||
Game::Game() {}
|
Game::Game() {}
|
||||||
Game::Game(LineSystem* ls_, PositionSystem* ps_) {
|
Game::Game(LineSystem* ls_, PositionSystem* ps_) {
|
|
@ -1,9 +1,9 @@
|
||||||
#define GAMES_CPP
|
#define GAMES_CPP
|
||||||
|
|
||||||
#include "games.h"
|
#include "position/linesys_2019.h"
|
||||||
#include "linesys_2019.h"
|
#include "position/positionsys_zone.h"
|
||||||
#include "positionsys_zone.h"
|
#include "position/positionsys_camera.h"
|
||||||
#include "positionsys_camera.h"
|
#include "strategy_roles/games.h"
|
||||||
|
|
||||||
void initGames(){
|
void initGames(){
|
||||||
vector<DataSource*> lIn = { new DataSource(S1I, true), new DataSource(S2I, true), new DataSource(S3I, true), new DataSource(S4I, true) };
|
vector<DataSource*> lIn = { new DataSource(S1I, true), new DataSource(S2I, true), new DataSource(S3I, true), new DataSource(S4I, true) };
|
|
@ -1,9 +1,11 @@
|
||||||
#include "goalie.h"
|
#include "behaviour_control/status_vector.h"
|
||||||
#include "sensors.h"
|
#include "position/positionsys_camera.h"
|
||||||
|
#include "sensors/sensors.h"
|
||||||
|
#include "strategy_roles/goalie.h"
|
||||||
#include "vars.h"
|
#include "vars.h"
|
||||||
#include "status_vector.h"
|
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include "positionsys_camera.h"
|
|
||||||
|
|
||||||
Goalie::Goalie() : Game() {
|
Goalie::Goalie() : Game() {
|
||||||
init();
|
init();
|
|
@ -1,9 +1,11 @@
|
||||||
#include "keeper.h"
|
|
||||||
#include "sensors.h"
|
|
||||||
#include "games.h"
|
|
||||||
#include "linesys_2019.h"
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "status_vector.h"
|
|
||||||
|
#include "behaviour_control/status_vector.h"
|
||||||
|
#include "position/linesys_2019.h"
|
||||||
|
#include "sensors/sensors.h"
|
||||||
|
#include "strategy_roles/keeper.h"
|
||||||
|
#include "strategy_roles/games.h"
|
||||||
|
|
||||||
|
|
||||||
Keeper::Keeper() : Game() {
|
Keeper::Keeper() : Game() {
|
||||||
init();
|
init();
|
Loading…
Reference in New Issue