Cheetah Software
1.0
|
#include <algorithm>
#include <map>
#include <random>
#include <unordered_map>
#include <vector>
#include "cppTypes.h"
Go to the source code of this file.
Functions | |
template<typename T > | |
bool | fpEqual (T a, T b, T tol) |
template<typename T > | |
bool | vectorEqual (const std::vector< T > &a, const std::vector< T > &b) |
template<typename T > | |
T | coerce (T in, T min, T max) |
template<typename T > | |
T | deadband (T x, T range) |
template<typename T > | |
void | eigenDeadband (Eigen::MatrixBase< T > &v, typename T::Scalar band) |
template<typename T > | |
int | sgn (T val) |
template<typename T > | |
void | fillEigenWithRandom (Eigen::MatrixBase< T > &v, std::mt19937 &gen, std::uniform_real_distribution< typename T::Scalar > &dist) |
template<typename T > | |
T | generator_gaussian_noise (T mean, T var) |
template<typename T1 , typename T2 > | |
bool | uMapContains (const std::unordered_map< T1, T2 > &set, T1 key) |
template<typename T1 , typename T2 > | |
bool | mapContains (const std::map< T1, T2 > &set, T1 key) |
template<typename T > | |
std::string | numberToString (T number) |
template<typename T > | |
T | mapToRange (T x, T inputMin, T inputMax, T outputMin, T outputMax) |
template<typename T > | |
std::string | eigenToString (Eigen::MatrixBase< T > &value) |
static std::string | boolToString (bool b) |
void | writeStringToFile (const std::string &fileName, const std::string &fileData) |
std::string | getCurrentTimeAndDate () |
std::string | getConfigDirectoryPath () |
template<typename T > | |
void | EulerZYX_2_SO3 (const Vec3< T > &euler_zyx, Mat3< T > &SO3) |
template<typename T > | |
T | smooth_change (T ini, T end, T moving_duration, T curr_time) |
template<typename T > | |
T | smooth_change_vel (T ini, T end, T moving_duration, T curr_time) |
template<typename T > | |
T | smooth_change_acc (T ini, T end, T moving_duration, T curr_time) |
template<typename T > | |
T | stringToNumber (const std::string &str) |
template<typename T > | |
T | stringToNumber (const char *str) |
template<typename T > | |
Vec3< T > | stringToVec3 (const std::string &str) |
std::string | getLcmUrl (s64 ttl) |
|
inlinestatic |
Definition at line 154 of file utilities.h.
References getConfigDirectoryPath(), getCurrentTimeAndDate(), and writeStringToFile().
T coerce | ( | T | in, |
T | min, | ||
T | max | ||
) |
Coerce in to be between min and max
Definition at line 35 of file utilities.h.
T deadband | ( | T | x, |
T | range | ||
) |
void eigenDeadband | ( | Eigen::MatrixBase< T > & | v, |
typename T::Scalar | band | ||
) |
Definition at line 52 of file utilities.h.
References deadband().
std::string eigenToString | ( | Eigen::MatrixBase< T > & | value | ) |
Get the rotation matrix coincide with euler angle Intrisic ZYX rotation
Definition at line 168 of file utilities.h.
void fillEigenWithRandom | ( | Eigen::MatrixBase< T > & | v, |
std::mt19937 & | gen, | ||
std::uniform_real_distribution< typename T::Scalar > & | dist | ||
) |
Fill an eigen type with random numbers from a random generator and uniform real distribution. TODO: is there a way to make this work nicely with normal distributions too?
Definition at line 75 of file utilities.h.
bool fpEqual | ( | T | a, |
T | b, | ||
T | tol | ||
) |
Are two floating point values almost equal?
Definition at line 15 of file utilities.h.
T generator_gaussian_noise | ( | T | mean, |
T | var | ||
) |
std::string getConfigDirectoryPath | ( | ) |
Todo: do something better to keep track of where we are relative to the config directory
Definition at line 30 of file utilities.cpp.
std::string getCurrentTimeAndDate | ( | ) |
std::string getLcmUrl | ( | s64 | ttl | ) |
Definition at line 32 of file utilities.cpp.
bool mapContains | ( | const std::map< T1, T2 > & | set, |
T1 | key | ||
) |
Does the unordered map contain the given element?
Definition at line 120 of file utilities.h.
T mapToRange | ( | T | x, |
T | inputMin, | ||
T | inputMax, | ||
T | outputMin, | ||
T | outputMax | ||
) |
map value x in (inputMin, inputMax) to (outputMin, outputMax)
Definition at line 142 of file utilities.h.
std::string numberToString | ( | T | number | ) |
Convert a floating point number to a string. Is preferable over std::to_string because this uses scientific notation and won't truncate small/large numbers.
Definition at line 130 of file utilities.h.
int sgn | ( | T | val | ) |
Get the sign of a number 1 for positive, 0 for 0, -1 for negative...
Definition at line 65 of file utilities.h.
T smooth_change | ( | T | ini, |
T | end, | ||
T | moving_duration, | ||
T | curr_time | ||
) |
Definition at line 182 of file utilities.h.
T smooth_change_acc | ( | T | ini, |
T | end, | ||
T | moving_duration, | ||
T | curr_time | ||
) |
Definition at line 200 of file utilities.h.
T smooth_change_vel | ( | T | ini, |
T | end, | ||
T | moving_duration, | ||
T | curr_time | ||
) |
Definition at line 191 of file utilities.h.
T stringToNumber | ( | const std::string & | str | ) |
Definition at line 209 of file utilities.h.
T stringToNumber | ( | const char * | str | ) |
Definition at line 221 of file utilities.h.
Vec3<T> stringToVec3 | ( | const std::string & | str | ) |
Definition at line 226 of file utilities.h.
References getLcmUrl().
bool uMapContains | ( | const std::unordered_map< T1, T2 > & | set, |
T1 | key | ||
) |
Does the unordered map contain the given element?
Definition at line 112 of file utilities.h.
bool vectorEqual | ( | const std::vector< T > & | a, |
const std::vector< T > & | b | ||
) |
Are two std::vectors equal?
Definition at line 23 of file utilities.h.
void writeStringToFile | ( | const std::string & | fileName, |
const std::string & | fileData | ||
) |