WPILibC++ 2023.4.3
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
 
std::string GetDescription () const override=0
 The return value from this method is printed out 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
 
virtual std::string GetDescription () const =0
 The return value from this method is printed out 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 = 0.02
 
double m_maxOutput = 1.0
 

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 
kFrontRight 
kRearLeft 
kRearRight 
kLeft 
kRight 
kBack 

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

The return value from this method is printed out when an error occurs.

This method must not throw!

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

Implements frc::MotorSafety.

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

Member Data Documentation

◆ m_deadband

double frc::RobotDriveBase::m_deadband = 0.02
protected

◆ m_maxOutput

double frc::RobotDriveBase::m_maxOutput = 1.0
protected

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