2020-02-05 18:57:11 +01:00
|
|
|
#pragma once
|
|
|
|
#include <Arduino.h>
|
2020-02-29 22:10:53 +01:00
|
|
|
#include "strategy_roles/game.h"
|
2020-11-04 17:46:14 +01:00
|
|
|
#include "systems/systems.h"
|
2020-02-05 18:57:11 +01:00
|
|
|
|
2020-02-12 21:43:20 +01:00
|
|
|
/**
|
|
|
|
* STATUS VECTOR:
|
|
|
|
* The status vector consists in two arrays of two different structs.
|
|
|
|
* One (inputs) holds the raw input read by the various sensors on the robot
|
|
|
|
* The other (datas) contains the useful data obtained by the eventual manipulation of the raw inputs
|
|
|
|
* This is made so that it ha an history of the inputs and datas if needed.
|
|
|
|
* This is an intermediator between all the classes representing the different components of the robot. It's preferable to not make the classes call one another
|
|
|
|
* All the data held by the structs in the status vector will be described here.
|
|
|
|
*
|
|
|
|
* REMEMBER: The value of a sensor in the status vector MUST be updated also if the sensor data didn't change
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
|
2020-02-05 19:46:57 +01:00
|
|
|
#ifdef STATUS_VECTOR_CPP
|
|
|
|
#define sv_extr
|
|
|
|
#else
|
|
|
|
#define sv_extr extern
|
|
|
|
#endif
|
|
|
|
|
2021-05-10 20:34:20 +02:00
|
|
|
#define dim 50
|
2020-02-12 21:43:20 +01:00
|
|
|
#define CURRENT_DATA_READ ( datas[((currentSVIndex-1+dim) % dim)] )
|
|
|
|
#define CURRENT_DATA_WRITE ( datas[((currentSVIndex))] )
|
|
|
|
#define CURRENT_INPUT_READ ( inputs[((currentSVIndex-1+dim) % dim)] )
|
|
|
|
#define CURRENT_INPUT_WRITE ( inputs[((currentSVIndex))] )
|
2020-02-05 19:46:57 +01:00
|
|
|
|
2020-02-05 18:57:11 +01:00
|
|
|
typedef struct input{
|
2021-06-07 12:06:08 +02:00
|
|
|
int IMUAngle, USfr, USsx, USdx, USrr, BT, ballPresenceVal;
|
2021-05-29 15:19:41 +02:00
|
|
|
byte cameraByte, ballByte, lineByte, xb, yb, xy, yy;
|
2020-02-05 18:57:11 +01:00
|
|
|
bool SW_DX, SW_SX;
|
2021-05-29 15:19:41 +02:00
|
|
|
String ballString;
|
2020-02-05 18:57:11 +01:00
|
|
|
}input;
|
|
|
|
|
|
|
|
typedef struct data{
|
2021-06-25 08:41:30 +02:00
|
|
|
int IMUAngle = 0, IMUOffset = 0, ballAngle = 0, ballAngleFix, ballDistance, ballPresenceVal,
|
2020-02-21 13:37:32 +01:00
|
|
|
yAngle, bAngle, yAngleFix, bAngleFix,
|
|
|
|
yDist, bDist,
|
2021-06-22 18:18:00 +02:00
|
|
|
angleAtk, angleAtkFix, angleDef, angleDefFix, distAtk, distDef, yAtk, yAtkFix, xAtk, xAtkFix, yDef, yDefFix, xDef, xDefFix,
|
2021-06-25 20:46:03 +02:00
|
|
|
cam_xb = 0, cam_yb = 0, cam_xy = 0, cam_yy = 0,
|
2020-02-21 13:37:32 +01:00
|
|
|
speed, tilt, dir, axisBlock[4],
|
|
|
|
USfr, USsx, USdx, USrr,
|
2021-06-25 20:46:03 +02:00
|
|
|
lineOutDir, matePos, role, cam_xb_fixed = 0,
|
|
|
|
cam_xy_fixed = 0, cam_yb_fixed = 0, cam_yy_fixed = 0,
|
2020-03-12 12:09:13 +01:00
|
|
|
posx, posy, addvx, addvy;
|
2020-02-18 09:37:36 +01:00
|
|
|
Game* game;
|
|
|
|
LineSystem* lineSystem;
|
|
|
|
PositionSystem* posSystem;
|
2020-02-26 16:00:26 +01:00
|
|
|
byte lineSeen, lineActive;
|
2020-02-21 13:37:32 +01:00
|
|
|
bool mate,
|
|
|
|
ATKgoal, DEFgoal,
|
2021-06-25 20:46:03 +02:00
|
|
|
atkSeen, defSeen, bSeen = true, ySeen = false,
|
2021-06-07 12:06:08 +02:00
|
|
|
ballSeen, ballPresent;
|
2020-02-05 18:57:11 +01:00
|
|
|
}data;
|
|
|
|
|
2020-02-05 19:46:57 +01:00
|
|
|
sv_extr input inputs[dim];
|
|
|
|
sv_extr data datas[dim];
|
|
|
|
sv_extr int currentSVIndex;
|
|
|
|
|
|
|
|
void initStatusVector();
|
2021-05-10 20:34:20 +02:00
|
|
|
void updateStatusVector();
|
|
|
|
data getDataAtIndex(int index);
|
|
|
|
data getDataAtIndex_backwardsFromCurrent(int steps);
|