A message field for an angle measurement which does not lose precision at very high angles. More...
#include <command.hpp>
Public Member Functions | |
void | clear () |
Removes any currently set value for this field. More... | |
double | get () const |
If the field has a value, returns that value as a double; otherwise, returns a default. More... | |
void | get (int64_t *revolutions, float *radian_offset) const |
If the field has a value, returns that value in the int64 and float parameters passed in; otherwise, returns a default. More... | |
bool | has () const |
True if (and only if) the field has a value. More... | |
HighResAngleField (HebiCommandPtr internal, HebiCommandHighResAngleField field) | |
operator bool () const | |
Allows casting to a bool to check if the field has a value without directly calling has() . More... | |
void | set (double radians) |
Sets the field to a given double value (in radians). Note that double precision floating point numbers cannot represent the same angular resolution at very high magnitudes as they can at lower magnitudes. More... | |
void | set (int64_t revolutions, float radian_offset) |
Sets the field to a given integer number of revolutions and a floating point offset from this number of revolutions. The offset does not specifically need to fall within a certain range (i.e., can add more than a single revolution to the integer value), but should be kept relatively small (e.g., below 10,000) to avoid potential loss of precision. More... | |
Private Attributes | |
HebiCommandHighResAngleField const | field_ |
HebiCommandPtr const | internal_ |
A message field for an angle measurement which does not lose precision at very high angles.
This field is represented as an int64_t for the number of revolutions and a float for the radian offset from that number of revolutions.
Definition at line 89 of file command.hpp.
hebi::Command::HighResAngleField::HighResAngleField | ( | HebiCommandPtr | internal, |
HebiCommandHighResAngleField | field | ||
) |
Definition at line 46 of file command.cpp.
void hebi::Command::HighResAngleField::clear | ( | ) |
Removes any currently set value for this field.
Definition at line 101 of file command.cpp.
double hebi::Command::HighResAngleField::get | ( | ) | const |
If the field has a value, returns that value as a double; otherwise, returns a default.
Note that some precision might be lost converting to a double at very high number of revolutions.
Definition at line 61 of file command.cpp.
void hebi::Command::HighResAngleField::get | ( | int64_t * | revolutions, |
float * | radian_offset | ||
) | const |
If the field has a value, returns that value in the int64 and float parameters passed in; otherwise, returns a default.
Note that this maintains the full precision of the underlying angle measurement, even for very large numbers of revolutions.
revolutions | The number of full revolutions |
radian_offset | The offset from the given number of full revolutions. Note that this is usually between 0 and 2*M_PI , but callers should not assume this. |
Definition at line 75 of file command.cpp.
bool hebi::Command::HighResAngleField::has | ( | ) | const |
True if (and only if) the field has a value.
Definition at line 56 of file command.cpp.
|
explicit |
Allows casting to a bool to check if the field has a value without directly calling has()
.
This can be used as in the following (assuming 'parent' is a parent message, and this field is called 'myField')
Definition at line 51 of file command.cpp.
void hebi::Command::HighResAngleField::set | ( | double | radians | ) |
Sets the field to a given double value (in radians). Note that double precision floating point numbers cannot represent the same angular resolution at very high magnitudes as they can at lower magnitudes.
Definition at line 84 of file command.cpp.
void hebi::Command::HighResAngleField::set | ( | int64_t | revolutions, |
float | radian_offset | ||
) |
Sets the field to a given integer number of revolutions and a floating point offset from this number of revolutions. The offset does not specifically need to fall within a certain range (i.e., can add more than a single revolution to the integer value), but should be kept relatively small (e.g., below 10,000) to avoid potential loss of precision.
Definition at line 96 of file command.cpp.
|
private |
Definition at line 145 of file command.hpp.
|
private |
Definition at line 144 of file command.hpp.