Contains many commonly used utility functions. Note: Communication with our devices (wireless and inertial) is done in Big Endian.
uint32 valueTypeSize( |
| ) |
uint8 msb( |
| ) |
Gets the Most Significant Byte from the 2-Byte WORD
value uint16 | the 2-Byte unsigned integer to find the MSB from |
The Most Significant Byte of the passed in value
uint8 lsb( |
| ) |
Gets the Least Significant Byte from the 2-Byte WORD
value uint16 | the 2-Byte unsigned integer to find the LSB from |
The Least Significant Byte of the passed in value
uint8 msNibble( |
| ) |
Gets the Most Significant Nibble (4-bits) from the 1-Byte value
value uint8 | the 1-Byte value to find the Most Significant Nibble from |
The Most Significant Nibble of the passed in value
uint8 lsNibble( |
| ) |
Gets the Least Significant Nibble (4-bits) from the 1-Byte value
value uint8 | the 1-Byte value to find the Least Significant Nibble from |
The Least Significant Nibble of the passed in value
int16 make_int16( |
| ) |
Gets the 2-byte nsigned integer from 2 individual MSB and LSB bytes
msb uint8 | the Most Significant Byte |
lsb uint8 | the Lease Significant Byte |
The 2-byte int16 built from the MSB and LSB bytes
void split_uint16( |
| ) |
Converts the 2-byte unsigned integer into its individual 2 bytes
value uint16 | the 2 byte uint16 to convert into bytes |
msb uint8& | holds the Most Significant Byte result |
lsb uint8& | holds the Least Significant Byte result |
uint16 make_uint16( |
| ) |
Gets the 2-byte unsigned integer from 2 individual MSB and LSB bytes
msb uint8 | the Most Significant Byte |
lsb uint8 | the Lease Significant Byte |
The 2-byte uint16 built from the MSB and LSB bytes
void split_uint32( |
| ) |
Converts the 4-byte unsigned integer into its 4 individual bytes
value uint32 | the 4 byte uint32 to convert into bytes |
msb uint8& | holds the msb result |
byte2 uint8& | holds the second byte result |
byte3 uint8& | holds the third byte result |
lsb uint8& | holds the lsb result |
void split_uint32( |
| ) |
Converts the 4-byte unsigned integer into its 2 uint16 values.
value uint32 | the 4 byte uint32 to convert into bytes. |
msw uint16& | holds the msw result. |
lsw uint16& | holds the lsw result. |
uint32 make_uint32( |
| ) |
gets the 4-byte unsigned integer from the 4 individual bytes
msb uint8 | the msb to be used |
byte2 uint8 | the second byte to be used |
byte3 uint8 | the third byte to be used |
lsb uint8 | the lsb to be used |
the 4-byte uint32 built from the 4 bytes
uint32 make_uint32( |
| ) |
gets the 4-byte unsigned integer from the 2 uint16 words.
msw uint16 | the most significant word to be used. |
lsw uint16 | the lease significant word to be used. |
the 4-byte uint32 built from the 2 uint16 words.
void split_float_big_endian( |
| ) |
Converts the 4-byte float (in system endian) into its 4 individual bytes in big endian
value float | the 4 byte float (in system endian) to convert into bytes |
msb uint8& | holds the msb result |
byte2 uint8& | holds the second byte result |
byte3 uint8& | holds the third byte result |
lsb uint8& | holds the lsb result |
void split_float_little_endian( |
| ) |
Converts the 4-byte float (in system endian) into its 4 individual bytes in little endian
value float | the 4 byte float (in system endian) to convert into bytes |
lsb uint8& | holds the lsb result |
byte2 uint8& | holds the second byte result |
byte3 uint8& | holds the third byte result |
msb uint8& | holds the msb result |
float make_float_big_endian( |
| ) |
Builds a 4-byte float (in system endian) from 4 bytes given in big endian
msb uint8 | the most significant byte |
byte2 uint8 | the second byte |
byte3 uint8 | the third byte |
lsb uint8 | the least significant byte |
A 4-byte float in system-endianess built from the 4 given bytes
float make_float_little_endian( |
| ) |
Builds a 4-byte float (in system endian) from 4 bytes given in little endian
lsb uint8 | the least significant byte |
byte2 uint8 | the second byte |
byte3 uint8 | the third byte |
msb uint8 | the most significant byte |
A 4-byte float in system-endianess built from the 4 given bytes
void split_double_big_endian( |
| ) |
Converts the 8-byte double (in system endian) into its 8 individual bytes in big endian
value double | the 8 byte double (in system endian) to convert into bytes |
msb uint8& | holds the msb result |
byte2 uint8& | holds the second byte result |
byte3 uint8& | holds the third byte result |
byte4 uint8& | holds the fourth byte result |
byte5 uint8& | holds the fifth byte result |
byte6 uint8& | holds the sixth byte result |
byte7 uint8& | holds the seventh byte result |
lsb uint8& | holds the lsb result |
void split_double_little_endian( |
| ) |
Converts the 8-byte double (in system endian) into its 8 individual bytes in little endian
value double | the 8 byte double (in system endian) to convert into bytes |
lsb uint8& | holds the lsb result |
byte2 uint8& | holds the second byte result |
byte3 uint8& | holds the third byte result |
byte4 uint8& | holds the fourth byte result |
byte5 uint8& | holds the fifth byte result |
byte6 uint8& | holds the sixth byte result |
byte7 uint8& | holds the seventh byte result |
msb uint8& | holds the msb result |
double make_double_big_endian( |
| ) |
Builds a 8-byte double (in system endian) from the bytes given in big endian
msb uint8 | the msb to be used |
byte2 uint8 | the 2nd byte to be used |
byte3 uint8 | the 3rd byte to be used |
byte4 uint8 | the 4th byte to be used |
byte5 uint8 | the 5th byte to be used |
byte6 uint8 | the 6th byte to be used |
byte7 uint8 | the 7th byte to be used |
lsb uint8 | the lsb to be used |
the 8-byte double (in system endian) built from the 8 bytes
double make_double_little_endian( |
| ) |
Builds a 8-byte double (in system endian) from the bytes given in little endian
lsb uint8 | the lsb to be used |
byte2 uint8 | the 2nd byte to be used |
byte3 uint8 | the 3rd byte to be used |
byte4 uint8 | the 4th byte to be used |
byte5 uint8 | the 5th byte to be used |
byte6 uint8 | the 6th byte to be used |
byte7 uint8 | the 7th byte to be used |
msb uint8 | the msb to be used |
the 8-byte double (in system endian) built from the 8 bytes
Gets the current system time in nanoseconds since unix epoch
The nanoseconds representation of the current system time in UTC
void threadSleep( |
| ) |
Sleeps for a specified amount of milliseconds on the current thread.
milli uint64 | The number of milliseconds to sleep for. |
double logBase2( |
| ) |
Gets the log base 2 of a value
value double | The value to get the log of |
The log base 2 of the value
float round( |
| ) |
Returns the value that is nearest to the provided value to round. (ie. round(2.5) == 3, round(2.4) == 2)
value float | The value to round |
The rounded result.
uint32 roundDownToNearestBase2( |
| ) |
Rounds down to the nearest base 2 value
value double | The value to round down to the nearest base 2 |
The value rounded down to the nearest base 2
uint32 roundUpToNearestBase2( |
| ) |
Rounds up to the nearest base 2 value
value double | The value to round up to the nearest base 2 |
The value rounded up to the nearest base 2
double radiansToDegrees( |
| ) |
Converts the radian angle to degrees.
angle float | The angle in radians. |
The angle in degrees.
bool bitIsSet( |
| ) |
Checks if a specific bit is set in the given value.
value uint32 | The value to check the bit of. |
bitPos size_t | The bit position to check if it is set. (0 = far right) |
true if the bit is set, false if it is not set.
void removeChar( |
| ) |
Removes all found instances of a char from a string.
src std::string& | The string to remove the character from. This will be changed to hold the result. |
charToRemove char | The character to remove all instances of from the string. |
void removeStr( |
| ) |
Removes all found instances of a string from another string.
str | The string to remove the substring from. This will be changed to hold the result. |
strtoRemove const std::string& | The substring to remove all instances of from the string. |
bool containsStr( |
| ) |
Checks whether or not a string contains another string.
src const std::string& | The source string. |
containsThis const std::string& | The string to attempt to find in the source string. |
true if the string was found in the source string, false if it was not found.
void strTrimLeft( |
| ) |
Trims all whitespace from the left of a string.
src std::string& | The string to trim whitespace from. This will be changed to hold the result. |
void strTrimRight( |
| ) |
Trims all whitespace from the right of a string.
src std::string& | The string to trim whitespace from. This will be changed to hold the result. |
void filterSensorcloudName( |
| ) |
Replaces characters that are not supported by SensorCloud with a '-' character.
str std::string& | The string to filter. This will hold the result. |
float normalizeAngle( |
| ) |
Normalizes an angle value to be between 0 and 360 degrees.
angle float | The angle to normalize. |
The normalized angle within 0 and 360 degrees.
template<typename T> bool isNaN( |
| ) |
Checks whether the given value is NaN or not.
value T | The value to check if it is a NaN. |
true if the value is a NaN, false otherwise.
template<typename T> void checkBounds_min( |
| ) |
Checks that a value is not below a minimum value. If the value is less than the min, the value is changed to that min value.
value T& | The value to check |
min T | The minimum value to make sure the value is greater than or equal to |
template<typename T> void checkBounds_max( |
| ) |
Checks that a value is not above a maximum value. If the value is greater than the max, the value is changed to that max value.
value T& | The value to check |
max T | The maximum value to make sure the value is less than or equal to. |
template<typename T> std::string toStr( |
| ) |
Performs a boost::lexical_cast from a value to an std::string
value T | The value to convert to a string. |
The string result of the lexical cast.