Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::algorithms::Ramp Class Reference

#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).
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Ramp()

tap::algorithms::Ramp::Ramp ( float  initialValue = 0.0f)
explicit

Create a ramp generator.

Parameters
initialValueThe starting value

Member Function Documentation

◆ getTarget()

float tap::algorithms::Ramp::getTarget ( ) const

Returns the target value (where the ramp generator will head torwards).

◆ getValue()

float tap::algorithms::Ramp::getValue ( ) const

Returns the current value being generated by the ramp.

◆ isTargetReached()

bool tap::algorithms::Ramp::isTargetReached ( ) const

Returns true if the value == target.

◆ reset()

void tap::algorithms::Ramp::reset ( float  val)

Sets the target and value to the passed in val.

◆ setTarget()

void tap::algorithms::Ramp::setTarget ( float  target)

Sets a new target ramp value.

◆ setValue()

void tap::algorithms::Ramp::setValue ( float  value)

Sets the value to value.

◆ update()

void tap::algorithms::Ramp::update ( float  increment)

Updates the ramp by incrementing or decrementing the target by the increment.

Note
For expected results, call this function every controller iteration.
The increment should be based on the time.
For example, if you are ramping a motor angle and want a motor to turn at some rotationSpeed pass in the following: (currtime - prevtime) * rotationSpeed

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