12 #include <llvm/raw_ostream.h> 13 #include <support/deprecated.h> 15 #include "ErrorBase.h" 16 #include "MotorSafety.h" 17 #include "MotorSafetyHelper.h" 44 WPI_DEPRECATED(
"Use DifferentialDrive or MecanumDrive classes instead.")
45 RobotDrive(
int leftMotorChannel,
int rightMotorChannel);
46 WPI_DEPRECATED(
"Use DifferentialDrive or MecanumDrive classes instead.")
47 RobotDrive(
int frontLeftMotorChannel,
int rearLeftMotorChannel,
48 int frontRightMotorChannel,
int rearRightMotorChannel);
49 WPI_DEPRECATED(
"Use DifferentialDrive or MecanumDrive classes instead.")
51 WPI_DEPRECATED(
"Use DifferentialDrive or MecanumDrive classes instead.")
53 WPI_DEPRECATED(
"Use DifferentialDrive or MecanumDrive classes instead.")
54 RobotDrive(std::shared_ptr<SpeedController> leftMotor,
55 std::shared_ptr<SpeedController> rightMotor);
56 WPI_DEPRECATED(
"Use DifferentialDrive or MecanumDrive classes instead.")
59 WPI_DEPRECATED(
"Use DifferentialDrive or MecanumDrive classes instead.")
62 WPI_DEPRECATED(
"Use DifferentialDrive or MecanumDrive classes instead.")
63 RobotDrive(std::shared_ptr<SpeedController> frontLeftMotor,
64 std::shared_ptr<SpeedController> rearLeftMotor,
65 std::shared_ptr<SpeedController> frontRightMotor,
66 std::shared_ptr<SpeedController> rearRightMotor);
72 void Drive(
double outputMagnitude,
double curve);
74 bool squaredInputs =
true);
76 bool squaredInputs =
true);
78 int rightAxis,
bool squaredInputs =
true);
80 int rightAxis,
bool squaredInputs =
true);
81 void TankDrive(
double leftValue,
double rightValue,
82 bool squaredInputs =
true);
87 bool squaredInputs =
true);
90 bool squaredInputs =
true);
91 void ArcadeDrive(
double moveValue,
double rotateValue,
92 bool squaredInputs =
true);
94 double gyroAngle = 0.0);
96 void HolonomicDrive(
double magnitude,
double direction,
double rotation);
98 void SetInvertedMotor(MotorType motor,
bool isInverted);
102 void SetExpiration(
double timeout)
override;
103 double GetExpiration()
const override;
104 bool IsAlive()
const override;
105 void StopMotor()
override;
106 bool IsSafetyEnabled()
const override;
107 void SetSafetyEnabled(
bool enabled)
override;
112 double Limit(
double number);
116 static constexpr
int kMaxNumberOfMotors = 4;
118 double m_sensitivity = 0.5;
119 double m_maxOutput = 1.0;
121 std::shared_ptr<SpeedController> m_frontLeftMotor;
122 std::shared_ptr<SpeedController> m_frontRightMotor;
123 std::shared_ptr<SpeedController> m_rearLeftMotor;
124 std::shared_ptr<SpeedController> m_rearRightMotor;
125 std::unique_ptr<MotorSafetyHelper> m_safetyHelper;
130 if (m_frontLeftMotor) motors++;
131 if (m_frontRightMotor) motors++;
132 if (m_rearLeftMotor) motors++;
133 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:718
Definition: RobotController.cpp:14
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:612
void MecanumDrive_Polar(double magnitude, double direction, double rotation)
Drive method for Mecanum wheeled robots.
Definition: RobotDrive.cpp:553
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:256
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:597
double Limit(double number)
Limit motor values to the -1.0 to +1.0 range.
Definition: RobotDrive.cpp:630
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:659
void MecanumDrive_Cartesian(double x, double y, double rotation, double gyroAngle=0.0)
Drive method for Mecanum wheeled robots.
Definition: RobotDrive.cpp:504
void Normalize(double *wheelSpeeds)
Normalize all wheel speeds if the magnitude of any wheel is greater than 1.0.
Definition: RobotDrive.cpp:643
void ArcadeDrive(GenericHID *stick, bool squaredInputs=true)
Arcade drive implements single stick driving.
Definition: RobotDrive.cpp:358
GenericHID Interface.
Definition: GenericHID.h:23
void InitRobotDrive()
Common function to initialize all the robot drive constructors.
Definition: RobotDrive.cpp:43
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:33
void SetSensitivity(double sensitivity)
Set the turning sensitivity.
Definition: RobotDrive.cpp:707