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

This class controls a specific servo in positional/servo mode 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 SetPosition (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.

Detailed Description

This class controls a specific servo in positional/servo mode 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.

See also
ExpansionHubCRServo if the servo is in continuous rotation mode
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

◆ SetAngle()

void wpi::ExpansionHubServo::SetAngle ( wpi::units::degree_t angle)

Sets the servo angle.

Servo angles range defaults to 0 to 180 degrees, but can be changed with setAngleRange().

Parameters
anglePosition in angle units. Will be clamped to be within the current angle range.

◆ 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

◆ 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

◆ SetPosition()

void wpi::ExpansionHubServo::SetPosition ( 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.

◆ 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 SetPosition() and SetAngle().

Parameters
reversedTrue to reverse, false for normal

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