Haptic Controller
Loading...
Searching...
No Matches
helpers.hpp File Reference

Go to the source code of this file.

Classes

struct  Limits< T >
 Limit struct to store upper and lower limits. More...
 

Functions

bool float_close_compare (float a, float b, float tol=1e-6)
 Compare two floats for equality under a tolerance.
 
template<typename T >
limit (T input, const T max_value, const std::optional< T >(min_value)=std::nullopt)
 Clamps an input value to a.
 
template<typename T >
limit (T input, Limits< T > limits)
 Special case of the limit function accepting a Limit struct instead.
 

Function Documentation

◆ float_close_compare()

bool float_close_compare ( float a,
float b,
float tol = 1e-6 )

Compare two floats for equality under a tolerance.

Parameters
a- The first float
b- The second float
tol- The acceptable tolerance, defaults to 1e-6
Returns
True if the difference of the floats is less than the tolerance, false otherwise

Definition at line 13 of file helpers.hpp.

Referenced by isSynced().

◆ limit() [1/2]

template<typename T >
T limit ( T input,
const T max_value,
const std::optional< T > min_value = std::nullopt )

Clamps an input value to a.

Template Parameters
T- The type of the value to be limited
Parameters
input- The variable to limit.
max_value- The maximum value to limit. If no other value is provided, the negative of this is assumed the minimum value.
min_value- The minimum value to limit. Defaults to nullopt and uses the negative of the maximum value.
Returns
the clamped value

Definition at line 25 of file helpers.hpp.

Referenced by endEffMirrorUpdate(), jointMirrorUpdate(), and limit().

◆ limit() [2/2]

template<typename T >
T limit ( T input,
Limits< T > limits )

Special case of the limit function accepting a Limit struct instead.

Template Parameters
T- The type of the input
Parameters
input- The value to input.
limits- The limit struct.
Returns
the clamped value.

Definition at line 58 of file helpers.hpp.

References limit(), Limits< T >::lower, and Limits< T >::upper.