- Motor 1 (
shooterNeo1
): Controls the top roller. - Motor 2 (
shooterNeo2
): Controls the bottom roller. - Both motors are set to brake mode to prevent them from spinning when not powered.
PID Control
PID Controller Initialization
The Shooter
subsystem uses two SparkPIDController
instances to manage the velocity of the two motors:
PID Coefficients
The following coefficients are used for the PID control of both motors:
These coefficients determine how the motors respond to velocity errors and are used to fine-tune the shooter’s performance. The m_pidController1
and m_pidController2
are configured with these values.
Movement Control
move(double speed)
This method directly sets the speed for both motors. The top and bottom rollers move in opposite directions:
setShooterRPM(double input)
Sets the RPM for both shooter motors using the PID controller. If the input RPM exceeds the defined maximum RPM (ShooterConstants.maxRPM
), the method logs a warning message:
This ensures that the shooter motors do not exceed the maximum RPM limit and maintains accurate velocity control.
Motor Modes
setBrakeMode(IdleMode mode)
This method allows switching between brake and coast modes for the motors:
- Brake Mode: Stops the motors immediately when power is cut, ensuring no continued motion.
- Coast Mode: Allows the motors to gradually slow down when power is cut, useful for smoother stopping in some cases.
coast()
Stops both shooter motors by setting their speed to zero:
Telemetry
The subsystem uses SmartDashboard
to display telemetry data for monitoring shooter performance:
Telemetry includes:
- Shooter RPM: Displays the current velocity of both motors.
- Shooter Voltage: Displays the voltage supplied to the motors.
Periodic Functions
periodic()
This method runs every scheduler cycle and can be used to update telemetry data:
simulationPeriodic()
This method is used during simulations:
Future Enhancements
- Implement more advanced control algorithms to dynamically adjust RPM based on game conditions.
- Further tune the PID coefficients for enhanced performance during high-speed shooting.
- Add more telemetry data to monitor motor temperature and other important metrics during competition.
This documentation provides a structured overview of the Shooter subsystem, including details on motor control, PID settings, telemetry, and motor modes. It also suggests future improvements to enhance performance.