HEBI C++ API  3.9.0
hebi::Info::HighResAngleField Class Referencefinal

A message field for an angle measurement which does not lose precision at very high angles. More...

#include <info.hpp>

Public Member Functions

 operator bool () const
 Allows casting to a bool to check if the field has a value without directly calling has(). More...
 
bool has () const
 True if (and only if) the field has a value. 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...
 

Detailed Description

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.

Member Function Documentation

◆ operator bool()

hebi::Info::HighResAngleField::operator bool ( ) const
inlineexplicit

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')

Info::HighResAngleField& f = parent.myField();
if (f)
std::cout << "Field has value: " << f.get() << std::endl;
else
std::cout << "Field has no value!" << std::endl;

◆ has()

bool hebi::Info::HighResAngleField::has ( ) const

True if (and only if) the field has a value.

◆ get() [1/2]

double hebi::Info::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.

◆ get() [2/2]

void hebi::Info::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.

Parameters
revolutionsThe number of full revolutions
radian_offsetThe 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.

The documentation for this class was generated from the following files: