13 #include "ErrorBase.h"
14 #include "MotorSafety.h"
15 #include "MotorSafetyHelper.h"
41 RobotDrive(
int leftMotorChannel,
int rightMotorChannel);
42 RobotDrive(
int frontLeftMotorChannel,
int rearLeftMotorChannel,
43 int frontRightMotorChannel,
int rearRightMotorChannel);
46 RobotDrive(std::shared_ptr<SpeedController> leftMotor,
47 std::shared_ptr<SpeedController> rightMotor);
52 RobotDrive(std::shared_ptr<SpeedController> frontLeftMotor,
53 std::shared_ptr<SpeedController> rearLeftMotor,
54 std::shared_ptr<SpeedController> frontRightMotor,
55 std::shared_ptr<SpeedController> rearRightMotor);
61 void Drive(
double outputMagnitude,
double curve);
63 bool squaredInputs =
true);
65 bool squaredInputs =
true);
67 int rightAxis,
bool squaredInputs =
true);
69 int rightAxis,
bool squaredInputs =
true);
70 void TankDrive(
double leftValue,
double rightValue,
71 bool squaredInputs =
true);
76 bool squaredInputs =
true);
79 bool squaredInputs =
true);
80 void ArcadeDrive(
double moveValue,
double rotateValue,
81 bool squaredInputs =
true);
83 double gyroAngle = 0.0);
85 void HolonomicDrive(
double magnitude,
double direction,
double rotation);
87 void SetInvertedMotor(MotorType motor,
bool isInverted);
91 void SetExpiration(
double timeout)
override;
92 double GetExpiration()
const override;
93 bool IsAlive()
const override;
94 void StopMotor()
override;
95 bool IsSafetyEnabled()
const override;
96 void SetSafetyEnabled(
bool enabled)
override;
97 void GetDescription(std::ostringstream& desc)
const override;
101 double Limit(
double number);
105 static const int kMaxNumberOfMotors = 4;
106 double m_sensitivity = 0.5;
107 double m_maxOutput = 1.0;
108 std::shared_ptr<SpeedController> m_frontLeftMotor;
109 std::shared_ptr<SpeedController> m_frontRightMotor;
110 std::shared_ptr<SpeedController> m_rearLeftMotor;
111 std::shared_ptr<SpeedController> m_rearRightMotor;
112 std::unique_ptr<MotorSafetyHelper> m_safetyHelper;
117 if (m_frontLeftMotor) motors++;
118 if (m_frontRightMotor) motors++;
119 if (m_rearLeftMotor) motors++;
120 if (m_rearRightMotor) motors++;
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:701
Utility class for handling Robot drive based on a definition of the motor configuration.
Definition: RobotDrive.h:32
virtual void SetLeftRightMotorOutputs(double leftOutput, double rightOutput)
Set the speed of the right and left motors.
Definition: RobotDrive.cpp:595
void MecanumDrive_Polar(double magnitude, double direction, double rotation)
Drive method for Mecanum wheeled robots.
Definition: RobotDrive.cpp:536
void Drive(double outputMagnitude, double curve)
Drive the motors at "outputMagnitude" and "curve".
Definition: RobotDrive.cpp:217
Definition: MotorSafety.h:16
void TankDrive(GenericHID *leftStick, GenericHID *rightStick, bool squaredInputs=true)
Provide tank steering using the stored robot configuration.
Definition: RobotDrive.cpp:254
RobotDrive(int leftMotorChannel, int rightMotorChannel)
Constructor for RobotDrive with 2 motors specified with channel numbers.
Definition: RobotDrive.cpp:60
void HolonomicDrive(double magnitude, double direction, double rotation)
Holonomic Drive method for Mecanum wheeled robots.
Definition: RobotDrive.cpp:580
double Limit(double number)
Limit motor values to the -1.0 to +1.0 range.
Definition: RobotDrive.cpp:613
Base class for most objects.
Definition: ErrorBase.h:72
void RotateVector(double &x, double &y, double angle)
Rotate a vector in Cartesian space.
Definition: RobotDrive.cpp:642
void MecanumDrive_Cartesian(double x, double y, double rotation, double gyroAngle=0.0)
Drive method for Mecanum wheeled robots.
Definition: RobotDrive.cpp:487
void Normalize(double *wheelSpeeds)
Normalize all wheel speeds if the magnitude of any wheel is greater than 1.0.
Definition: RobotDrive.cpp:626
void ArcadeDrive(GenericHID *stick, bool squaredInputs=true)
Arcade drive implements single stick driving.
Definition: RobotDrive.cpp:341
GenericHID Interface.
Definition: GenericHID.h:21
void InitRobotDrive()
Common function to initialize all the robot drive constructors.
Definition: RobotDrive.cpp:43
void SetSensitivity(double sensitivity)
Set the turning sensitivity.
Definition: RobotDrive.cpp:690