12 #include <wpi/deprecated.h> 13 #include <wpi/raw_ostream.h> 15 #include "ErrorBase.h" 16 #include "MotorSafety.h" 17 #include "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
void SetMaxOutput(double maxOutput)
Configure the scaling factor for using RobotDrive with motor controllers in a mode other than Percent...
Definition: RobotDrive.cpp:381
Definition: Utility.cpp:119
Utility class for handling Robot drive based on a definition of the motor configuration.
Definition: RobotDrive.h:35
virtual void SetLeftRightMotorOutputs(double leftOutput, double rightOutput)
Set the speed of the right and left motors.
Definition: RobotDrive.cpp:341
void MecanumDrive_Polar(double magnitude, double direction, double rotation)
Drive method for Mecanum wheeled robots.
Definition: RobotDrive.cpp:304
void Drive(double outputMagnitude, double curve)
Drive the motors at "outputMagnitude" and "curve".
Definition: RobotDrive.cpp:119
Definition: MotorSafety.h:16
void TankDrive(GenericHID *leftStick, GenericHID *rightStick, bool squaredInputs=true)
Provide tank steering using the stored robot configuration.
Definition: RobotDrive.cpp:147
RobotDrive(int leftMotorChannel, int rightMotorChannel)
Constructor for RobotDrive with 2 motors specified with channel numbers.
Definition: RobotDrive.cpp:28
void HolonomicDrive(double magnitude, double direction, double rotation)
Holonomic Drive method for Mecanum wheeled robots.
Definition: RobotDrive.cpp:336
double Limit(double number)
Limit motor values to the -1.0 to +1.0 range.
Definition: RobotDrive.cpp:418
Base class for most objects.
Definition: ErrorBase.h:74
void RotateVector(double &x, double &y, double angle)
Rotate a vector in Cartesian space.
Definition: RobotDrive.cpp:441
void MecanumDrive_Cartesian(double x, double y, double rotation, double gyroAngle=0.0)
Drive method for Mecanum wheeled robots.
Definition: RobotDrive.cpp:272
void Normalize(double *wheelSpeeds)
Normalize all wheel speeds if the magnitude of any wheel is greater than 1.0.
Definition: RobotDrive.cpp:428
void ArcadeDrive(GenericHID *stick, bool squaredInputs=true)
Arcade drive implements single stick driving.
Definition: RobotDrive.cpp:201
GenericHID Interface.
Definition: GenericHID.h:23
void InitRobotDrive()
Common function to initialize all the robot drive constructors.
Definition: RobotDrive.cpp:413
void SetSensitivity(double sensitivity)
Set the turning sensitivity.
Definition: RobotDrive.cpp:377