mirror of
https://github.com/Team4388/2026KPopRobotHunters.git
synced 2026-06-09 00:38:03 -06:00
Some changes
This commit is contained in:
@@ -101,6 +101,7 @@ public class RobotContainer {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private Command LidarIntake = new SequentialCommandGroup(
|
private Command LidarIntake = new SequentialCommandGroup(
|
||||||
|
// Right now this will just go to the closest ball constantly updating - need to make it so it locks on one ball
|
||||||
RobotIntakeDown,
|
RobotIntakeDown,
|
||||||
new RunCommand(
|
new RunCommand(
|
||||||
() -> m_robotSwerveDrive.driveWithInputRotation(
|
() -> m_robotSwerveDrive.driveWithInputRotation(
|
||||||
|
|||||||
@@ -64,6 +64,11 @@ public class Lidar extends SubsystemBase implements ScanListener {
|
|||||||
public Rotation2d getLatestBallAngle() {
|
public Rotation2d getLatestBallAngle() {
|
||||||
return latestBallAngleDeg;
|
return latestBallAngleDeg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean outOfBounds(Translation2d closestBall){
|
||||||
|
// Make sure robot doesn't go off the earth
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -237,19 +242,14 @@ public class Lidar extends SubsystemBase implements ScanListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (closestBallPrior != null) {
|
if (closestBallPrior != null) {
|
||||||
if (closestBall.getDistance(closestBallPrior) < 0.1){
|
if (closestBall.getDistance(closestBallPrior) < 0.1 && outOfBounds(closestBall)){
|
||||||
|
|
||||||
Point scaledPoint = new Point( (WIDTH/2) + (closestBall.getX() / scale), (WIDTH/2) + (closestBall.getY() / scale));
|
// Point scaledPoint = new Point( (WIDTH/2) + (closestBall.getX() / scale), (WIDTH/2) + (closestBall.getY() / scale));
|
||||||
|
// Imgproc.circle(mat, scaledPoint, (int) (RADIUS_OFFSET / scale), new Scalar(200, 25, 52), -1);
|
||||||
Imgproc.circle(mat, scaledPoint, (int) (RADIUS_OFFSET / scale), new Scalar(200, 25, 52), -1);
|
|
||||||
|
|
||||||
// System.out.println("Drive "+ Units.metersToInches(closestBall.x) + " inches forward and " + Units.metersToInches(closestBall.y) + "inches to the right");
|
|
||||||
latestBallAngleDeg = new Rotation2d(Math.atan((closestBall.getY())/(closestBall.getX()))/Math.PI*180);
|
latestBallAngleDeg = new Rotation2d(Math.atan((closestBall.getY())/(closestBall.getX()))/Math.PI*180);
|
||||||
System.out.println("!!" + latestBallAngleDeg);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Point scaledPoint = new Point( (WIDTH/2) + (closestBallPrior.getX() / scale), (WIDTH/2) + (closestBallPrior.getX() / scale));
|
// Point scaledPoint = new Point( (WIDTH/2) + (closestBallPrior.getX() / scale), (WIDTH/2) + (closestBallPrior.getX() / scale));
|
||||||
Imgproc.circle(mat, scaledPoint, (int) (RADIUS_OFFSET / scale), new Scalar(200, 25, 52), -1);
|
// Imgproc.circle(mat, scaledPoint, (int) (RADIUS_OFFSET / scale), new Scalar(200, 25, 52), -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -405,20 +405,13 @@ public class SwerveDrive extends SubsystemBase implements Queryable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void driveWithInputRotation(Translation2d leftStick, Rotation2d rot) {
|
public void driveWithInputRotation(Translation2d leftStick, Rotation2d rot) {
|
||||||
// if (leftStick.getNorm() < 0.05 && stopped == false) // if no imput and the
|
|
||||||
// swerve drive is still going:
|
|
||||||
// stopModules(); // stop the swerve
|
|
||||||
|
|
||||||
// if (leftStick.getNorm() < 0.05) //if no imput
|
|
||||||
// return; // don't bother doing swerve drive math and return early.
|
|
||||||
|
|
||||||
leftStick = leftStick.rotateBy(TimesNegativeOne.ForwardOffset);
|
leftStick = leftStick.rotateBy(TimesNegativeOne.ForwardOffset);
|
||||||
|
|
||||||
io.setControl(new SwerveRequest.FieldCentricFacingAngle()
|
io.setControl(new SwerveRequest.FieldCentricFacingAngle()
|
||||||
.withVelocityX(leftStick.getX() * -speedAdjust)
|
.withVelocityX(leftStick.getX() * -speedAdjust)
|
||||||
.withVelocityY(leftStick.getY() * speedAdjust)
|
.withVelocityY(leftStick.getY() * speedAdjust)
|
||||||
.withTargetDirection(rot));
|
.withTargetDirection(rot));
|
||||||
// double
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getGyroAngle() {
|
public double getGyroAngle() {
|
||||||
|
|||||||
Reference in New Issue
Block a user