You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// TODO: this neo init code was taken straight from the SDS library. It should be moved to SparkSetup after being tested on a live robot
packageorg.bitbuckets.drive.controlsds.neo;
importcom.revrobotics.CANSparkMax;
importcom.revrobotics.CANSparkMaxLowLevel;
importcom.revrobotics.RelativeEncoder;
importorg.bitbuckets.drive.DriveSDSConstants;
importorg.bitbuckets.drive.controlsds.sds.IDriveController;
importorg.bitbuckets.drive.controlsds.sds.SwerveModuleConfiguration;
importorg.bitbuckets.lib.ISetup;
importorg.bitbuckets.lib.ProcessPath;
importorg.bitbuckets.lib.hardware.IMotorController;
importorg.bitbuckets.lib.vendor.spark.SparkSetup;
importstaticorg.bitbuckets.lib.vendor.spark.RevUtils.checkNeoError;
publicclassNeoDriveControllerSetupimplementsISetup<IDriveController> {
finalISetup<IMotorController> motor;
finalSwerveModuleConfigurationswerveModuleConfiguration;
doublenominalVoltage = 12;
doublecurrentLimit = 80;
publicNeoDriveControllerSetup(SparkSetupmotor, SwerveModuleConfigurationswerveModuleConfiguration) {
this.motor = motor;
this.swerveModuleConfiguration = swerveModuleConfiguration;
}
@OverridepublicIDriveControllerbuild(ProcessPathpath) {
// build the motor controller passed in by the caller (Should be a SparkSetup)varmotorController = this.motor.build(path.addChild("drive"));
// configure the raw motor with the same settings for SDS// TODO: this neo init code was taken straight from the SDS library. It should be moved to SparkSetup after being tested on a live robotCANSparkMaxneo = motorController.rawAccess(CANSparkMax.class);
neo.setInverted(swerveModuleConfiguration.isDriveInverted());
// Setup voltage compensationcheckNeoError(neo.enableVoltageCompensation(nominalVoltage), "Failed to enable voltage compensation");
checkNeoError(neo.setSmartCurrentLimit((int) currentLimit), "Failed to set current limit for NEO");
checkNeoError(neo.setPeriodicFramePeriod(CANSparkMaxLowLevel.PeriodicFrame.kStatus0, 100), "Failed to set periodic status frame 0 rate");
checkNeoError(neo.setPeriodicFramePeriod(CANSparkMaxLowLevel.PeriodicFrame.kStatus1, 20), "Failed to set periodic status frame 1 rate");
checkNeoError(neo.setPeriodicFramePeriod(CANSparkMaxLowLevel.PeriodicFrame.kStatus2, 20), "Failed to set periodic status frame 2 rate");
// Set neutral mode to brakeneo.setIdleMode(CANSparkMax.IdleMode.kBrake);
// Setup encoderRelativeEncoderencoder = neo.getEncoder();
doublepositionConversionFactor = Math.PI * swerveModuleConfiguration.getWheelDiameter() * swerveModuleConfiguration.getDriveReduction();
encoder.setPositionConversionFactor(positionConversionFactor);
encoder.setVelocityConversionFactor(positionConversionFactor / 60.0);
// pass our configured motorController back to the DriveControllerreturnnewNeoDriveController(motorController, DriveSDSConstants.nominalVoltage);
}
}
The text was updated successfully, but these errors were encountered:
cpostbitbuckets
changed the title
this neo init code was taken straight from the SDS library. It should be moved t...
Migrate NeoSteerController to use SparkPositionSetup
Jan 28, 2023
The NeoSteerController does configuration on the steer motor using rawAccess. We need to create a spark setup for it instead.
FRC2023-Charged-Up/src/main/java/org/bitbuckets/drive/controlsds/neo/NeoDriveControllerSetup.java
Line 34 in cfeb6f1
The text was updated successfully, but these errors were encountered: