|
Fang-Robotics-MCB
Fang Robotics Team Codebase
|
#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 |
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.
| 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.
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].| [in] | drivers | Instance to the drivers class you would like to use. |
| [in] | pwmPin | The pin to attach the Servo class with. |
| [in] | maximumPwm | The maximum allowable PWM output. This is limited between 0 and 1. |
| [in] | minimumPwm | The minimum allowable PWM output. This is limited between 0 and 1. |
| [in] | pwmRampSpeed | The speed in PWM percent per millisecond. |
| float tap::motor::Servo::getMaxPWM | ( | ) | const |
| float tap::motor::Servo::getMinPWM | ( | ) | const |
| float tap::motor::Servo::getPWM | ( | ) | const |
| bool tap::motor::Servo::isRampTargetMet | ( | ) | const |
true if the ramp has met the desired PWM value (set with setTargetPwm). Use this to estimate when a servo movement is complete. | 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).
| void tap::motor::Servo::updateSendPwmRamp | ( | ) |
Updates the pwmOutputRamp object and then sets the output PWM to the updated ramp value.