status vector now working better. Still have to fix something

pull/1/head
EmaMaker 2020-02-12 21:44:00 +01:00
commit 73981ad784
6 changed files with 26 additions and 8 deletions

View File

@ -16,7 +16,7 @@
#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 : public Game{ class Goalie : public Game, public PositionSysZone{
public: public:
Goalie(); Goalie();

View File

@ -60,6 +60,7 @@ class PositionSysZone : public PositionSystem{
PositionSysZone(); PositionSysZone();
void update() override; void update() override;
void test() override; void test() override;
void goCenter();
//returns the zone calculated //returns the zone calculated
int getValue(); int getValue();
@ -110,7 +111,7 @@ class PositionSysZone : public PositionSystem{
void testLogicZone(); void testLogicZone();
//movement //movement
void goCenter(); //void goCenter();
void goGoalPost(); void goGoalPost();
void centerGoalPost(); void centerGoalPost();
void centerGoalPostCamera(bool); void centerGoalPostCamera(bool);

View File

@ -31,7 +31,7 @@ DriveController::DriveController(Motor* m1_, Motor* m2_, Motor* m3_, Motor* m4_)
setpoint = 0; setpoint = 0;
pid->SetMode(AUTOMATIC); pid->SetMode(AUTOMATIC);
pid->SetSampleTime(2); pid->SetSampleTime(5);
canUnlock = true; canUnlock = true;
unlockTime = 0; unlockTime = 0;

View File

@ -1,6 +1,7 @@
#include "goalie.h" #include "goalie.h"
#include "sensors.h" #include "sensors.h"
#include "vars.h" #include "vars.h"
#include "positionsys_zone.h"
Goalie::Goalie() : Game() { Goalie::Goalie() : Game() {
init(); init();
@ -17,7 +18,7 @@ void Goalie::init(){
} }
void Goalie::realPlay(){ void Goalie::realPlay(){
if(ball->ballSeen) this->goalie(50); if(ball->ballSeen) this->goCenter();
else drive->prepareDrive(0,0,0); else drive->prepareDrive(0,0,0);
} }
@ -36,11 +37,19 @@ void Goalie::goalie(int plusang) {
else dir = dir; else dir = dir;
storcimentoPorta(); storcimentoPorta();
<<<<<<< HEAD
if(ball->distance > 200 && (ball->angle > 340 || ball->angle < 20)) drive->prepareDrive(dir, 350, cstorc); if(ball->distance > 200 && (ball->angle > 340 || ball->angle < 20)) drive->prepareDrive(dir, 350, cstorc);
else { else {
drive->prepareDrive(dir, 350, 0); drive->prepareDrive(dir, 350, 0);
cstorc = 0; cstorc = 0;
} }
=======
//if(ball->distance > 200 && (ball->angle > 340 || ball->angle < 20)) drive->prepareDrive(ball->dir, 350, cstorc);
//else {
drive->prepareDrive(ball->dir, 350, 0);
// cstorc = 0;
//}
>>>>>>> 5a9ce6692fe1b3165fa36a1f5a11c729c8818dd4
} }
} }

View File

@ -373,7 +373,15 @@ void PositionSysZone::testLogicZone(){
void PositionSysZone::goCenter() { void PositionSysZone::goCenter() {
if (zoneIndex == 8) if((camera->true_yb + camera->true_yy) >= 3 && (camera->true_yb + camera->true_yy) <= -3) {
//dx o sx
if((camera->true_yb + camera->true_yy) < 0) drive->prepareDrive(0, 200, 0);
else if ((camera->true_yb + camera->true_yy) > 0) drive->prepareDrive(270, 200, 0);
}
if(camera->true_xb >= -10 && camera->true_xb <= 10);
else if(camera->true_xb >= -5 && camera->true_xb <= 35) drive->prepareDrive(90, 200, 0);
else if(camera->true_xb >= 5 && camera->true_xb <= -35) drive->prepareDrive(180, 200, 0);
/* if (zoneIndex == 8)
drive->prepareDrive(330, GOCENTER_VEL); drive->prepareDrive(330, GOCENTER_VEL);
if (zoneIndex == 7) if (zoneIndex == 7)
drive->prepareDrive(0, GOCENTER_VEL); drive->prepareDrive(0, GOCENTER_VEL);
@ -390,7 +398,7 @@ void PositionSysZone::goCenter() {
if (zoneIndex == 1) if (zoneIndex == 1)
drive->prepareDrive(180, GOCENTER_VEL); drive->prepareDrive(180, GOCENTER_VEL);
if (zoneIndex == 0) if (zoneIndex == 0)
drive->prepareDrive(135, GOCENTER_VEL); drive->prepareDrive(135, GOCENTER_VEL); */
} }

View File

@ -40,7 +40,7 @@ blue_led.on()
thresholds = [ (30, 70, -12, 19, 10, 57), # thresholds yellow goal thresholds = [ (30, 70, -12, 19, 10, 57), # thresholds yellow goal
(0, 31, -2, 39, -68, -25)] # thresholds blue goal (6, 31, -15, 4, -35, 0) (0, 44, -5, 42, -65, -13)] # thresholds blue goal (6, 31, -15, 4, -35, 0)
roi = (0, 6, 318, 152) roi = (0, 6, 318, 152)
@ -62,7 +62,7 @@ sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA) sensor.set_framesize(sensor.QQVGA)
sensor.set_contrast(+3) sensor.set_contrast(+3)
sensor.set_saturation(0) sensor.set_saturation(0)
sensor.set_brightness(0) sensor.set_brightness(-2)
sensor.set_quality(0) sensor.set_quality(0)
sensor.set_auto_exposure(False, 10000) sensor.set_auto_exposure(False, 10000)
sensor.set_auto_gain(True) sensor.set_auto_gain(True)