Conversation
| * Dynamically slows drivetrain and lower-priority mechanism motion when battery voltage drops or | ||
| * robot is drawing too high of a current. | ||
| */ | ||
| public class BrownProtection extends SubsystemBase { |
There was a problem hiding this comment.
Call this BrownoutProtection instead of BrownProtection.
| @@ -0,0 +1,106 @@ | |||
| package frc.robot.power; | |||
There was a problem hiding this comment.
Put this in the subsystems folder.
| private final CommandSwerveDrive swerveDrive; | ||
| private final Turret turret; | ||
| private final ShooterHood shooterHood; | ||
| private final IntakeExtension intakeExtension; |
There was a problem hiding this comment.
We also want to be limiting the roller floor and intake roller voltage.
| return baseMotionMagicAcceleration * motionProfileConstraintScale; | ||
| } | ||
|
|
||
| private void applyMotionMagicConfig() { |
There was a problem hiding this comment.
You can't reapply configurations on the fly, because that takes a long time. Instead use DynamicMotionMagicVoltage.
| * Command to drive a swerve drive to a specified state using trapezoidal motion profiling and PID | ||
| * for translation and rotation. | ||
| */ | ||
| public class DriveToStateCommand extends Command { |
There was a problem hiding this comment.
You don't need to slow down the robot when running DriveToStateCommand.
| DogLog.log("Brownout/CurrentBudget", currentBudget); | ||
| DogLog.log("Brownout/ProtectionBudget", protectionBudget); | ||
| DogLog.log("Brownout/DriveScale", driveScale); | ||
| DogLog.log("Brownout/MechanismScale", mechanismScale); |
There was a problem hiding this comment.
Instead of Brownout/, nest these under BrownoutProtection/ to match the class name.
| ShooterHoodConstants.MOTOR_CONFIGURATION.MotionMagic.MotionMagicAcceleration; | ||
| private double motionProfileConstraintScale = 1.0; | ||
| private double appliedCruiseVelocity = Double.NaN; | ||
| private double appliedAcceleration = Double.NaN; |
There was a problem hiding this comment.
These last two don't appear to be used, so you can just remove them.
| @@ -1 +1 @@ | |||
| package frc.robot.subsystems.intakeextension; | |||
There was a problem hiding this comment.
Same comments as ShooterHood.
| } | ||
|
|
||
| public void setMotionProfileConstraintScale(double scale) { | ||
| motionProfileConstraintScale = MathUtil.clamp(Math.round(scale * 20.0) / 20.0, 0.1, 1.0); |
There was a problem hiding this comment.
This shouldn't be rounded.
| * clamp target angles within a safe range. The subsystem also includes extensive logging of status | ||
| * signals and control requests for debugging and tuning purposes. | ||
| */ | ||
| public class Turret extends SubsystemBase { |
There was a problem hiding this comment.
Same comments as ShooterHood.
BrownProtection runs every robot loop at runtime, reading battery voltage from RobotController and total robot current from CurrentDrawLogger, smooths both with a 10-sample moving average, and converts them into normalized budgets (voltage budget and current budget). It then takes the worst of those budgets, and that becomes protectionBudget. Then it generates a difference and separates it into driveScale and mechanismScale. The drivetrain is prioritized, while aiming and extension mechanisms are slowed more aggressively.