WPILibC++ 2024.3.2
frc::RobotDriveBase Class Referenceabstract

Common base class for drive platforms. More...

#include <frc/drive/RobotDriveBase.h>

Inheritance diagram for frc::RobotDriveBase:
frc::MotorSafety frc::DifferentialDrive frc::MecanumDrive

Public Types

enum  MotorType {
  kFrontLeft = 0 , kFrontRight = 1 , kRearLeft = 2 , kRearRight = 3 ,
  kLeft = 0 , kRight = 1 , kBack = 2
}
 The location of a motor on the robot for the purpose of driving. More...
 

Public Member Functions

 RobotDriveBase ()
 
 ~RobotDriveBase () override=default
 
 RobotDriveBase (RobotDriveBase &&)=default
 
RobotDriveBaseoperator= (RobotDriveBase &&)=default
 
void SetDeadband (double deadband)
 Sets the deadband applied to the drive inputs (e.g., joystick values). More...
 
void SetMaxOutput (double maxOutput)
 Configure the scaling factor for using RobotDrive with motor controllers in a mode other than PercentVbus or to limit the maximum output. More...
 
void FeedWatchdog ()
 Feed the motor safety object. More...
 
void StopMotor () override=0
 Called to stop the motor when the timeout expires. More...
 
std::string GetDescription () const override=0
 Returns a description to print when an error occurs. More...
 
- Public Member Functions inherited from frc::MotorSafety
 MotorSafety ()
 
virtual ~MotorSafety ()
 
 MotorSafety (MotorSafety &&rhs)
 
MotorSafetyoperator= (MotorSafety &&rhs)
 
void Feed ()
 Feed the motor safety object. More...
 
void SetExpiration (units::second_t expirationTime)
 Set the expiration time for the corresponding motor safety object. More...
 
units::second_t GetExpiration () const
 Retrieve the timeout value for the corresponding motor safety object. More...
 
bool IsAlive () const
 Determine if the motor is still operating or has timed out. More...
 
void SetSafetyEnabled (bool enabled)
 Enable/disable motor safety for this device. More...
 
bool IsSafetyEnabled () const
 Return the state of the motor safety enabled flag. More...
 
void Check ()
 Check if this motor has exceeded its timeout. More...
 
virtual void StopMotor ()=0
 Called to stop the motor when the timeout expires. More...
 
virtual std::string GetDescription () const =0
 Returns a description to print when an error occurs. More...
 

Static Protected Member Functions

static void Desaturate (std::span< double > wheelSpeeds)
 Renormalize all wheel speeds if the magnitude of any wheel is greater than 1.0. More...
 

Protected Attributes

double m_deadband = kDefaultDeadband
 Input deadband. More...
 
double m_maxOutput = kDefaultMaxOutput
 Maximum output. More...
 

Static Protected Attributes

static constexpr double kDefaultDeadband = 0.02
 Default input deadband. More...
 
static constexpr double kDefaultMaxOutput = 1.0
 Default maximum output. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from frc::MotorSafety
static void CheckMotors ()
 Check the motors to see if any have timed out. More...
 

Detailed Description

Common base class for drive platforms.

MotorSafety is enabled by default.

Member Enumeration Documentation

◆ MotorType

The location of a motor on the robot for the purpose of driving.

Enumerator
kFrontLeft 

Front-left motor.

kFrontRight 

Front-right motor.

kRearLeft 

Rear-left motor.

kRearRight 

Rear-right motor.

kLeft 

Left motor.

kRight 

Right motor.

kBack 

Back motor.

Constructor & Destructor Documentation

◆ RobotDriveBase() [1/2]

frc::RobotDriveBase::RobotDriveBase ( )

◆ ~RobotDriveBase()

frc::RobotDriveBase::~RobotDriveBase ( )
overridedefault

◆ RobotDriveBase() [2/2]

frc::RobotDriveBase::RobotDriveBase ( RobotDriveBase &&  )
default

Member Function Documentation

◆ Desaturate()

static void frc::RobotDriveBase::Desaturate ( std::span< double >  wheelSpeeds)
staticprotected

Renormalize all wheel speeds if the magnitude of any wheel is greater than 1.0.

◆ FeedWatchdog()

void frc::RobotDriveBase::FeedWatchdog ( )

Feed the motor safety object.

Resets the timer that will stop the motors if it completes.

See also
MotorSafetyHelper::Feed()

◆ GetDescription()

std::string frc::RobotDriveBase::GetDescription ( ) const
overridepure virtual

Returns a description to print when an error occurs.

Returns
Description to print when an error occurs.

Implements frc::MotorSafety.

Implemented in frc::DifferentialDrive, and frc::MecanumDrive.

◆ operator=()

RobotDriveBase & frc::RobotDriveBase::operator= ( RobotDriveBase &&  )
default

◆ SetDeadband()

void frc::RobotDriveBase::SetDeadband ( double  deadband)

Sets the deadband applied to the drive inputs (e.g., joystick values).

The default value is 0.02. Inputs smaller than the deadband are set to 0.0 while inputs larger than the deadband are scaled from 0.0 to 1.0. See frc::ApplyDeadband().

Parameters
deadbandThe deadband to set.

◆ SetMaxOutput()

void frc::RobotDriveBase::SetMaxOutput ( double  maxOutput)

Configure the scaling factor for using RobotDrive with motor controllers in a mode other than PercentVbus or to limit the maximum output.

Parameters
maxOutputMultiplied with the output percentage computed by the drive functions.

◆ StopMotor()

void frc::RobotDriveBase::StopMotor ( )
overridepure virtual

Called to stop the motor when the timeout expires.

Implements frc::MotorSafety.

Implemented in frc::DifferentialDrive, and frc::MecanumDrive.

Member Data Documentation

◆ kDefaultDeadband

constexpr double frc::RobotDriveBase::kDefaultDeadband = 0.02
staticconstexprprotected

Default input deadband.

◆ kDefaultMaxOutput

constexpr double frc::RobotDriveBase::kDefaultMaxOutput = 1.0
staticconstexprprotected

Default maximum output.

◆ m_deadband

double frc::RobotDriveBase::m_deadband = kDefaultDeadband
protected

Input deadband.

◆ m_maxOutput

double frc::RobotDriveBase::m_maxOutput = kDefaultMaxOutput
protected

Maximum output.


The documentation for this class was generated from the following file: