12 #include <wpi/deprecated.h>
13 #include <wpi/raw_ostream.h>
15 #include "frc/ErrorBase.h"
16 #include "frc/MotorSafety.h"
17 #include "frc/MotorSafetyHelper.h"
21 class SpeedController;
56 WPI_DEPRECATED(
"Use DifferentialDrive or MecanumDrive classes instead.")
57 RobotDrive(
int leftMotorChannel,
int rightMotorChannel);
75 WPI_DEPRECATED(
"Use DifferentialDrive or MecanumDrive classes instead.")
76 RobotDrive(
int frontLeftMotorChannel,
int rearLeftMotorChannel,
77 int frontRightMotorChannel,
int rearRightMotorChannel);
91 WPI_DEPRECATED(
"Use DifferentialDrive or MecanumDrive classes instead.")
94 WPI_DEPRECATED(
"Use DifferentialDrive or MecanumDrive classes instead.")
97 WPI_DEPRECATED(
"Use DifferentialDrive or MecanumDrive classes instead.")
98 RobotDrive(std::shared_ptr<SpeedController> leftMotor,
99 std::shared_ptr<SpeedController> rightMotor);
116 WPI_DEPRECATED(
"Use DifferentialDrive or MecanumDrive classes instead.")
120 WPI_DEPRECATED(
"Use DifferentialDrive or MecanumDrive classes instead.")
124 WPI_DEPRECATED(
"Use DifferentialDrive or MecanumDrive classes instead.")
125 RobotDrive(std::shared_ptr<SpeedController> frontLeftMotor,
126 std::shared_ptr<SpeedController> rearLeftMotor,
127 std::shared_ptr<SpeedController> frontRightMotor,
128 std::shared_ptr<SpeedController> rearRightMotor);
158 void Drive(
double outputMagnitude,
double curve);
172 bool squaredInputs =
true);
186 bool squaredInputs =
true);
204 int rightAxis,
bool squaredInputs =
true);
207 int rightAxis,
bool squaredInputs =
true);
219 void TankDrive(
double leftValue,
double rightValue,
220 bool squaredInputs =
true);
270 bool squaredInputs =
true);
290 bool squaredInputs =
true);
301 void ArcadeDrive(
double moveValue,
double rotateValue,
302 bool squaredInputs =
true);
326 double gyroAngle = 0.0);
359 void HolonomicDrive(
double magnitude,
double direction,
double rotation);
383 void SetInvertedMotor(MotorType motor,
bool isInverted);
404 void SetExpiration(
double timeout)
override;
405 double GetExpiration()
const override;
406 bool IsAlive()
const override;
407 void StopMotor()
override;
408 bool IsSafetyEnabled()
const override;
409 void SetSafetyEnabled(
bool enabled)
override;
425 double Limit(
double number);
438 static constexpr
int kMaxNumberOfMotors = 4;
440 double m_sensitivity = 0.5;
441 double m_maxOutput = 1.0;
443 std::shared_ptr<SpeedController> m_frontLeftMotor;
444 std::shared_ptr<SpeedController> m_frontRightMotor;
445 std::shared_ptr<SpeedController> m_rearLeftMotor;
446 std::shared_ptr<SpeedController> m_rearRightMotor;
447 std::unique_ptr<MotorSafetyHelper> m_safetyHelper;
452 if (m_frontLeftMotor) motors++;
453 if (m_frontRightMotor) motors++;
454 if (m_rearLeftMotor) motors++;
455 if (m_rearRightMotor) motors++;
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
Interface for speed controlling devices.
Definition: SpeedController.h:17
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
Utility class for handling Robot drive based on a definition of the motor configuration.
Definition: RobotDrive.h:35
double Limit(double number)
Limit motor values to the -1.0 to +1.0 range.
void ArcadeDrive(GenericHID *stick, bool squaredInputs=true)
Arcade drive implements single stick driving.
void InitRobotDrive()
Common function to initialize all the robot drive constructors.
void RotateVector(double &x, double &y, double angle)
Rotate a vector in Cartesian space.
void MecanumDrive_Polar(double magnitude, double direction, double rotation)
Drive method for Mecanum wheeled robots.
Definition: MotorSafety.h:16
void SetSensitivity(double sensitivity)
Set the turning sensitivity.
virtual void SetLeftRightMotorOutputs(double leftOutput, double rightOutput)
Set the speed of the right and left motors.
void HolonomicDrive(double magnitude, double direction, double rotation)
Holonomic Drive method for Mecanum wheeled robots.
void TankDrive(GenericHID *leftStick, GenericHID *rightStick, bool squaredInputs=true)
Provide tank steering using the stored robot configuration.
void Drive(double outputMagnitude, double curve)
Drive the motors at "outputMagnitude" and "curve".
Base class for most objects.
Definition: ErrorBase.h:74
GenericHID Interface.
Definition: GenericHID.h:23
void SetMaxOutput(double maxOutput)
Configure the scaling factor for using RobotDrive with motor controllers in a mode other than Percent...
RobotDrive(int leftMotorChannel, int rightMotorChannel)
Constructor for RobotDrive with 2 motors specified with channel numbers.
void Normalize(double *wheelSpeeds)
Normalize all wheel speeds if the magnitude of any wheel is greater than 1.0.
void MecanumDrive_Cartesian(double x, double y, double rotation, double gyroAngle=0.0)
Drive method for Mecanum wheeled robots.