LemLib  0.4.7
An easy to use and feature-rich PROS template
Loading...
Searching...
No Matches
util.hpp File Reference

Utility functions declarations. More...

#include <vector>

Go to the source code of this file.

Functions

float lemlib::slew (float target, float current, float maxChange)
 Slew rate limiter. More...
 
float lemlib::radToDeg (float rad)
 Convert radians to degrees. More...
 
float lemlib::degToRad (float deg)
 Convert degrees to radians. More...
 
float lemlib::angleError (float angle1, float angle2, bool radians=false)
 Calculate the error between 2 angles. Useful when calculating the error between 2 headings. More...
 
float lemlib::sgn (float x)
 Return the sign of a number. More...
 
float lemlib::avg (std::vector< float > values)
 Return the average of a vector of numbers. More...
 
double lemlib::avg (std::vector< double > values)
 Return the average of a vector of numbers. More...
 

Detailed Description

Utility functions declarations.

Author
LemLib Team
Version
0.4.5
Date
2023-01-15

Function Documentation

◆ angleError()

float lemlib::angleError ( float  angle1,
float  angle2,
bool  radians = false 
)

Calculate the error between 2 angles. Useful when calculating the error between 2 headings.

Parameters
angle1
angle2
radianstrue if angle is in radians, false if not. False by default
Returns
float wrapped angle

◆ avg() [1/2]

double lemlib::avg ( std::vector< double >  values)

Return the average of a vector of numbers.

Parameters
values
Returns
double

◆ avg() [2/2]

float lemlib::avg ( std::vector< float >  values)

Return the average of a vector of numbers.

Parameters
values
Returns
float

◆ degToRad()

float lemlib::degToRad ( float  deg)

Convert degrees to radians.

Parameters
degdegrees
Returns
float radians

◆ radToDeg()

float lemlib::radToDeg ( float  rad)

Convert radians to degrees.

Parameters
radradians
Returns
float degrees

◆ sgn()

float lemlib::sgn ( float  x)

Return the sign of a number.

Parameters
xthe number to get the sign of
Returns
float - -1 if negative, 1 if positive

◆ slew()

float lemlib::slew ( float  target,
float  current,
float  maxChange 
)

Slew rate limiter.

Parameters
targettarget value
currentcurrent value
maxChangemaximum change. No maximum if set to 0
Returns
float - the limited value