WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
wpi::PWMMotorController Class Reference

Common base class for all PWM Motor Controllers. More...

#include <wpi/hardware/motor/PWMMotorController.hpp>

Inheritance diagram for wpi::PWMMotorController:
wpi::MotorController wpi::MotorSafety wpi::util::Sendable wpi::util::SendableHelper< PWMMotorController > wpi::Koors40 wpi::PWMSparkFlex wpi::PWMSparkMax wpi::PWMTalonFX wpi::PWMTalonSRX wpi::PWMVenom wpi::PWMVictorSPX wpi::Spark wpi::SparkMini wpi::Talon wpi::VictorSP wpi::romi::RomiMotor

Public Member Functions

 PWMMotorController (PWMMotorController &&)=default
PWMMotorControlleroperator= (PWMMotorController &&)=default
void SetDutyCycle (double dutyCycle) override
 Sets the duty cycle of the motor controller.
double GetDutyCycle () const override
 Gets the duty cycle of the motor controller.
virtual wpi::units::volt_t GetVoltage () const
 Gets the voltage output of the motor controller, nominally between -12 V and 12 V.
void SetInverted (bool isInverted) override
 Sets the inversion state of the motor controller.
bool GetInverted () const override
 Gets the inversion state of the motor controller.
void Disable () override
 Disables the motor controller.
void StopMotor () override
 Called to stop the motor when the timeout expires.
std::string GetDescription () const override
 Returns a description to print when an error occurs.
int GetChannel () const
void EnableDeadbandElimination (bool eliminateDeadband)
 Optionally eliminate the deadband from a motor controller.
void AddFollower (PWMMotorController &follower)
 Make the given PWM motor controller follow the output of this one.
template<std::derived_from< PWMMotorController > T>
void AddFollower (T &&follower)
 Make the given PWM motor controller follow the output of this one.
Public Member Functions inherited from wpi::MotorController
virtual ~MotorController ()=default
virtual void SetVoltage (wpi::units::volt_t voltage)
 Sets the voltage output of the motor controller.
Public Member Functions inherited from wpi::MotorSafety
 MotorSafety ()
virtual ~MotorSafety ()
 MotorSafety (MotorSafety &&rhs)
MotorSafetyoperator= (MotorSafety &&rhs)
void Feed ()
 Feed the motor safety object.
void SetExpiration (wpi::units::second_t expirationTime)
 Set the expiration time for the corresponding motor safety object.
wpi::units::second_t GetExpiration () const
 Retrieve the timeout value for the corresponding motor safety object.
bool IsAlive () const
 Determine if the motor is still operating or has timed out.
void SetSafetyEnabled (bool enabled)
 Enable/disable motor safety for this device.
bool IsSafetyEnabled () const
 Return the state of the motor safety enabled flag.
void Check ()
 Check if this motor has exceeded its timeout.
Public Member Functions inherited from wpi::util::Sendable
virtual constexpr ~Sendable ()=default
Public Member Functions inherited from wpi::util::SendableHelper< PWMMotorController >
constexpr SendableHelper (const SendableHelper &rhs)=default
constexpr SendableHelperoperator= (const SendableHelper &rhs)=default

Protected Member Functions

 PWMMotorController (std::string_view name, int channel)
 Constructor for a PWM Motor Controller connected via PWM.
void InitSendable (wpi::util::SendableBuilder &builder) override
 Initializes this Sendable object.
void SetDutyCycleInternal (double dutyCycle)
double GetDutyCycleInternal () const
void SetBounds (wpi::units::microsecond_t maxPwm, wpi::units::microsecond_t deadbandMaxPwm, wpi::units::microsecond_t centerPwm, wpi::units::microsecond_t deadbandMinPwm, wpi::units::microsecond_t minPwm)
Protected Member Functions inherited from wpi::util::SendableHelper< PWMMotorController >
constexpr ~SendableHelper ()

Protected Attributes

PWM m_pwm
 PWM instances for motor controller.

Additional Inherited Members

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

Detailed Description

Common base class for all PWM Motor Controllers.

Constructor & Destructor Documentation

◆ PWMMotorController() [1/2]

wpi::PWMMotorController::PWMMotorController ( PWMMotorController && )
default

◆ PWMMotorController() [2/2]

wpi::PWMMotorController::PWMMotorController ( std::string_view name,
int channel )
protected

Constructor for a PWM Motor Controller connected via PWM.

Parameters
nameName to use for SendableRegistry
channelThe PWM channel that the controller is attached to. 0-9 are on-board, 10-19 are on the MXP port

Member Function Documentation

◆ AddFollower() [1/2]

void wpi::PWMMotorController::AddFollower ( PWMMotorController & follower)

Make the given PWM motor controller follow the output of this one.

Parameters
followerThe motor controller follower.

◆ AddFollower() [2/2]

template<std::derived_from< PWMMotorController > T>
void wpi::PWMMotorController::AddFollower ( T && follower)
inline

Make the given PWM motor controller follow the output of this one.

Parameters
followerThe motor controller follower.

◆ Disable()

void wpi::PWMMotorController::Disable ( )
overridevirtual

Disables the motor controller.

Implements wpi::MotorController.

◆ EnableDeadbandElimination()

void wpi::PWMMotorController::EnableDeadbandElimination ( bool eliminateDeadband)

Optionally eliminate the deadband from a motor controller.

Parameters
eliminateDeadbandIf true, set the motor curve on the motor controller to eliminate the deadband in the middle of the range. Otherwise, keep the full range without modifying any values.

◆ GetChannel()

int wpi::PWMMotorController::GetChannel ( ) const

◆ GetDescription()

std::string wpi::PWMMotorController::GetDescription ( ) const
overridevirtual

Returns a description to print when an error occurs.

Returns
Description to print when an error occurs.

Implements wpi::MotorSafety.

◆ GetDutyCycle()

double wpi::PWMMotorController::GetDutyCycle ( ) const
overridevirtual

Gets the duty cycle of the motor controller.

Returns
The duty cycle between -1 and 1 (sign indicates direction).

Implements wpi::MotorController.

◆ GetDutyCycleInternal()

double wpi::PWMMotorController::GetDutyCycleInternal ( ) const
protected

◆ GetInverted()

bool wpi::PWMMotorController::GetInverted ( ) const
overridevirtual

Gets the inversion state of the motor controller.

Returns
The inversion state.

Implements wpi::MotorController.

◆ GetVoltage()

virtual wpi::units::volt_t wpi::PWMMotorController::GetVoltage ( ) const
virtual

Gets the voltage output of the motor controller, nominally between -12 V and 12 V.

Returns
The voltage of the motor controller, nominally between -12 V and 12 V.

◆ InitSendable()

void wpi::PWMMotorController::InitSendable ( wpi::util::SendableBuilder & builder)
overrideprotectedvirtual

Initializes this Sendable object.

Parameters
buildersendable builder

Implements wpi::util::Sendable.

◆ operator=()

PWMMotorController & wpi::PWMMotorController::operator= ( PWMMotorController && )
default

◆ SetBounds()

void wpi::PWMMotorController::SetBounds ( wpi::units::microsecond_t maxPwm,
wpi::units::microsecond_t deadbandMaxPwm,
wpi::units::microsecond_t centerPwm,
wpi::units::microsecond_t deadbandMinPwm,
wpi::units::microsecond_t minPwm )
protected

◆ SetDutyCycle()

void wpi::PWMMotorController::SetDutyCycle ( double dutyCycle)
overridevirtual

Sets the duty cycle of the motor controller.

Parameters
dutyCycleThe duty cycle between -1 and 1 (sign indicates direction).

Implements wpi::MotorController.

◆ SetDutyCycleInternal()

void wpi::PWMMotorController::SetDutyCycleInternal ( double dutyCycle)
protected

◆ SetInverted()

void wpi::PWMMotorController::SetInverted ( bool isInverted)
overridevirtual

Sets the inversion state of the motor controller.

Parameters
isInvertedThe inversion state.

Implements wpi::MotorController.

◆ StopMotor()

void wpi::PWMMotorController::StopMotor ( )
overridevirtual

Called to stop the motor when the timeout expires.

Implements wpi::MotorSafety.

Member Data Documentation

◆ m_pwm

PWM wpi::PWMMotorController::m_pwm
protected

PWM instances for motor controller.


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