SF2 C++ FRC Class Library
Sensor Fusion Framework (SF2) for FRC
Public Member Functions | Public Attributes | List of all members
OrientationHistory Class Reference

The OrientationHistory class implements a timestamped history of orientation data (e.g., from an IMU). More...

#include <OrientationHistory.h>

Inheritance diagram for OrientationHistory:
ISensorDataSubscriber

Public Member Functions

 OrientationHistory (ISensorInfo *p_sensor, int history_length_num_samples)
 Constructs an OrientationHistory object with a specified size. More...
 
void reset ()
 Reset the OrientationHistory, clearing all existing entries. More...
 
bool getCurrentQuaternion (TimestampedValue< Quaternion > &out)
 Retrieves the most recently added Quaternion. More...
 
bool getQuaternionAtTime (long requested_timestamp, TimestampedValue< Quaternion > &out)
 Retrieves the TimestampedQuaterion at the specified sensor timestamp. More...
 
float getYawDegreesAtTime (long requested_timestamp)
 Retrieves the yaw angle in degrees at the specified sensor timestamp. More...
 
float getPitchDegreesAtTime (long requested_timestamp)
 Retrieves the pitch angle in degrees at the specified sensor timestamp. More...
 
float getRollDegreesAtTime (long requested_timestamp)
 Retrieves the roll angle in degrees at the specified sensor timestamp. More...
 
virtual void publish (vector< IQuantity * > curr_values, Timestamp &sys_timestamp)
 
bool writeToDirectory (string directory_path)
 
bool writeToFile (string file_path)
 

Public Attributes

const int MAX_ORIENTATION_HISTORY_LENGTH_NUM_SAMPLES = 1000
 

Detailed Description

The OrientationHistory class implements a timestamped history of orientation data (e.g., from an IMU).

The OrientationHistory is populated by data from a "timestamped quaternion" sensor, such as the navX-MXP.

The OrientationHistory buffers the orientation data received over the most current time period between "now" and the size of the time history, and provides methods to retrieve orientation data in the form of TimestampedQuaternion objects. These objects can be looked up based upon a timestamp; if an exact match is found the object is returned direction; otherwise if TimestampedQuaternion objects exist for the times before and after the requested timestamp, a new TimestampedQuaterion object is created via interpolation.

Author
Scott

Constructor & Destructor Documentation

OrientationHistory::OrientationHistory ( ISensorInfo p_sensor,
int  history_length_num_samples 
)
inline

Constructs an OrientationHistory object with a specified size.

The OrientationHistory registers for incoming data using the provided ITimestampedQuaternionSensor object.

Parameters
quat_sensor- the sensor to acquire TimestampedQuaternion objects from.
history_length_seconds- the length of the OrientationHistory, in seconds. The actual length of the OrientationHistory in number of objects is calculated internally by accessing the sensor's current update rate. Note: if the sensor update rate is changed, after this constructor is invoked, the length of the history may no longer accurately reflect the originally-configured length.
quat_sensor- the sensor to use as the source of TimestampedQuaternions contained in the Orientation History
history_length_seconds- the number of seconds the history will represent. This value may not be larger than #MAX_ORIENTATION_HISTORY_IN_SECONDS seconds.

Member Function Documentation

bool OrientationHistory::getCurrentQuaternion ( TimestampedValue< Quaternion > &  out)
inline

Retrieves the most recently added Quaternion.

Returns
float OrientationHistory::getPitchDegreesAtTime ( long  requested_timestamp)
inline

Retrieves the pitch angle in degrees at the specified sensor timestamp.

Note that this value may be interpolated if a sample at the requested time is not available.

Parameters
requested_timestamp
Returns
Pitch angle (in degrees, range -180 to 180) at the requested timestamp. If a pitch angle at the specified timestamp could not be found/interpolated, the value INVALID_ANGLE (NaN) will be returned.
bool OrientationHistory::getQuaternionAtTime ( long  requested_timestamp,
TimestampedValue< Quaternion > &  out 
)
inline

Retrieves the TimestampedQuaterion at the specified sensor timestamp.

If an exact timestamp match occurs, a TimestampedQuaternion representing the actual (measured) data is returned; otherwise a new interpolated TimestampedQuaternion will be estimated, using the nearest preceding/following TimestampedQuaternion and the requested timestamp's ratio of time between them as its basis. If no exact match could be found or interpolated value estimated, null is returned.

Parameters
requested_timestamp- sensor timestamp to retrieve
Returns
TimestampedQuaternion at requested timestamp, or null.
float OrientationHistory::getRollDegreesAtTime ( long  requested_timestamp)
inline

Retrieves the roll angle in degrees at the specified sensor timestamp.

Note that this value may be interpolated if a sample at the requested time is not available.

Parameters
requested_timestamp
Returns
Roll angle (in degrees, range -180 to 180) at the requested timestamp. If a roll angle at the specified timestamp could not be found/interpolated, the value INVALID_ANGLE (NaN) will be returned.
float OrientationHistory::getYawDegreesAtTime ( long  requested_timestamp)
inline

Retrieves the yaw angle in degrees at the specified sensor timestamp.

Note that this value may be interpolated if a sample at the requested time is not available.

Parameters
requested_timestamp
Returns
Yaw angle (in degrees, range -180 to 180) at the requested timestamp. If a yaw angle at the specified timestamp could not be found/interpolated, the value INVALID_ANGLE (NaN) will be returned.
void OrientationHistory::reset ( )
inline

Reset the OrientationHistory, clearing all existing entries.

Parameters
quat_curr

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