diff --git a/include/motors_movement/drivecontroller.h b/include/motors_movement/drivecontroller.h index ad47a5f..28679de 100644 --- a/include/motors_movement/drivecontroller.h +++ b/include/motors_movement/drivecontroller.h @@ -20,7 +20,7 @@ //Max possible vel 310 -#define MAX_VEL 125 +#define MAX_VEL 150 #define MAX_VEL_EIGTH ((int)MAX_VEL*0.8) #define MAX_VEL_HALF ((int)MAX_VEL*0.5) #define MAX_VEL_3QUARTERS ((int)MAX_VEL*0.75) diff --git a/include/sensors/data_source_camera_conicmirror.h b/include/sensors/data_source_camera_conicmirror.h index 7ad04d8..1594da6 100644 --- a/include/sensors/data_source_camera_conicmirror.h +++ b/include/sensors/data_source_camera_conicmirror.h @@ -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. These values need to be subtracted from the coords used in setMoveSetpoints*/ #define CAMERA_TRANSLATION_X 0 -#define CAMERA_TRANSLATION_Y 0 +#define CAMERA_TRANSLATION_Y 4 class DataSourceCameraConic : public DataSource{ diff --git a/include/strategy_roles/precision_shooter.h b/include/strategy_roles/precision_shooter.h index eadf914..69efe78 100644 --- a/include/strategy_roles/precision_shooter.h +++ b/include/strategy_roles/precision_shooter.h @@ -7,7 +7,7 @@ #define PS_ATTACK_DISTANCE 110 #define PS_TILT_STOP_DISTANCE 140 #define PS_PLUSANG 55 -#define PS_PLUSANG_VISIONCONE 7 +#define PS_PLUSANG_VISIONCONE 10 class PrecisionShooter : public Game{ diff --git a/include/systems/lines/linesys_camera.h b/include/systems/lines/linesys_camera.h index 4227b58..94c60ff 100644 --- a/include/systems/lines/linesys_camera.h +++ b/include/systems/lines/linesys_camera.h @@ -17,7 +17,7 @@ #define S4O A1 #define LINE_THRESH_CAM 350 -#define EXIT_TIME 400 +#define EXIT_TIME 300 class LineSysCamera : public LineSystem{ diff --git a/src/main.cpp b/src/main.cpp index 380eae6..9c47d1e 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -44,9 +44,12 @@ void setup() { tone(BUZZER, 350.00, 250); drive->prepareDrive(0,0,0); + + pinMode(35, INPUT); } void loop() { + DEBUG.println(digitalReadFast(35)); updateSensors(); drive->resetDrive(); @@ -54,9 +57,9 @@ void loop() { striker_condition = role == HIGH || ((Keeper*)keeper)->shouldStrike; keeper_condition = role == LOW; - striker->play(striker_condition); - keeper->play(keeper_condition); - // precision_shooter->play(1); + // striker->play(striker_condition); + // keeper->play(keeper_condition); + precision_shooter->play(1); testmenu->testMenu(); diff --git a/src/strategy_roles/precision_shooter.cpp b/src/strategy_roles/precision_shooter.cpp index d4928a5..3d7717c 100644 --- a/src/strategy_roles/precision_shooter.cpp +++ b/src/strategy_roles/precision_shooter.cpp @@ -36,6 +36,8 @@ void PrecisionShooter::realPlay() } unsigned long t3 = 0; +unsigned long t4 = 0; +boolean ignited = false; void PrecisionShooter::striker(){ @@ -60,13 +62,21 @@ void PrecisionShooter::striker(){ if(ball->isInFront()) roller->speed(ROLLER_DEFAULT_SPEED); 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) ) { - t3 = millis(); + 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(); + } } - if(millis() - t3 < 1000){ - roller->speed(1800); - ps->goCenter(); + if(millis() - t3 < 800){ + roller->speed(roller->MAX); + drive->prepareDrive(180, MAX_VEL_3QUARTERS, 0); + ignited = false; } @@ -74,7 +84,7 @@ void PrecisionShooter::striker(){ } 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; if(!gotta_tilt || !CURRENT_DATA_READ.atkSeen) { diff --git a/src/strategy_roles/striker.cpp b/src/strategy_roles/striker.cpp index 36e861f..bfe7c56 100644 --- a/src/strategy_roles/striker.cpp +++ b/src/strategy_roles/striker.cpp @@ -49,12 +49,8 @@ void Striker::striker(){ dir = (dir + 360) % 360; 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); - - // 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(); - // } } diff --git a/src/system/positions/positionsys_camera.cpp b/src/system/positions/positionsys_camera.cpp index e8cc2fd..d923267 100644 --- a/src/system/positions/positionsys_camera.cpp +++ b/src/system/positions/positionsys_camera.cpp @@ -54,7 +54,8 @@ void PositionSysCamera::update(){ posx *= -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 int i = 1; do{ diff --git a/utility/OpenMV/conic_eff_h7.py b/utility/OpenMV/conic_eff_h7.py index cb0d177..a1aa0c7 100644 --- a/utility/OpenMV/conic_eff_h7.py +++ b/utility/OpenMV/conic_eff_h7.py @@ -45,8 +45,8 @@ blue_led.on() ############################################################################## -thresholds = [ (66, 88, -12, 26, 50, 79), # thresholds yellow goalz - (40, 61, -9, 19, -61, -21)] # thresholds blue goal (6, 31, -15, 4, -35, 0) +thresholds = [ (70, 100, -36, 8, 38, 112), # thresholds yellow goalz + (46, 65, -18, 19, -59, -15)] # thresholds blue goal (6, 31, -15, 4, -35, 0) roi = (80, 0, 240, 200) @@ -67,11 +67,11 @@ clock = time.clock()''' sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) -sensor.set_windowing(roi) +#sensor.set_windowing(roi) sensor.set_contrast(0) sensor.set_saturation(2) 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_gain(False, gain_db=8.78) sensor.skip_frames(time = 300)