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
ConstructorsConstructorDescriptionQuaternionFrame(double timestamp, Quaternion defaultData) Instantiates a new QuaternionFrame. -
Method Summary
Modifier and TypeMethodDescriptionvoidFlag that this frame's data is not valid.doublegetPitch()Gets the Euler pitch value in rotations from [-0.5 inclusive..0.5 exclusive).doublegetRoll()Gets the Euler roll value in rotations from [-0.5 inclusive..0.5 exclusive).getValue()Returns the value of the data frame.doublegetW()Gets the W term of the current quaternion, normalized from [-1.0..1.0] inclusive.doublegetX()Gets the X term of the current quaternion, normalized from [-1.0..1.0] inclusive.doublegetY()Gets the Y term of the current quaternion, normalized from [-1.0..1.0] inclusive.doublegetYaw()Gets the Euler yaw value in rotations from [-0.5 inclusive..0.5 exclusive).doublegetZ()Gets the Z term of the current quaternion, normalized from [-1.0..1.0] inclusive.booleanhasData()Returns if this frame has data.voidupdateData(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:FrameReturns the value of the data frame.- Specified by:
getValuein 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:
hasDatain 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
-