Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::motor::Servo Class Reference

#include <servo.hpp>

Public Member Functions

 Servo (Drivers *drivers, tap::gpio::Pwm::Pin currpwmPinPort, float maximumPwm, float minimumPwm, float pwmRampSpeed)
 
void setTargetPwm (float PWM)
 
void updateSendPwmRamp ()
 
float getPWM () const
 
float getMinPWM () const
 
float getMaxPWM () const
 
bool isRampTargetMet () const
 

Detailed Description

This class wraps around the PWM class to provide utilities for controlling a servo. In particular, this class limits some target PWM to a min and max PWM value and uses ramping to control the speed of the servo.

Constructor & Destructor Documentation

◆ Servo()

tap::motor::Servo::Servo ( Drivers drivers,
tap::gpio::Pwm::Pin  currpwmPinPort,
float  maximumPwm,
float  minimumPwm,
float  pwmRampSpeed 
)

Initializes the PWM bounds and associates the Servo with some PWM pin.

Note
maximumPwm and minimumPwm are limited to between [0, 1]. Also if maximumPwm < minimumPwm, an error is thrown and [minPwm, maxPwm] is set to [0, 1].
Parameters
[in]driversInstance to the drivers class you would like to use.
[in]pwmPinThe pin to attach the Servo class with.
[in]maximumPwmThe maximum allowable PWM output. This is limited between 0 and 1.
[in]minimumPwmThe minimum allowable PWM output. This is limited between 0 and 1.
[in]pwmRampSpeedThe speed in PWM percent per millisecond.

Member Function Documentation

◆ getMaxPWM()

float tap::motor::Servo::getMaxPWM ( ) const
Returns
The maximum PWM output (as a duty cycle).

◆ getMinPWM()

float tap::motor::Servo::getMinPWM ( ) const
Returns
The minimum PWM output (as a duty cycle).

◆ getPWM()

float tap::motor::Servo::getPWM ( ) const
Returns
The current PWM output to the servo.

◆ isRampTargetMet()

bool tap::motor::Servo::isRampTargetMet ( ) const
Returns
true if the ramp has met the desired PWM value (set with setTargetPwm). Use this to estimate when a servo movement is complete.

◆ setTargetPwm()

void tap::motor::Servo::setTargetPwm ( float  PWM)

Limits pwmOutputRamp to minPwm and maxPwm, then sets ramp output to the limited value. Do not repeatedly call (i.e. only call in a Command's initialize function, for example).

◆ updateSendPwmRamp()

void tap::motor::Servo::updateSendPwmRamp ( )

Updates the pwmOutputRamp object and then sets the output PWM to the updated ramp value.


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