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_);
|
DriveController(Motor* m1_, Motor* m2_, Motor* m3_, Motor* m4_);
|
||||||
|
|
||||||
void drive(int dir, int speed, int tilt);
|
void drive(int dir=0, int speed=0, int tilt=0);
|
||||||
void prepareDrive(int dir, int speed, int tilt);
|
void prepareDrive(int dir=0, int speed=0, int tilt=0);
|
||||||
void drivePrepared();
|
void drivePrepared();
|
||||||
float updatePid();
|
float updatePid();
|
||||||
float torad(float f);
|
float torad(float f);
|
||||||
|
|
|
@ -1,21 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "data_source.h"
|
|
||||||
#include "data_source_ball.h"
|
|
||||||
#include "motor.h"
|
|
||||||
#include "drivecontroller.h"
|
|
||||||
#include "sensors.h"
|
|
||||||
#include "vars.h"
|
#include "vars.h"
|
||||||
#include "data_source_bno055.h"
|
#include "sensors.h"
|
||||||
#include "goalie.h"
|
|
||||||
#include "keeper.h"
|
|
||||||
|
|
||||||
class Game{
|
class Game {
|
||||||
public:
|
public:
|
||||||
Game();
|
Game();
|
||||||
//void keeper();
|
void play(bool condition=true);
|
||||||
//void goalie();
|
private:
|
||||||
//void ballBack();
|
virtual void realPlay() = 0;
|
||||||
bool role, attackGoal; //1->goalie 0->keeper, 1->yellow 0->blue
|
|
||||||
//~Game();
|
|
||||||
};
|
};
|
|
@ -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
|
#pragma once
|
||||||
|
|
||||||
#include "game.h"
|
#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_BAK 350
|
||||||
#define GOALIE_ATKSPD_FRT 345
|
#define GOALIE_ATKSPD_FRT 345
|
||||||
#define GOALIE_ATKSPD_STRK 355
|
#define GOALIE_ATKSPD_STRK 355
|
||||||
|
@ -12,14 +14,18 @@
|
||||||
#define GOALIE_ATKDIR_PLUSANGBAK 40
|
#define GOALIE_ATKDIR_PLUSANGBAK 40
|
||||||
#define GOALIE_ATKDIR_PLUSANG1_COR 60
|
#define GOALIE_ATKDIR_PLUSANG1_COR 60
|
||||||
#define GOALIE_ATKDIR_PLUSANG2_COR 70
|
#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:
|
public:
|
||||||
Goalie();
|
Goalie();
|
||||||
|
|
||||||
|
void realPlay() override;
|
||||||
void goalie();
|
void goalie();
|
||||||
void ballBack();
|
void ballBack();
|
||||||
//void rigore(); to be implemented
|
void storcimentoPorta();
|
||||||
int atk_direction, atk_speed;
|
|
||||||
|
int atk_speed, atk_direction;
|
||||||
|
float cstorc;
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,10 +2,26 @@
|
||||||
|
|
||||||
#include "game.h"
|
#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:
|
public:
|
||||||
Keeper();
|
Keeper();
|
||||||
|
private:
|
||||||
|
void realPlay() override;
|
||||||
void keeper();
|
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
|
#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_bno055.h"
|
||||||
#include "data_source_ball.h"
|
#include "data_source_ball.h"
|
||||||
#include "data_source_camera.h"
|
#include "data_source_camera.h"
|
||||||
|
@ -8,31 +16,20 @@
|
||||||
#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
|
|
||||||
#define extr
|
|
||||||
#else
|
|
||||||
#define extr extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class Game;
|
|
||||||
class Goalie;
|
|
||||||
class Keeper;
|
|
||||||
void initSensors();
|
void initSensors();
|
||||||
void updateSensors();
|
void updateSensors();
|
||||||
|
|
||||||
extr vector<DataSource*> lIn;
|
s_extr vector<DataSource*> lIn;
|
||||||
extr vector<DataSource*> lOut;
|
s_extr vector<DataSource*> lOut;
|
||||||
extr vector<DataSource*> dUs;
|
s_extr vector<DataSource*> dUs;
|
||||||
|
|
||||||
extr DataSourceCtrl* usCtrl;
|
s_extr DataSourceCtrl* usCtrl;
|
||||||
extr DataSourceCtrlLines* linesCtrl;
|
s_extr DataSourceCtrlLines* linesCtrl;
|
||||||
|
|
||||||
extr DataSourceBNO055* compass;
|
s_extr DataSourceBNO055* compass;
|
||||||
extr DataSourceBall* ball;
|
s_extr DataSourceBall* ball;
|
||||||
extr DataSourceCamera* camera;
|
s_extr DataSourceCamera* camera;
|
||||||
extr DriveController* drive;
|
s_extr DriveController* drive;
|
||||||
|
|
||||||
extr Game* game;
|
s_extr int role;
|
||||||
extr Goalie* goalie;
|
|
||||||
extr Keeper* keeper;
|
|
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