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

This class controls a specific servo in continuous rotation mode hooked up to an ExpansionHub. More...

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

Public Member Functions

 ExpansionHubCRServo (int usbId, int channel)
 Constructs a continuous rotation servo at the requested channel on a specific USB port.
 ~ExpansionHubCRServo () noexcept
void SetThrottle (double value)
 Set the servo throttle.
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 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 continuous rotation mode hooked up to an ExpansionHub.

Constructor & Destructor Documentation

◆ ExpansionHubCRServo()

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

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

See also
ExpansionHubServo for a servo mode, or non-continuous rotation servo
Parameters
usbIdThe USB port ID the hub is connected to
channelThe servo channel

◆ ~ExpansionHubCRServo()

wpi::ExpansionHubCRServo::~ExpansionHubCRServo ( )
noexcept

Member Function Documentation

◆ IsHubConnected()

bool wpi::ExpansionHubCRServo::IsHubConnected ( ) const
inline

Gets if the underlying ExpansionHub is connected.

Returns
True if hub is connected, otherwise false

◆ SetEnabled()

void wpi::ExpansionHubCRServo::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::ExpansionHubCRServo::SetFramePeriod ( wpi::units::microsecond_t framePeriod)

Sets the frame period for the servo.

Defaults to 20ms.

Parameters
framePeriodThe frame period

◆ SetPulseWidth()

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

Sets the raw pulse width output on the servo.

Parameters
pulseWidthPulse width

◆ SetPWMRange()

void wpi::ExpansionHubCRServo::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::ExpansionHubCRServo::SetReversed ( bool reversed)

Sets whether the servo is reversed.

This will reverse SetThrottle.

Parameters
reversedTrue to reverse, false for normal

◆ SetThrottle()

void wpi::ExpansionHubCRServo::SetThrottle ( double value)

Set the servo throttle.

Throttle values range from -1.0 to 1.0 corresponding to full reverse to full forward.

Parameters
valueThrottle from -1.0 to 1.0.

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