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

This class controls a specific servo hooked up to an ExpansionHub. More...

#include <wpi/hardware/expansionhub/ExpansionHubServo.hpp>

Public Member Functions

 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.

Detailed Description

This class controls a specific servo hooked up to an ExpansionHub.

Constructor & Destructor Documentation

◆ ExpansionHubServo()

wpi::ExpansionHubServo::ExpansionHubServo ( int usbId,
int channel )

Constructs a servo at the requested channel on a specific USB port.

Parameters
usbIdThe USB port ID the hub is connected to
channelThe servo channel

◆ ~ExpansionHubServo()

wpi::ExpansionHubServo::~ExpansionHubServo ( )
noexcept

Member Function Documentation

◆ 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
valuePosition 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
anglePosition 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
minAngleMinimum angle
maxAngleMaximum 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
enableTrue 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
enabledTrue 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
framePeriodThe frame period

◆ SetPulseWidth()

void wpi::ExpansionHubServo::SetPulseWidth ( wpi::units::microsecond_t pulseWidth)

Sets the raw pulse width output on the servo.

Parameters
pulseWidthPulse width

◆ 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
minPwmMinimum PWM
maxPwmMaximum PWM

◆ SetReversed()

void wpi::ExpansionHubServo::SetReversed ( bool reversed)

Sets whether the servo is reversed.

This will reverse both Set() and SetAngle().

Parameters
reversedTrue to reverse, false for normal

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