mirror of
https://github.com/Team4388/2022NoWayHome.git
synced 2026-06-09 08:48:07 -06:00
current ver (ryan)
This commit is contained in:
@@ -226,7 +226,7 @@ public class RobotContainer {
|
|||||||
}, m_robotClimber));
|
}, m_robotClimber));
|
||||||
|
|
||||||
m_robotBoomBoom.setDefaultCommand(
|
m_robotBoomBoom.setDefaultCommand(
|
||||||
new RunCommand(() -> m_robotBoomBoom.runDrumShooter(0.45))
|
new RunCommand(() -> m_robotBoomBoom.runDrumShooter(0.45), m_robotBoomBoom)
|
||||||
);
|
);
|
||||||
|
|
||||||
// autoInit();
|
// autoInit();
|
||||||
@@ -296,7 +296,7 @@ public class RobotContainer {
|
|||||||
// .whenPressed(new Shoot(m_robotSwerveDrive, m_robotBoomBoom, m_robotTurret, m_robotHood, m_robotVisionOdometry, false, false));
|
// .whenPressed(new Shoot(m_robotSwerveDrive, m_robotBoomBoom, m_robotTurret, m_robotHood, m_robotVisionOdometry, false, false));
|
||||||
|
|
||||||
new JoystickButton(getOperatorController(), XboxController.Button.kY.value)
|
new JoystickButton(getOperatorController(), XboxController.Button.kY.value)
|
||||||
.whileHeld(new TrackTarget(m_robotTurret, m_robotBoomBoom, m_robotHood, m_robotVisionOdometry));
|
.whileHeld(new TrackTarget(m_robotTurret, m_robotBoomBoom, m_robotHood, m_robotVisionOdometry, false));
|
||||||
|
|
||||||
// new JoystickButton(getOperatorController(), XboxController.Button.kY.value)
|
// new JoystickButton(getOperatorController(), XboxController.Button.kY.value)
|
||||||
// .whileHeld(new RunCommand(() -> m_robotClaws.setOpen(true)));
|
// .whileHeld(new RunCommand(() -> m_robotClaws.setOpen(true)));
|
||||||
|
|||||||
@@ -89,29 +89,29 @@ public class TrackTarget extends CommandBase {
|
|||||||
m_visionOdometry.setLEDs(true);
|
m_visionOdometry.setLEDs(true);
|
||||||
|
|
||||||
points = m_visionOdometry.getTargetPoints();
|
points = m_visionOdometry.getTargetPoints();
|
||||||
// points = filterPoints(points);
|
points = filterPoints(points);
|
||||||
Point average = VisionOdometry.averagePoint(points);
|
Point average = VisionOdometry.averagePoint(points);
|
||||||
|
|
||||||
double output = (average.x - VisionConstants.LIME_HIXELS/2.d) / VisionConstants.LIME_HIXELS;
|
double output = (average.x - VisionConstants.LIME_HIXELS/2.d) / VisionConstants.LIME_HIXELS;
|
||||||
output *= 2;
|
output *= 2.0;
|
||||||
|
|
||||||
m_turret.runTurretWithInput(output);
|
m_turret.runTurretWithInput(output);
|
||||||
// double position = m_turret.m_boomBoomRotateEncoder.getPosition();
|
double position = m_turret.m_boomBoomRotateEncoder.getPosition();
|
||||||
|
|
||||||
// if(Math.abs(position - ShooterConstants.TURRET_FORWARD_SOFT_LIMIT) < 5 ||
|
if(Math.abs(position - ShooterConstants.TURRET_FORWARD_SOFT_LIMIT) < 5 ||
|
||||||
// Math.abs(position - ShooterConstants.TURRET_REVERSE_SOFT_LIMIT) < 5)
|
Math.abs(position - ShooterConstants.TURRET_REVERSE_SOFT_LIMIT) < 5)
|
||||||
// m_swerve.driveWithInput(RobotContainer.getDriverController().getLeftX(), RobotContainer.getDriverController().getLeftY(), output, true);
|
m_swerve.driveWithInput(RobotContainer.getDriverController().getLeftX(), RobotContainer.getDriverController().getLeftY(), output, true);
|
||||||
// else
|
else
|
||||||
// m_swerve.driveWithInput(RobotContainer.getDriverController().getLeftX(), RobotContainer.getDriverController().getLeftY(),
|
m_swerve.driveWithInput(RobotContainer.getDriverController().getLeftX(), RobotContainer.getDriverController().getLeftY(),
|
||||||
// RobotContainer.getDriverController().getRightX(), RobotContainer.getDriverController().getRightY(),
|
RobotContainer.getDriverController().getRightX(), RobotContainer.getDriverController().getRightY(),
|
||||||
// true);
|
true);
|
||||||
|
|
||||||
|
|
||||||
double regressedDistance = getDistance(average.y);
|
double regressedDistance = getDistance(average.y);
|
||||||
|
|
||||||
// ! no longer a +30 lol -aarav
|
// ! no longer a +30 lol -aarav
|
||||||
velocity = m_boomBoom.getVelocity(regressedDistance);
|
velocity = m_boomBoom.getVelocity(regressedDistance + 30);
|
||||||
hoodPosition = m_boomBoom.getHood(regressedDistance);
|
hoodPosition = m_boomBoom.getHood(regressedDistance + 30);
|
||||||
|
|
||||||
m_boomBoom.runDrumShooterVelocityPID(velocity);
|
m_boomBoom.runDrumShooterVelocityPID(velocity);
|
||||||
m_hood.runAngleAdjustPID(hoodPosition);
|
m_hood.runAngleAdjustPID(hoodPosition);
|
||||||
@@ -134,25 +134,25 @@ public class TrackTarget extends CommandBase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public ArrayList<Point> filterPoints(ArrayList<Point> points) {
|
public ArrayList<Point> filterPoints(ArrayList<Point> points) {
|
||||||
// Point average = VisionOdometry.averagePoint(points);
|
Point average = VisionOdometry.averagePoint(points);
|
||||||
|
|
||||||
// HashMap<Point, Double> pointDistances = new HashMap<>();
|
HashMap<Point, Double> pointDistances = new HashMap<>();
|
||||||
// double distanceSum = 0;
|
double distanceSum = 0;
|
||||||
|
|
||||||
// for(Point point : points) {
|
for(Point point : points) {
|
||||||
// Vector2D difference = new Vector2D(point);
|
Vector2D difference = new Vector2D(point);
|
||||||
// difference.subtract(new Vector2D(average));
|
difference.subtract(new Vector2D(average));
|
||||||
|
|
||||||
// double mag = difference.magnitude();
|
double mag = difference.magnitude();
|
||||||
// distanceSum += mag;
|
distanceSum += mag;
|
||||||
|
|
||||||
// pointDistances.put(point, mag);
|
pointDistances.put(point, mag);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// final double averageDist = distanceSum / points.size();
|
final double averageDist = distanceSum / points.size();
|
||||||
// return (ArrayList<Point>) pointDistances.keySet().stream().filter(p -> pointDistances.get(p) < 2 * averageDist).collect(Collectors.toList());
|
return (ArrayList<Point>) pointDistances.keySet().stream().filter(p -> pointDistances.get(p) < 1.3 * averageDist).collect(Collectors.toList());
|
||||||
// }
|
}
|
||||||
|
|
||||||
public final double getDistance(double averageY) {
|
public final double getDistance(double averageY) {
|
||||||
double y_rot = averageY / VisionConstants.LIME_VIXELS;
|
double y_rot = averageY / VisionConstants.LIME_VIXELS;
|
||||||
|
|||||||
Reference in New Issue
Block a user