More work bringing 2026 into 2027, ignoring errors for pos/vel conversion factor for now
This commit is contained in:
38
src/main/java/first/robot/utilities/SparkMAXTester.java
Normal file
38
src/main/java/first/robot/utilities/SparkMAXTester.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package first.robot.utilities;
|
||||
|
||||
import java.util.function.DoubleSupplier;
|
||||
|
||||
import org.wpilib.command2.Command;
|
||||
import org.wpilib.command2.SubsystemBase;
|
||||
import org.wpilib.hardware.bus.CANPort;
|
||||
|
||||
import com.revrobotics.spark.SparkLowLevel.MotorType;
|
||||
import com.revrobotics.spark.SparkMax;
|
||||
|
||||
/**
|
||||
* A simple subsystem that can be used to test a single SparkMax and associated NEO motor
|
||||
*/
|
||||
public class SparkMAXTester extends SubsystemBase {
|
||||
private SparkMax spark;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param deviceID The CAN ID of the SparkMAX that needs testing
|
||||
*/
|
||||
public SparkMAXTester(CANPort canPort, int deviceID) {
|
||||
spark = new SparkMax(canPort, deviceID, MotorType.kBrushless);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the speed of the motor
|
||||
*
|
||||
* @param speed A method or lambda which returns a double between -1 and 1
|
||||
* @return A Command object that runs indefinitely to control motor speed
|
||||
*/
|
||||
public Command setSpeed(DoubleSupplier speed) {
|
||||
return run(() -> {
|
||||
spark.setThrottle(speed.getAsDouble());
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user