mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
Remove MotorSafetyHelper, create MotorSafety base class instead (#562)
Most of the MotorSafety implementation was moved into the MotorSafety base class. SafePWM's inheritance of MotorSafety was moved into PWM to eliminate Java needing a helper class. In Java, a helper class for Sendable (SendableImpl) was added due to lack of multiple inheritance.
This commit is contained in:
committed by
Peter Johnson
parent
df347e3d80
commit
acb786a791
@@ -79,7 +79,7 @@ void DifferentialDrive::ArcadeDrive(double xSpeed, double zRotation,
|
||||
m_rightMotor.Set(Limit(rightMotorOutput) * m_maxOutput *
|
||||
m_rightSideInvertMultiplier);
|
||||
|
||||
m_safetyHelper.Feed();
|
||||
Feed();
|
||||
}
|
||||
|
||||
void DifferentialDrive::CurvatureDrive(double xSpeed, double zRotation,
|
||||
@@ -152,7 +152,7 @@ void DifferentialDrive::CurvatureDrive(double xSpeed, double zRotation,
|
||||
m_rightMotor.Set(rightMotorOutput * m_maxOutput *
|
||||
m_rightSideInvertMultiplier);
|
||||
|
||||
m_safetyHelper.Feed();
|
||||
Feed();
|
||||
}
|
||||
|
||||
void DifferentialDrive::TankDrive(double leftSpeed, double rightSpeed,
|
||||
@@ -180,7 +180,7 @@ void DifferentialDrive::TankDrive(double leftSpeed, double rightSpeed,
|
||||
m_leftMotor.Set(leftSpeed * m_maxOutput);
|
||||
m_rightMotor.Set(rightSpeed * m_maxOutput * m_rightSideInvertMultiplier);
|
||||
|
||||
m_safetyHelper.Feed();
|
||||
Feed();
|
||||
}
|
||||
|
||||
void DifferentialDrive::SetQuickStopThreshold(double threshold) {
|
||||
@@ -202,7 +202,7 @@ void DifferentialDrive::SetRightSideInverted(bool rightSideInverted) {
|
||||
void DifferentialDrive::StopMotor() {
|
||||
m_leftMotor.StopMotor();
|
||||
m_rightMotor.StopMotor();
|
||||
m_safetyHelper.Feed();
|
||||
Feed();
|
||||
}
|
||||
|
||||
void DifferentialDrive::GetDescription(wpi::raw_ostream& desc) const {
|
||||
|
||||
@@ -73,7 +73,7 @@ void KilloughDrive::DriveCartesian(double ySpeed, double xSpeed,
|
||||
m_rightMotor.Set(wheelSpeeds[kRight] * m_maxOutput);
|
||||
m_backMotor.Set(wheelSpeeds[kBack] * m_maxOutput);
|
||||
|
||||
m_safetyHelper.Feed();
|
||||
Feed();
|
||||
}
|
||||
|
||||
void KilloughDrive::DrivePolar(double magnitude, double angle,
|
||||
@@ -92,7 +92,7 @@ void KilloughDrive::StopMotor() {
|
||||
m_leftMotor.StopMotor();
|
||||
m_rightMotor.StopMotor();
|
||||
m_backMotor.StopMotor();
|
||||
m_safetyHelper.Feed();
|
||||
Feed();
|
||||
}
|
||||
|
||||
void KilloughDrive::GetDescription(wpi::raw_ostream& desc) const {
|
||||
|
||||
@@ -70,7 +70,7 @@ void MecanumDrive::DriveCartesian(double ySpeed, double xSpeed,
|
||||
m_rearRightMotor.Set(wheelSpeeds[kRearRight] * m_maxOutput *
|
||||
m_rightSideInvertMultiplier);
|
||||
|
||||
m_safetyHelper.Feed();
|
||||
Feed();
|
||||
}
|
||||
|
||||
void MecanumDrive::DrivePolar(double magnitude, double angle,
|
||||
@@ -98,7 +98,7 @@ void MecanumDrive::StopMotor() {
|
||||
m_frontRightMotor.StopMotor();
|
||||
m_rearLeftMotor.StopMotor();
|
||||
m_rearRightMotor.StopMotor();
|
||||
m_safetyHelper.Feed();
|
||||
Feed();
|
||||
}
|
||||
|
||||
void MecanumDrive::GetDescription(wpi::raw_ostream& desc) const {
|
||||
|
||||
@@ -18,31 +18,13 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
RobotDriveBase::RobotDriveBase() { m_safetyHelper.SetSafetyEnabled(true); }
|
||||
RobotDriveBase::RobotDriveBase() { SetSafetyEnabled(true); }
|
||||
|
||||
void RobotDriveBase::SetDeadband(double deadband) { m_deadband = deadband; }
|
||||
|
||||
void RobotDriveBase::SetMaxOutput(double maxOutput) { m_maxOutput = maxOutput; }
|
||||
|
||||
void RobotDriveBase::FeedWatchdog() { m_safetyHelper.Feed(); }
|
||||
|
||||
void RobotDriveBase::SetExpiration(double timeout) {
|
||||
m_safetyHelper.SetExpiration(timeout);
|
||||
}
|
||||
|
||||
double RobotDriveBase::GetExpiration() const {
|
||||
return m_safetyHelper.GetExpiration();
|
||||
}
|
||||
|
||||
bool RobotDriveBase::IsAlive() const { return m_safetyHelper.IsAlive(); }
|
||||
|
||||
bool RobotDriveBase::IsSafetyEnabled() const {
|
||||
return m_safetyHelper.IsSafetyEnabled();
|
||||
}
|
||||
|
||||
void RobotDriveBase::SetSafetyEnabled(bool enabled) {
|
||||
m_safetyHelper.SetSafetyEnabled(enabled);
|
||||
}
|
||||
void RobotDriveBase::FeedWatchdog() { Feed(); }
|
||||
|
||||
double RobotDriveBase::Limit(double value) {
|
||||
if (value > 1.0) {
|
||||
|
||||
Reference in New Issue
Block a user