Class QuaternionFrame
Implements an object-holding Frame with considerations for quaternions.
This avoids creation of new objects by only converting to a
Quaternion
when the value is requested,
while also offering interfaces to efficiently retrieve components without allocation.-
Nested Class Summary
Nested classes/interfaces inherited from class com.reduxrobotics.frames.Frame
Frame.FrameCallback<FC>
-
Constructor Summary
ConstructorDescriptionQuaternionFrame
(double timestamp, Quaternion defaultData) Instantiates a new QuaternionFrame. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Flag that this frame's data is not valid.double
getPitch()
Gets the Euler pitch value in rotations from [-0.5 inclusive..0.5 exclusive).double
getRoll()
Gets the Euler roll value in rotations from [-0.5 inclusive..0.5 exclusive).getValue()
Returns the value of the data frame.double
getW()
Gets the W term of the current quaternion, normalized from [-1.0..1.0] inclusive.double
getX()
Gets the X term of the current quaternion, normalized from [-1.0..1.0] inclusive.double
getY()
Gets the Y term of the current quaternion, normalized from [-1.0..1.0] inclusive.double
getYaw()
Gets the Euler yaw value in rotations from [-0.5 inclusive..0.5 exclusive).double
getZ()
Gets the Z term of the current quaternion, normalized from [-1.0..1.0] inclusive.boolean
hasData()
Returns if this frame has data.void
updateData
(byte[] data, double timestamp) Update the Frame with new data.Methods inherited from class com.reduxrobotics.frames.Frame
addCallback, getFrameData, getTimestamp, maxTimestamp, removeCallback, update, waitForFrames
-
Constructor Details
-
QuaternionFrame
Instantiates a new QuaternionFrame.- Parameters:
timestamp
- The timestamp the update happened at.defaultData
- An instance of the object to return before the first update happens.
-
-
Method Details
-
getValue
Description copied from class:Frame
Returns the value of the data frame.- Specified by:
getValue
in classFrame<Quaternion>
- Returns:
- the value the data frame holds.
-
getW
public double getW()Gets the W term of the current quaternion, normalized from [-1.0..1.0] inclusive.- Returns:
- quaternion term value
-
getX
public double getX()Gets the X term of the current quaternion, normalized from [-1.0..1.0] inclusive.- Returns:
- quaternion term value
-
getY
public double getY()Gets the Y term of the current quaternion, normalized from [-1.0..1.0] inclusive.- Returns:
- quaternion term value
-
getZ
public double getZ()Gets the Z term of the current quaternion, normalized from [-1.0..1.0] inclusive.- Returns:
- quaternion term value
-
getRoll
public double getRoll()Gets the Euler roll value in rotations from [-0.5 inclusive..0.5 exclusive).- Returns:
- roll value in rotations
-
getPitch
public double getPitch()Gets the Euler pitch value in rotations from [-0.5 inclusive..0.5 exclusive).- Returns:
- pitch value in rotations
-
getYaw
public double getYaw()Gets the Euler yaw value in rotations from [-0.5 inclusive..0.5 exclusive).- Returns:
- yaw value in rotations
-
hasData
public boolean hasData()Returns if this frame has data.- Specified by:
hasData
in classFrame<Quaternion>
- Returns:
- if this frame's data can be considered valid
-
clearData
public void clearData()Flag that this frame's data is not valid. -
updateData
public void updateData(byte[] data, double timestamp) Update the Frame with new data.- Parameters:
data
- the new data to update withtimestamp
- the timestamp at which it occured
-