mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
artf4107: clang-modernize was run on WPILib
Loops were converted to their range-based equivalents, variable types were replaced with auto where the type was already specified on the same line, the override keyword was added, and instances of NULL and assignments of 0 to pointers were replaced with nullptr. Change-Id: If281e46a2e2e1c37f278d56df9915236d4b2c864
This commit is contained in:
@@ -37,10 +37,10 @@ const int32_t RobotDrive::kMaxNumberOfMotors;
|
||||
* robot drive.
|
||||
*/
|
||||
void RobotDrive::InitRobotDrive() {
|
||||
m_frontLeftMotor = NULL;
|
||||
m_frontRightMotor = NULL;
|
||||
m_rearRightMotor = NULL;
|
||||
m_rearLeftMotor = NULL;
|
||||
m_frontLeftMotor = nullptr;
|
||||
m_frontRightMotor = nullptr;
|
||||
m_rearRightMotor = nullptr;
|
||||
m_rearLeftMotor = nullptr;
|
||||
m_sensitivity = 0.5;
|
||||
m_maxOutput = 1.0;
|
||||
m_safetyHelper = new MotorSafetyHelper(this);
|
||||
@@ -105,9 +105,9 @@ RobotDrive::RobotDrive(uint32_t frontLeftMotor, uint32_t rearLeftMotor,
|
||||
RobotDrive::RobotDrive(SpeedController *leftMotor,
|
||||
SpeedController *rightMotor) {
|
||||
InitRobotDrive();
|
||||
if (leftMotor == NULL || rightMotor == NULL) {
|
||||
if (leftMotor == nullptr || rightMotor == nullptr) {
|
||||
wpi_setWPIError(NullParameter);
|
||||
m_rearLeftMotor = m_rearRightMotor = NULL;
|
||||
m_rearLeftMotor = m_rearRightMotor = nullptr;
|
||||
return;
|
||||
}
|
||||
m_rearLeftMotor = leftMotor;
|
||||
@@ -141,8 +141,8 @@ RobotDrive::RobotDrive(SpeedController *frontLeftMotor,
|
||||
SpeedController *frontRightMotor,
|
||||
SpeedController *rearRightMotor) {
|
||||
InitRobotDrive();
|
||||
if (frontLeftMotor == NULL || rearLeftMotor == NULL ||
|
||||
frontRightMotor == NULL || rearRightMotor == NULL) {
|
||||
if (frontLeftMotor == nullptr || rearLeftMotor == nullptr ||
|
||||
frontRightMotor == nullptr || rearRightMotor == nullptr) {
|
||||
wpi_setWPIError(NullParameter);
|
||||
return;
|
||||
}
|
||||
@@ -230,7 +230,7 @@ void RobotDrive::Drive(float outputMagnitude, float curve) {
|
||||
*/
|
||||
void RobotDrive::TankDrive(GenericHID *leftStick, GenericHID *rightStick,
|
||||
bool squaredInputs) {
|
||||
if (leftStick == NULL || rightStick == NULL) {
|
||||
if (leftStick == nullptr || rightStick == nullptr) {
|
||||
wpi_setWPIError(NullParameter);
|
||||
return;
|
||||
}
|
||||
@@ -255,7 +255,7 @@ void RobotDrive::TankDrive(GenericHID &leftStick, GenericHID &rightStick,
|
||||
void RobotDrive::TankDrive(GenericHID *leftStick, uint32_t leftAxis,
|
||||
GenericHID *rightStick, uint32_t rightAxis,
|
||||
bool squaredInputs) {
|
||||
if (leftStick == NULL || rightStick == NULL) {
|
||||
if (leftStick == nullptr || rightStick == nullptr) {
|
||||
wpi_setWPIError(NullParameter);
|
||||
return;
|
||||
}
|
||||
@@ -591,13 +591,13 @@ void RobotDrive::HolonomicDrive(float magnitude, float direction,
|
||||
* @param rightOutput The speed to send to the right side of the robot.
|
||||
*/
|
||||
void RobotDrive::SetLeftRightMotorOutputs(float leftOutput, float rightOutput) {
|
||||
wpi_assert(m_rearLeftMotor != NULL && m_rearRightMotor != NULL);
|
||||
wpi_assert(m_rearLeftMotor != nullptr && m_rearRightMotor != nullptr);
|
||||
|
||||
if (m_frontLeftMotor != NULL)
|
||||
if (m_frontLeftMotor != nullptr)
|
||||
m_frontLeftMotor->Set(Limit(leftOutput) * m_maxOutput, m_syncGroup);
|
||||
m_rearLeftMotor->Set(Limit(leftOutput) * m_maxOutput, m_syncGroup);
|
||||
|
||||
if (m_frontRightMotor != NULL)
|
||||
if (m_frontRightMotor != nullptr)
|
||||
m_frontRightMotor->Set(-Limit(rightOutput) * m_maxOutput, m_syncGroup);
|
||||
m_rearRightMotor->Set(-Limit(rightOutput) * m_maxOutput, m_syncGroup);
|
||||
|
||||
@@ -734,9 +734,9 @@ void RobotDrive::GetDescription(char *desc) const {
|
||||
}
|
||||
|
||||
void RobotDrive::StopMotor() {
|
||||
if (m_frontLeftMotor != NULL) m_frontLeftMotor->Disable();
|
||||
if (m_frontRightMotor != NULL) m_frontRightMotor->Disable();
|
||||
if (m_rearLeftMotor != NULL) m_rearLeftMotor->Disable();
|
||||
if (m_rearRightMotor != NULL) m_rearRightMotor->Disable();
|
||||
if (m_frontLeftMotor != nullptr) m_frontLeftMotor->Disable();
|
||||
if (m_frontRightMotor != nullptr) m_frontRightMotor->Disable();
|
||||
if (m_rearLeftMotor != nullptr) m_rearLeftMotor->Disable();
|
||||
if (m_rearRightMotor != nullptr) m_rearRightMotor->Disable();
|
||||
m_safetyHelper->Feed();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user