|
Fang-Robotics-MCB
Fang Robotics Team Codebase
|
#include <ramp.hpp>
Public Member Functions | |
| Ramp (float initialValue=0.0f) | |
| void | reset (float val) |
Sets the target and value to the passed in val. | |
| void | setTarget (float target) |
| Sets a new target ramp value. | |
| void | setValue (float value) |
Sets the value to value. | |
| void | update (float increment) |
| float | getValue () const |
| Returns the current value being generated by the ramp. | |
| bool | isTargetReached () const |
| Returns true if the value == target. | |
| float | getTarget () const |
| Returns the target value (where the ramp generator will head torwards). | |
An output value is incremented or decremented at every call to update until target has been reached.
This is very similar to modm's ramp except for one difference: rather than setting the increment at the beginning, you set the increment each time, which allows you to take into account systems where time increment is not constant.
|
explicit |
Create a ramp generator.
| initialValue | The starting value |
| float tap::algorithms::Ramp::getTarget | ( | ) | const |
Returns the target value (where the ramp generator will head torwards).
| float tap::algorithms::Ramp::getValue | ( | ) | const |
Returns the current value being generated by the ramp.
| bool tap::algorithms::Ramp::isTargetReached | ( | ) | const |
Returns true if the value == target.
| void tap::algorithms::Ramp::reset | ( | float | val | ) |
Sets the target and value to the passed in val.
| void tap::algorithms::Ramp::setTarget | ( | float | target | ) |
Sets a new target ramp value.
| void tap::algorithms::Ramp::setValue | ( | float | value | ) |
Sets the value to value.
| void tap::algorithms::Ramp::update | ( | float | increment | ) |
Updates the ramp by incrementing or decrementing the target by the increment.
rotationSpeed pass in the following: (currtime - prevtime) * rotationSpeed