precision shooter

pull/1/head
EmaMaker 2021-05-13 20:40:15 +02:00
parent 0c5737c1ad
commit 6fc65c7331
9 changed files with 33 additions and 23 deletions

View File

@ -20,7 +20,7 @@
//Max possible vel 310 //Max possible vel 310
#define MAX_VEL 125 #define MAX_VEL 150
#define MAX_VEL_EIGTH ((int)MAX_VEL*0.8) #define MAX_VEL_EIGTH ((int)MAX_VEL*0.8)
#define MAX_VEL_HALF ((int)MAX_VEL*0.5) #define MAX_VEL_HALF ((int)MAX_VEL*0.5)
#define MAX_VEL_3QUARTERS ((int)MAX_VEL*0.75) #define MAX_VEL_3QUARTERS ((int)MAX_VEL*0.75)

View File

@ -22,7 +22,7 @@
To overcome this, each coordinate needs to be shifted by some amount, defined on a per-robot basis that needs to be recalibrated each time. To overcome this, each coordinate needs to be shifted by some amount, defined on a per-robot basis that needs to be recalibrated each time.
These values need to be subtracted from the coords used in setMoveSetpoints*/ These values need to be subtracted from the coords used in setMoveSetpoints*/
#define CAMERA_TRANSLATION_X 0 #define CAMERA_TRANSLATION_X 0
#define CAMERA_TRANSLATION_Y 0 #define CAMERA_TRANSLATION_Y 4
class DataSourceCameraConic : public DataSource{ class DataSourceCameraConic : public DataSource{

View File

@ -7,7 +7,7 @@
#define PS_ATTACK_DISTANCE 110 #define PS_ATTACK_DISTANCE 110
#define PS_TILT_STOP_DISTANCE 140 #define PS_TILT_STOP_DISTANCE 140
#define PS_PLUSANG 55 #define PS_PLUSANG 55
#define PS_PLUSANG_VISIONCONE 7 #define PS_PLUSANG_VISIONCONE 10
class PrecisionShooter : public Game{ class PrecisionShooter : public Game{

View File

@ -17,7 +17,7 @@
#define S4O A1 #define S4O A1
#define LINE_THRESH_CAM 350 #define LINE_THRESH_CAM 350
#define EXIT_TIME 400 #define EXIT_TIME 300
class LineSysCamera : public LineSystem{ class LineSysCamera : public LineSystem{

View File

@ -44,9 +44,12 @@ void setup() {
tone(BUZZER, 350.00, 250); tone(BUZZER, 350.00, 250);
drive->prepareDrive(0,0,0); drive->prepareDrive(0,0,0);
pinMode(35, INPUT);
} }
void loop() { void loop() {
DEBUG.println(digitalReadFast(35));
updateSensors(); updateSensors();
drive->resetDrive(); drive->resetDrive();
@ -54,9 +57,9 @@ void loop() {
striker_condition = role == HIGH || ((Keeper*)keeper)->shouldStrike; striker_condition = role == HIGH || ((Keeper*)keeper)->shouldStrike;
keeper_condition = role == LOW; keeper_condition = role == LOW;
striker->play(striker_condition); // striker->play(striker_condition);
keeper->play(keeper_condition); // keeper->play(keeper_condition);
// precision_shooter->play(1); precision_shooter->play(1);
testmenu->testMenu(); testmenu->testMenu();

View File

@ -36,6 +36,8 @@ void PrecisionShooter::realPlay()
} }
unsigned long t3 = 0; unsigned long t3 = 0;
unsigned long t4 = 0;
boolean ignited = false;
void PrecisionShooter::striker(){ void PrecisionShooter::striker(){
@ -60,13 +62,21 @@ void PrecisionShooter::striker(){
if(ball->isInFront()) roller->speed(ROLLER_DEFAULT_SPEED); if(ball->isInFront()) roller->speed(ROLLER_DEFAULT_SPEED);
else roller->speed(roller->MIN); else roller->speed(roller->MIN);
if(ball->isInFront() && CURRENT_DATA_READ.ballDistance <= 85 && CURRENT_DATA_READ.posy >= 32 && (CURRENT_DATA_READ.posx >= 15 || CURRENT_DATA_READ.posx <= -15) ) { if(ball->isInFront() && CURRENT_DATA_READ.ballDistance <= 78 && ( (CURRENT_DATA_READ.posy >= 32 && (CURRENT_DATA_READ.posx >= 15 || CURRENT_DATA_READ.posx <= -15)) || abs(tilt()) > 65 ) ) {
// Just let the robot slowly approach the ball
if(!ignited){
ignited = true;
t4 = millis();
}
if(millis() - t4 > 250 && ignited){
t3 = millis(); t3 = millis();
} }
}
if(millis() - t3 < 1000){ if(millis() - t3 < 800){
roller->speed(1800); roller->speed(roller->MAX);
ps->goCenter(); drive->prepareDrive(180, MAX_VEL_3QUARTERS, 0);
ignited = false;
} }
@ -74,7 +84,7 @@ void PrecisionShooter::striker(){
} }
int PrecisionShooter::tilt() { int PrecisionShooter::tilt() {
if (ball->isInMouth() /* || (ball->isInMouthMaxDistance() && gotta_tilt)*/ ) gotta_tilt = true; if (ball->isInFront() && CURRENT_DATA_READ.ballDistance <= 90 /* || (ball->isInMouthMaxDistance() && gotta_tilt)*/ ) gotta_tilt = true;
else gotta_tilt = false; else gotta_tilt = false;
if(!gotta_tilt || !CURRENT_DATA_READ.atkSeen) { if(!gotta_tilt || !CURRENT_DATA_READ.atkSeen) {

View File

@ -49,13 +49,9 @@ void Striker::striker(){
dir = (dir + 360) % 360; dir = (dir + 360) % 360;
drive->prepareDrive(dir, MAX_VEL_HALF, tilt()); drive->prepareDrive(dir, MAX_VEL_HALF, tilt());
if(ball->isInFront()) roller->speed(ROLLER_DEFAULT_SPEED); if(ball->isInFront() && roller->roller_armed) roller->speed(ROLLER_DEFAULT_SPEED);
else roller->speed(roller->MIN); else roller->speed(roller->MIN);
// if(ball->isInMouth() && ( (CURRENT_DATA_READ.posx <= -30 && CURRENT_DATA_READ.posy >= 35) || (CURRENT_DATA_READ.posx >= 30 && CURRENT_DATA_READ.posy >= 35))){
// ps->goCenter();
// }
} }
int Striker::tilt() { int Striker::tilt() {

View File

@ -54,7 +54,8 @@ void PositionSysCamera::update(){
posx *= -1; posx *= -1;
posy *= -1; posy *= -1;
if(abs(CURRENT_DATA_READ.posx-CURRENT_DATA_WRITE.posx)>MAX_X || abs(CURRENT_DATA_READ.posy-CURRENT_DATA_WRITE.posy)>MAX_Y|| (CURRENT_DATA_WRITE.bSeen == false && CURRENT_DATA_WRITE.ySeen == false) ) { //x = 66 is a very very strange bug I can't seem to track down. It's a dirty hack, I know
if(posx == 66 || (CURRENT_DATA_WRITE.bSeen == false && CURRENT_DATA_WRITE.ySeen == false) ) {
// Go back in time until we found a valid status, when we saw at least one goal // Go back in time until we found a valid status, when we saw at least one goal
int i = 1; int i = 1;
do{ do{

View File

@ -45,8 +45,8 @@ blue_led.on()
############################################################################## ##############################################################################
thresholds = [ (66, 88, -12, 26, 50, 79), # thresholds yellow goalz thresholds = [ (70, 100, -36, 8, 38, 112), # thresholds yellow goalz
(40, 61, -9, 19, -61, -21)] # thresholds blue goal (6, 31, -15, 4, -35, 0) (46, 65, -18, 19, -59, -15)] # thresholds blue goal (6, 31, -15, 4, -35, 0)
roi = (80, 0, 240, 200) roi = (80, 0, 240, 200)
@ -67,11 +67,11 @@ clock = time.clock()'''
sensor.reset() sensor.reset()
sensor.set_pixformat(sensor.RGB565) sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA) sensor.set_framesize(sensor.QVGA)
sensor.set_windowing(roi) #sensor.set_windowing(roi)
sensor.set_contrast(0) sensor.set_contrast(0)
sensor.set_saturation(2) sensor.set_saturation(2)
sensor.set_brightness(3) sensor.set_brightness(3)
sensor.set_auto_whitebal(True, (-6.02073, -4.528669, -1.804)) sensor.set_auto_whitebal(False, (-6.02073, -4.528669, -1.804))
sensor.set_auto_exposure(False, 6576) sensor.set_auto_exposure(False, 6576)
#sensor.set_auto_gain(False, gain_db=8.78) #sensor.set_auto_gain(False, gain_db=8.78)
sensor.skip_frames(time = 300) sensor.skip_frames(time = 300)