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

@@ -5,8 +5,8 @@ import com.ctre.phoenix.motorcontrol.DemandType;
import com.ctre.phoenix.motorcontrol.FeedbackDevice;
import com.ctre.phoenix.motorcontrol.NeutralMode;
import com.ctre.phoenix.motorcontrol.SupplyCurrentLimitConfiguration;
import com.ctre.phoenix.motorcontrol.can.TalonFX;
import com.ctre.phoenix.motorcontrol.can.TalonFXConfiguration;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
import com.ctre.phoenix.sensors.AbsoluteSensorRange;
import com.ctre.phoenix.sensors.CANCoder;
import com.ctre.phoenix.sensors.SensorInitializationStrategy;
@@ -26,7 +26,7 @@ public class CTRESwerveMotor extends SwerveMotor
private final int m_mainPIDSlotId;
private final int m_mainPidId;
private final Supplier<Double> m_encoderRet;
private final TalonFX m_motor;
private final WPI_TalonFX m_motor;
/**
* kV feed forward for PID
@@ -34,7 +34,7 @@ public class CTRESwerveMotor extends SwerveMotor
private final double m_moduleRadkV;
// TODO: Finish this based off of BaseFalconSwerve
public CTRESwerveMotor(TalonFX motor, SwerveEncoder<?> encoder, ModuleMotorType type, double gearRatio,
public CTRESwerveMotor(WPI_TalonFX motor, SwerveEncoder<?> encoder, ModuleMotorType type, double gearRatio,
double wheelDiameter,
double freeSpeedRPM, double powerLimit)
{
@@ -197,6 +197,17 @@ public class CTRESwerveMotor extends SwerveMotor
m_motor.set(ControlMode.PercentOutput, speed);
}
/**
* Set the voltage of the motor.
*
* @param voltage Voltage to output.
*/
@Override
public void setVoltage(double voltage)
{
m_motor.setVoltage(voltage);
}
/**
* Get the current value of the encoder corresponding to the PID.
*