Class Ramp

Class Documentation

class Ramp

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.

Public Functions

explicit Ramp(float initialValue = 0.0f)

Create a ramp generator.

Parameters:

initialValue – The starting value

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)

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

Note

For expected results, call this function every controller iteration.

Note

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

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