This class controls a specific motor and encoder hooked up to an ExpansionHub.
More...
#include <wpi/hardware/expansionhub/ExpansionHubMotor.hpp>
This class controls a specific motor and encoder hooked up to an ExpansionHub.
◆ ExpansionHubMotor()
| wpi::ExpansionHubMotor::ExpansionHubMotor |
( |
int | usbId, |
|
|
int | channel ) |
Constructs a servo at the requested channel on a specific USB port.
- Parameters
-
| usbId | The USB port ID the hub is connected to |
| channel | The motor channel |
◆ ~ExpansionHubMotor()
| wpi::ExpansionHubMotor::~ExpansionHubMotor |
( |
| ) |
|
|
noexcept |
◆ Follow()
Sets this motor to follow another motor on the same hub.
This does not support following motors that are also followers. Additionally, the direction of both motors will be the same.
- Parameters
-
| leader | The motor to follow |
◆ GetCurrent()
| wpi::units::ampere_t wpi::ExpansionHubMotor::GetCurrent |
( |
| ) |
const |
Gets the current being pulled by the motor.
- Returns
- Motor current
◆ GetEncoderPosition()
| double wpi::ExpansionHubMotor::GetEncoderPosition |
( |
| ) |
const |
Gets the current position of the motor encoder.
Scaled into distancePerCount units.
- Returns
- Encoder position
◆ GetEncoderVelocity()
| double wpi::ExpansionHubMotor::GetEncoderVelocity |
( |
| ) |
const |
Gets the current velocity of the motor encoder.
Scaled into distancePerCount units.
- Returns
- Encoder velocity
◆ GetPositionPidConstants()
Gets the PID constants object for position PID.
- Returns
- Position PID constants object
◆ GetVelocityPidConstants()
Gets the PID constants object for velocity PID.
- Returns
- Velocity PID constants object
◆ IsHubConnected()
| bool wpi::ExpansionHubMotor::IsHubConnected |
( |
| ) |
|
|
inline |
Gets if the underlying ExpansionHub is connected.
- Returns
- True if hub is connected, otherwise false
◆ ResetEncoder()
| void wpi::ExpansionHubMotor::ResetEncoder |
( |
| ) |
|
Reset the encoder count to 0.
◆ SetDistancePerCount()
| void wpi::ExpansionHubMotor::SetDistancePerCount |
( |
double | perCount | ) |
|
Sets the distance per count of the encoder.
Used to scale encoder readings.
- Parameters
-
| perCount | The distance moved per count of the encoder |
◆ SetDutyCycle()
| void wpi::ExpansionHubMotor::SetDutyCycle |
( |
double | dutyCycle | ) |
|
Sets the duty cycle.
- Parameters
-
| dutyCycle | The duty cycle between -1 and 1 (sign indicates direction). |
◆ SetEnabled()
| void wpi::ExpansionHubMotor::SetEnabled |
( |
bool | enabled | ) |
|
Sets if the motor output is enabled or not.
Defaults to false.
- Parameters
-
| enabled | True to enable, false to disable |
◆ SetFloatOn0()
| void wpi::ExpansionHubMotor::SetFloatOn0 |
( |
bool | floatOn0 | ) |
|
Sets if the motor should float or brake when 0 is commanded.
Defaults to false.
- Parameters
-
| floatOn0 | True to float when commanded 0, false to brake |
◆ SetPositionSetpoint()
| void wpi::ExpansionHubMotor::SetPositionSetpoint |
( |
double | setpoint | ) |
|
Command the motor to drive to a specific position setpoint.
This value will be scaled by SetDistancePerCount and influenced by the PID constants.
- Parameters
-
| setpoint | The position setpoint to drive the motor to |
◆ SetReversed()
| void wpi::ExpansionHubMotor::SetReversed |
( |
bool | reversed | ) |
|
Sets if the motor and encoder should be reversed.
- Parameters
-
| reversed | True to reverse encoder, false otherwise |
◆ SetVelocitySetpoint()
| void wpi::ExpansionHubMotor::SetVelocitySetpoint |
( |
double | setpoint | ) |
|
Command the motor to drive to a specific velocity setpoint.
This value will be scaled by SetDistancePerCount and influenced by the PID constants.
- Parameters
-
| setpoint | The velocity setpoint to drive the motor to |
◆ SetVoltage()
| void wpi::ExpansionHubMotor::SetVoltage |
( |
wpi::units::volt_t | voltage | ) |
|
Sets the voltage to run the motor at.
This value will be continously scaled to match the input voltage.
- Parameters
-
| voltage | The voltage to drive the motor at |
The documentation for this class was generated from the following file: