WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
wpi::MotorController Class Referenceabstract

Interface for motor controlling devices. More...

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

Inheritance diagram for wpi::MotorController:
wpi::PWMMotorController wpi::xrp::XRPMotor 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

virtual ~MotorController ()=default
virtual void SetDutyCycle (double dutyCycle)=0
 Sets the duty cycle of the motor controller.
virtual void SetVoltage (wpi::units::volt_t voltage)
 Sets the voltage output of the motor controller.
virtual double GetDutyCycle () const =0
 Gets the duty cycle of the motor controller.
virtual void SetInverted (bool isInverted)=0
 Sets the inversion state of the motor controller.
virtual bool GetInverted () const =0
 Gets the inversion state of the motor controller.
virtual void Disable ()=0
 Disables the motor controller.

Detailed Description

Interface for motor controlling devices.

Constructor & Destructor Documentation

◆ ~MotorController()

virtual wpi::MotorController::~MotorController ( )
virtualdefault

Member Function Documentation

◆ Disable()

virtual void wpi::MotorController::Disable ( )
pure virtual

Disables the motor controller.

Implemented in wpi::PWMMotorController, and wpi::xrp::XRPMotor.

◆ GetDutyCycle()

virtual double wpi::MotorController::GetDutyCycle ( ) const
pure virtual

Gets the duty cycle of the motor controller.

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

Implemented in wpi::PWMMotorController, and wpi::xrp::XRPMotor.

◆ GetInverted()

virtual bool wpi::MotorController::GetInverted ( ) const
pure virtual

Gets the inversion state of the motor controller.

Returns
The inversion state.

Implemented in wpi::PWMMotorController, and wpi::xrp::XRPMotor.

◆ SetDutyCycle()

virtual void wpi::MotorController::SetDutyCycle ( double dutyCycle)
pure virtual

Sets the duty cycle of the motor controller.

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

Implemented in wpi::PWMMotorController, and wpi::xrp::XRPMotor.

◆ SetInverted()

virtual void wpi::MotorController::SetInverted ( bool isInverted)
pure virtual

Sets the inversion state of the motor controller.

Parameters
isInvertedThe inversion state.

Implemented in wpi::PWMMotorController, and wpi::xrp::XRPMotor.

◆ SetVoltage()

virtual void wpi::MotorController::SetVoltage ( wpi::units::volt_t voltage)
virtual

Sets the voltage output of the motor controller.

Compensates for the current bus voltage to ensure that the desired voltage is output even if the battery voltage is below 12V - highly useful when the voltage outputs are "meaningful" (e.g. they come from a feedforward calculation).

NOTE: This function must be called regularly in order for voltage compensation to work properly - unlike the ordinary set function, it is not "set it and forget it."

Parameters
voltageThe voltage.

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