Add setVoltage method to SpeedController (#1997)

Add a voltage-compensated setVoltage method to SpeedController, which is sorely needed to help teams use feedforward-based controls effectively. Also uses correct units on the cpp side.

Also update relevant examples.
This commit is contained in:
Oblarg
2019-11-01 12:32:40 -04:00
committed by Peter Johnson
parent f6e311ef86
commit 9ebd23d61e
12 changed files with 88 additions and 39 deletions

View File

@@ -7,6 +7,8 @@
#pragma once
#include <units/units.h>
#include <frc/ADXRS450_Gyro.h>
#include <frc/Encoder.h>
#include <frc/PWMVictorSPX.h>
@@ -38,13 +40,12 @@ class DriveSubsystem : public frc2::SubsystemBase {
void ArcadeDrive(double fwd, double rot);
/**
* Drives the robot using tank controls. Does not square inputs to enable
* composition with external controllers.
* Controls each side of the drive directly with a voltage.
*
* @param left the commanded left output
* @param right the commanded right output
*/
void TankDrive(double left, double right);
void TankDriveVolts(units::volt_t left, units::volt_t right);
/**
* Resets the drive encoders to currently read a position of 0.