mirror of
https://github.com/Team4388/2025RidgeScape.git
synced 2026-06-09 08:48:04 -06:00
lidar align works
This commit is contained in:
@@ -105,8 +105,8 @@ public final class Constants {
|
|||||||
public static final double FORWARD_OFFSET = 90; // 0, 90, 180, 270
|
public static final double FORWARD_OFFSET = 90; // 0, 90, 180, 270
|
||||||
|
|
||||||
public static final boolean DRIFT_CORRECTION_ENABLED = true;
|
public static final boolean DRIFT_CORRECTION_ENABLED = true;
|
||||||
public static final boolean INVERT_X = true;
|
public static final boolean INVERT_X = false;
|
||||||
public static final boolean INVERT_Y = false;
|
public static final boolean INVERT_Y = true;
|
||||||
public static final boolean INVERT_ROTATION = false;
|
public static final boolean INVERT_ROTATION = false;
|
||||||
|
|
||||||
// public static final Trim POINTLESS_TRIM = new Trim("Pointless Trim", Double.MAX_VALUE, Double.MIN_VALUE, 0.1, 0);
|
// public static final Trim POINTLESS_TRIM = new Trim("Pointless Trim", Double.MAX_VALUE, Double.MIN_VALUE, 0.1, 0);
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import edu.wpi.first.wpilibj2.command.Commands;
|
|||||||
// Autos
|
// Autos
|
||||||
import frc4388.utility.controller.VirtualController;
|
import frc4388.utility.controller.VirtualController;
|
||||||
import frc4388.robot.commands.GotoPositionCommand;
|
import frc4388.robot.commands.GotoPositionCommand;
|
||||||
|
import frc4388.robot.commands.LidarAlign;
|
||||||
import frc4388.robot.commands.Swerve.neoJoystickPlayback;
|
import frc4388.robot.commands.Swerve.neoJoystickPlayback;
|
||||||
import frc4388.robot.commands.Swerve.neoJoystickRecorder;
|
import frc4388.robot.commands.Swerve.neoJoystickRecorder;
|
||||||
|
|
||||||
@@ -106,6 +107,15 @@ public class RobotContainer {
|
|||||||
new VirtualController[]{getVirtualDriverController(), getVirtualOperatorController()},
|
new VirtualController[]{getVirtualDriverController(), getVirtualOperatorController()},
|
||||||
true, false);
|
true, false);
|
||||||
private Command AutoGotoPosition = new GotoPositionCommand(m_robotSwerveDrive, m_vision);
|
private Command AutoGotoPosition = new GotoPositionCommand(m_robotSwerveDrive, m_vision);
|
||||||
|
private Command AprilLidarLeft = new SequentialCommandGroup(
|
||||||
|
AutoGotoPosition.asProxy(),
|
||||||
|
new LidarAlign(m_robotSwerveDrive, m_lidar, false)
|
||||||
|
);
|
||||||
|
|
||||||
|
private Command AprilLidarRight = new SequentialCommandGroup(
|
||||||
|
AutoGotoPosition.asProxy(),
|
||||||
|
new LidarAlign(m_robotSwerveDrive, m_lidar, true)
|
||||||
|
);
|
||||||
|
|
||||||
private Command placeCoral = new SequentialCommandGroup(
|
private Command placeCoral = new SequentialCommandGroup(
|
||||||
new InstantCommand(() -> m_robotSwerveDrive.stopModules()),
|
new InstantCommand(() -> m_robotSwerveDrive.stopModules()),
|
||||||
@@ -217,7 +227,8 @@ public class RobotContainer {
|
|||||||
// ? /* Operator Buttons */
|
// ? /* Operator Buttons */
|
||||||
|
|
||||||
new JoystickButton(getDeadbandedDriverController(), XboxController.Y_BUTTON)
|
new JoystickButton(getDeadbandedDriverController(), XboxController.Y_BUTTON)
|
||||||
.onTrue(AutoGotoPosition);
|
// .onTrue(AutoGotoPosition);
|
||||||
|
.onTrue(AprilLidarRight);
|
||||||
|
|
||||||
new JoystickButton(getDeadbandedDriverController(), XboxController.B_BUTTON)
|
new JoystickButton(getDeadbandedDriverController(), XboxController.B_BUTTON)
|
||||||
.onTrue(new InstantCommand(() -> {}, m_robotSwerveDrive));
|
.onTrue(new InstantCommand(() -> {}, m_robotSwerveDrive));
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ public class GotoPositionCommand extends Command {
|
|||||||
double rotoutput = rotPID.update(roterr);
|
double rotoutput = rotPID.update(roterr);
|
||||||
|
|
||||||
Translation2d leftStick = new Translation2d(
|
Translation2d leftStick = new Translation2d(
|
||||||
Math.max(Math.min(youtput, 1), -1),
|
Math.max(Math.min(-youtput, 1), -1),
|
||||||
Math.max(Math.min(xoutput, 1), -1)
|
Math.max(Math.min(-xoutput, 1), -1)
|
||||||
// 0,0
|
// 0,0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class LidarAlign extends Command {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
this.currentFinderTick = 0;
|
this.currentFinderTick = 0;
|
||||||
this.speed = 0.1; // TODO: find good speed for this
|
this.speed = 0.4; // TODO: find good speed for this
|
||||||
this.foundReef = false;
|
this.foundReef = false;
|
||||||
this.headedRight = constructedHeadedRight;
|
this.headedRight = constructedHeadedRight;
|
||||||
}
|
}
|
||||||
@@ -57,11 +57,11 @@ public class LidarAlign extends Command {
|
|||||||
currentFinderTick *= -1;
|
currentFinderTick *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
double relAngle = Math.round(swerveDrive.getGyroAngle() / 60.d) * 60; // Relative driving to the side of the reef
|
double relAngle = (Math.round(swerveDrive.getGyroAngle() / 60.d) * 60) + 90; // Relative driving to the side of the reef
|
||||||
if (!headedRight) {
|
if (!headedRight) {
|
||||||
swerveDrive.driveRelativeLockedAngle(new Translation2d(0, speed), Rotation2d.fromDegrees(relAngle));
|
|
||||||
} else {
|
|
||||||
swerveDrive.driveRelativeLockedAngle(new Translation2d(0, -speed), Rotation2d.fromDegrees(relAngle));
|
swerveDrive.driveRelativeLockedAngle(new Translation2d(0, -speed), Rotation2d.fromDegrees(relAngle));
|
||||||
|
} else {
|
||||||
|
swerveDrive.driveRelativeLockedAngle(new Translation2d(0, speed), Rotation2d.fromDegrees(relAngle));
|
||||||
}
|
}
|
||||||
|
|
||||||
currentFinderTick++;
|
currentFinderTick++;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.ctre.phoenix6.hardware.CANcoder;
|
|||||||
import com.ctre.phoenix6.hardware.TalonFX;
|
import com.ctre.phoenix6.hardware.TalonFX;
|
||||||
import com.ctre.phoenix6.swerve.SwerveDrivetrain;
|
import com.ctre.phoenix6.swerve.SwerveDrivetrain;
|
||||||
import com.ctre.phoenix6.swerve.SwerveRequest;
|
import com.ctre.phoenix6.swerve.SwerveRequest;
|
||||||
|
import com.ctre.phoenix6.swerve.SwerveRequest.ForwardPerspectiveValue;
|
||||||
|
|
||||||
import edu.wpi.first.math.geometry.Pose2d;
|
import edu.wpi.first.math.geometry.Pose2d;
|
||||||
import edu.wpi.first.math.geometry.Rotation2d;
|
import edu.wpi.first.math.geometry.Rotation2d;
|
||||||
@@ -149,6 +150,7 @@ public class SwerveDrive extends Subsystem {
|
|||||||
.withVelocityX(leftStick.getX() * speedAdjust)
|
.withVelocityX(leftStick.getX() * speedAdjust)
|
||||||
.withVelocityY(leftStick.getY() * speedAdjust)
|
.withVelocityY(leftStick.getY() * speedAdjust)
|
||||||
.withRotationalRate(rightStick.getX() * rotSpeedAdjust));
|
.withRotationalRate(rightStick.getX() * rotSpeedAdjust));
|
||||||
|
// .withForwardPerspective(ForwardPerspectiveValue.OperatorPerspective));
|
||||||
SmartDashboard.putBoolean("drift correction", false);
|
SmartDashboard.putBoolean("drift correction", false);
|
||||||
} else {
|
} else {
|
||||||
var ctrl = new SwerveRequest.FieldCentricFacingAngle()
|
var ctrl = new SwerveRequest.FieldCentricFacingAngle()
|
||||||
|
|||||||
Reference in New Issue
Block a user