Class QuaternionFrame

java.lang.Object
com.reduxrobotics.frames.Frame<Quaternion>
com.reduxrobotics.sensors.canandgyro.QuaternionFrame

public class QuaternionFrame extends Frame<Quaternion>
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

    Constructors
    Constructor
    Description
    QuaternionFrame(double timestamp, Quaternion defaultData)
    Instantiates a new QuaternionFrame.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Flag that this frame's data is not valid.
    double
    Gets the Euler pitch value in rotations from [-0.5 inclusive..0.5 exclusive).
    double
    Gets the Euler roll value in rotations from [-0.5 inclusive..0.5 exclusive).
    Returns the value of the data frame.
    double
    Gets the W term of the current quaternion, normalized from [-1.0..1.0] inclusive.
    double
    Gets the X term of the current quaternion, normalized from [-1.0..1.0] inclusive.
    double
    Gets the Y term of the current quaternion, normalized from [-1.0..1.0] inclusive.
    double
    Gets the Euler yaw value in rotations from [-0.5 inclusive..0.5 exclusive).
    double
    Gets the Z term of the current quaternion, normalized from [-1.0..1.0] inclusive.
    boolean
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • QuaternionFrame

      public QuaternionFrame(double timestamp, Quaternion defaultData)
      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

      public Quaternion getValue()
      Description copied from class: Frame
      Returns the value of the data frame.
      Specified by:
      getValue in class Frame<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 class Frame<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 with
      timestamp - the timestamp at which it occured