ported goalie and keeper from old code, condtion code working to decide game strategy
parent
c6856fdbce
commit
20b3aa1b0c
|
@ -15,8 +15,8 @@ class DriveController{
|
|||
|
||||
DriveController(Motor* m1_, Motor* m2_, Motor* m3_, Motor* m4_);
|
||||
|
||||
void drive(int dir, int speed, int tilt);
|
||||
void prepareDrive(int dir, int speed, int tilt);
|
||||
void drive(int dir=0, int speed=0, int tilt=0);
|
||||
void prepareDrive(int dir=0, int speed=0, int tilt=0);
|
||||
void drivePrepared();
|
||||
float updatePid();
|
||||
float torad(float f);
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
#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"
|
||||
#include "sensors.h"
|
||||
|
||||
class Game{
|
||||
class Game {
|
||||
public:
|
||||
Game();
|
||||
//void keeper();
|
||||
//void goalie();
|
||||
//void ballBack();
|
||||
bool role, attackGoal; //1->goalie 0->keeper, 1->yellow 0->blue
|
||||
//~Game();
|
||||
void play(bool condition=true);
|
||||
private:
|
||||
virtual void realPlay() = 0;
|
||||
};
|
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef GAMES_CPP
|
||||
#define g_extr
|
||||
#else
|
||||
#define g_extr extern
|
||||
#endif
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "game.h"
|
||||
#include "goalie.h"
|
||||
#include "keeper.h"
|
||||
|
||||
void initGames();
|
||||
|
||||
g_extr Game* goalie;
|
||||
g_extr Game* keeper;
|
|
@ -1,8 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "game.h"
|
||||
#include "sensors.h"
|
||||
#include "data_source_camera.h"
|
||||
|
||||
/* #define GOALIE_ATKSPD_LAT 255
|
||||
#define GOALIE_ATKSPD_LAT 255
|
||||
#define GOALIE_ATKSPD_BAK 350
|
||||
#define GOALIE_ATKSPD_FRT 345
|
||||
#define GOALIE_ATKSPD_STRK 355
|
||||
|
@ -12,14 +14,18 @@
|
|||
#define GOALIE_ATKDIR_PLUSANGBAK 40
|
||||
#define GOALIE_ATKDIR_PLUSANG1_COR 60
|
||||
#define GOALIE_ATKDIR_PLUSANG2_COR 70
|
||||
#define GOALIE_ATKDIR_PLUSANG3_COR 70 */
|
||||
#define GOALIE_ATKDIR_PLUSANG3_COR 70
|
||||
|
||||
class Goalie{
|
||||
class Goalie : public Game{
|
||||
|
||||
public:
|
||||
Goalie();
|
||||
|
||||
void realPlay() override;
|
||||
void goalie();
|
||||
void ballBack();
|
||||
//void rigore(); to be implemented
|
||||
int atk_direction, atk_speed;
|
||||
void storcimentoPorta();
|
||||
|
||||
int atk_speed, atk_direction;
|
||||
float cstorc;
|
||||
};
|
||||
|
|
|
@ -2,10 +2,26 @@
|
|||
|
||||
#include "game.h"
|
||||
|
||||
class Keeper{
|
||||
//KEEPER
|
||||
#define KEEPER_ATTACK_DISTANCE 200
|
||||
#define KEEPER_ALONE_ATTACK_TIME 5000 //in millis
|
||||
#define KEEPER_COMRADE_ATTACK_TIME 3000//in millis
|
||||
#define KEEPER_BASE_VEL 320
|
||||
#define KEEPER_VEL_MULT 1.4
|
||||
#define KEEPER_BALL_BACK_ANGLE 30
|
||||
|
||||
|
||||
class Keeper : public Game{
|
||||
|
||||
public:
|
||||
Keeper();
|
||||
private:
|
||||
void realPlay() override;
|
||||
void keeper();
|
||||
//void keeperGoalie(); to be implemented
|
||||
};
|
||||
|
||||
int defSpeed, defDir;
|
||||
|
||||
float angle, angleX, angleY;
|
||||
elapsedMillis t, toh, keeperAttackTimer;
|
||||
bool keeper_tookTimer, keeper_backToGoalPost;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
#include <Arduino.h>
|
||||
#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.h"
|
||||
|
@ -8,31 +16,20 @@
|
|||
#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 vector<DataSource*> lIn;
|
||||
extr vector<DataSource*> lOut;
|
||||
extr vector<DataSource*> dUs;
|
||||
s_extr vector<DataSource*> lIn;
|
||||
s_extr vector<DataSource*> lOut;
|
||||
s_extr vector<DataSource*> dUs;
|
||||
|
||||
extr DataSourceCtrl* usCtrl;
|
||||
extr DataSourceCtrlLines* linesCtrl;
|
||||
s_extr DataSourceCtrl* usCtrl;
|
||||
s_extr DataSourceCtrlLines* linesCtrl;
|
||||
|
||||
extr DataSourceBNO055* compass;
|
||||
extr DataSourceBall* ball;
|
||||
extr DataSourceCamera* camera;
|
||||
extr DriveController* drive;
|
||||
s_extr DataSourceBNO055* compass;
|
||||
s_extr DataSourceBall* ball;
|
||||
s_extr DataSourceCamera* camera;
|
||||
s_extr DriveController* drive;
|
||||
|
||||
extr Game* game;
|
||||
extr Goalie* goalie;
|
||||
extr Keeper* keeper;
|
||||
s_extr int role;
|
0
lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/cuberotate.pde
Normal file → Executable file
0
lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/cuberotate.pde
Normal file → Executable file
0
lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/data/bunny.mtl
Normal file → Executable file
0
lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/data/bunny.mtl
Normal file → Executable file
0
lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/data/bunny.obj
Normal file → Executable file
0
lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/data/bunny.obj
Normal file → Executable file
0
lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/serialconfig.txt
Normal file → Executable file
0
lib/Adafruit_BNO055/examples/bunny/processing/cuberotate/serialconfig.txt
Normal file → Executable file
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue