Added setVoltage function to swerve motors, made SwervePoseEstimator public, and changed setting targetVelocity to inside setState

This commit is contained in:
thenetworkgrinch
2023-01-31 10:42:02 -06:00
parent b1a4d0e370
commit c3d6df94d0
5 changed files with 66 additions and 29 deletions

View File

@@ -1,6 +1,6 @@
package frc.robot.subsystems.swervedrive.swerve;
import com.ctre.phoenix.motorcontrol.can.TalonFX;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
import com.revrobotics.CANSparkMax;
import edu.wpi.first.wpilibj.motorcontrol.MotorController;
import frc.robot.subsystems.swervedrive.swerve.motors.CTRESwerveMotor;
@@ -54,9 +54,9 @@ public abstract class SwerveMotor
freeSpeedRPM,
powerLimit);
}
if (motor instanceof TalonFX)
if (motor instanceof WPI_TalonFX)
{
return new CTRESwerveMotor((TalonFX) motor,
return new CTRESwerveMotor((WPI_TalonFX) motor,
absoluteEncoder,
type,
gearRatio,
@@ -120,6 +120,13 @@ public abstract class SwerveMotor
*/
public abstract void set(double speed);
/**
* Set the voltage of the motor.
*
* @param voltage Voltage to output.
*/
public abstract void setVoltage(double voltage);
/**
* Get the current value of the encoder corresponding to the PID.
*