trig solution

This commit is contained in:
aarav18
2022-04-08 12:33:42 -06:00
parent a07bbfbbae
commit 3b5749569b
2 changed files with 13 additions and 5 deletions
@@ -341,5 +341,8 @@ public final class Constants {
public static final double EDGE_TO_CENTER = 20;
public static final double LIMELIGHT_RADIUS = 8;
public static final double SHOOTER_CORRECTION = 1.d;
public static final double PIXELS_PER_DEGREE = LIME_HIXELS / H_FOV;
public static final double DEGREES_PER_PIXELS = 1 / PIXELS_PER_DEGREE;
}
}
@@ -106,11 +106,6 @@ public class TrackTarget extends CommandBase {
// points = getFakePoints();
//// points = filterPoints(points);
Point average = VisionOdometry.averagePoint(points);
double output = ((average.x + 40) - VisionConstants.LIME_HIXELS/2.d) / VisionConstants.LIME_HIXELS;
output *= 2.1;
m_turret.runTurretWithInput(output);
// double position = m_turret.m_boomBoomRotateEncoder.getPosition();
// if(Math.abs(position - ShooterConstants.TURRET_FORWARD_SOFT_LIMIT) < 5 ||
@@ -123,7 +118,17 @@ public class TrackTarget extends CommandBase {
double regressedDistance = getDistance(average.y);
// ! offset trig solution
double desiredOffset = 10; // * inches
double angleOffset = Math.toDegrees(Math.atan(desiredOffset / regressedDistance)); // * degrees
double pixelOffset = angleOffset * VisionConstants.PIXELS_PER_DEGREE;
double output = ((average.x + 40) - VisionConstants.LIME_HIXELS/2.d) / VisionConstants.LIME_HIXELS;
output *= 2.1;
m_turret.runTurretWithInput(output);
// ! no longer a +30 lol -aarav
double distAdj = SmartDashboard.getNumber("Distance Adjust", -35);
velocity = m_boomBoom.getVelocity(regressedDistance + distAdj);