Arctos6135 / frc-2024

Other
1 stars 1 forks source link

Replace calls to sparkmax.set with calls to sparkmax.setVoltage #37

Closed n-arms closed 7 months ago

n-arms commented 7 months ago

In all of our *IOSparkMax setVoltage methods, we call motor.set(targetVoltage) instead of motor.setVoltage(targetVoltage). .set is supposed to take a parameter in the range -1 to 1, not -12 to 12, so we need to switch to .setVoltage.

SomewhatMay commented 7 months ago

Although this may be a bad idea, since we are using IO classes as a middleware for voltages, we could technically just divide the voltage by 12 to get a range between -1 and 1 (clamp the value to ensure it doesn't go over the bounds as well).

n-arms commented 7 months ago

@SomewhatMay I don't think that's ideal because on many motor controllers .set takes a percentage of the current battery voltage, which means our mechanism will behave very differently for different battery voltages, which means it'll drive slower if we want to run the shooter while driving. Sparkmaxes might actually not do that, but I'd rather not find out.