This class controls a specific servo hooked up to an ExpansionHub.
More...
#include <wpi/hardware/expansionhub/ExpansionHubServo.hpp>
|
| | ExpansionHubServo (int usbId, int channel) |
| | Constructs a servo at the requested channel on a specific USB port.
|
| | ~ExpansionHubServo () noexcept |
| void | Set (double value) |
| | Set the servo position.
|
| void | SetAngle (wpi::units::degree_t angle) |
| | Sets the servo angle.
|
| void | SetPulseWidth (wpi::units::microsecond_t pulseWidth) |
| | Sets the raw pulse width output on the servo.
|
| void | SetEnabled (bool enabled) |
| | Sets if the servo output is enabled or not.
|
| void | SetFramePeriod (wpi::units::microsecond_t framePeriod) |
| | Sets the frame period for the servo.
|
| bool | IsHubConnected () const |
| | Gets if the underlying ExpansionHub is connected.
|
| void | SetAngleRange (wpi::units::degree_t minAngle, wpi::units::degree_t maxAngle) |
| | Sets the angle range for the setAngle call.
|
| void | SetPWMRange (wpi::units::microsecond_t minPwm, wpi::units::microsecond_t maxPwm) |
| | Sets the PWM range for the servo.
|
| void | SetReversed (bool reversed) |
| | Sets whether the servo is reversed.
|
| void | SetContinousRotationMode (bool enable) |
| | Enables or disables continuous rotation mode.
|
This class controls a specific servo hooked up to an ExpansionHub.
◆ ExpansionHubServo()
| wpi::ExpansionHubServo::ExpansionHubServo |
( |
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 servo channel |
◆ ~ExpansionHubServo()
| wpi::ExpansionHubServo::~ExpansionHubServo |
( |
| ) |
|
|
noexcept |
◆ IsHubConnected()
| bool wpi::ExpansionHubServo::IsHubConnected |
( |
| ) |
const |
|
inline |
Gets if the underlying ExpansionHub is connected.
- Returns
- True if hub is connected, otherwise false
◆ Set()
| void wpi::ExpansionHubServo::Set |
( |
double | value | ) |
|
Set the servo position.
Servo values range from 0.0 to 1.0 corresponding to the range of full left to full right.
- Parameters
-
| value | Position from 0.0 to 1.0. |
◆ SetAngle()
| void wpi::ExpansionHubServo::SetAngle |
( |
wpi::units::degree_t | angle | ) |
|
Sets the servo angle.
Servo angles range from 0 to 180 degrees. Use Set() with your own scaler for other angle ranges.
- Parameters
-
| angle | Position in angle units. Will be scaled between 0 and 180 degrees |
◆ SetAngleRange()
| void wpi::ExpansionHubServo::SetAngleRange |
( |
wpi::units::degree_t | minAngle, |
|
|
wpi::units::degree_t | maxAngle ) |
Sets the angle range for the setAngle call.
By default, this is 0 to 180 degrees.
Maximum angle must be greater than minimum angle.
- Parameters
-
| minAngle | Minimum angle |
| maxAngle | Maximum angle |
◆ SetContinousRotationMode()
| void wpi::ExpansionHubServo::SetContinousRotationMode |
( |
bool | enable | ) |
|
Enables or disables continuous rotation mode.
In continuous rotation mode, the servo will interpret Set() commands to between -1.0 and 1.0, instead of 0.0 to 1.0.
- Parameters
-
| enable | True to enable continuous rotation mode, false to disable |
◆ SetEnabled()
| void wpi::ExpansionHubServo::SetEnabled |
( |
bool | enabled | ) |
|
Sets if the servo output is enabled or not.
Defaults to false.
- Parameters
-
| enabled | True to enable, false to disable |
◆ SetFramePeriod()
| void wpi::ExpansionHubServo::SetFramePeriod |
( |
wpi::units::microsecond_t | framePeriod | ) |
|
Sets the frame period for the servo.
Defaults to 20ms.
- Parameters
-
| framePeriod | The frame period |
◆ SetPulseWidth()
| void wpi::ExpansionHubServo::SetPulseWidth |
( |
wpi::units::microsecond_t | pulseWidth | ) |
|
Sets the raw pulse width output on the servo.
- Parameters
-
◆ SetPWMRange()
| void wpi::ExpansionHubServo::SetPWMRange |
( |
wpi::units::microsecond_t | minPwm, |
|
|
wpi::units::microsecond_t | maxPwm ) |
Sets the PWM range for the servo.
By default, this is 600 to 2400 microseconds.
Maximum must be greater than minimum.
- Parameters
-
| minPwm | Minimum PWM |
| maxPwm | Maximum PWM |
◆ SetReversed()
| void wpi::ExpansionHubServo::SetReversed |
( |
bool | reversed | ) |
|
Sets whether the servo is reversed.
This will reverse both Set() and SetAngle().
- Parameters
-
| reversed | True to reverse, false for normal |
The documentation for this class was generated from the following file: