Class QuestNav

java.lang.Object
gg.questnav.questnav.QuestNav

public class QuestNav extends Object
The QuestNav class provides an interface to communicate with an Oculus/Meta Quest VR headset for robot localization and tracking purposes. It uses NetworkTables to exchange data between the robot and the Quest device.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new QuestNav implementation
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Cleans up QuestNav responses after processing on the headset.
    double
    Returns the Quest app's uptime timestamp.
    int
    Returns the Quest's battery level (0-100%), or -1 if no data is available
    double
    Gets the NT timestamp of when the last frame data was sent.
    int
    Gets the current frame count from the Quest headset.
    double
    Gets the latency of the Quest > Robot Connection.
    edu.wpi.first.math.geometry.Pose2d
    Returns the current pose of the Quest on the field.
    int
    Gets the number of tracking lost events since the Quest connected to the robot.
    boolean
    Determines if the Quest headset is currently connected to the robot.
    boolean
    Gets the current tracking state of the Quest headset.
    void
    setPose(edu.wpi.first.math.geometry.Pose2d pose)
    Sets the field-relative pose of the Quest.

    Methods inherited from class java.lang.Object

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

    • QuestNav

      public QuestNav()
      Creates a new QuestNav implementation
  • Method Details

    • setPose

      public void setPose(edu.wpi.first.math.geometry.Pose2d pose)
      Sets the field-relative pose of the Quest. This is the position of the Quest, not the robot. Make sure you correctly offset back from the center of your robot first.
      Parameters:
      pose - The field relative position of the Quest
    • getBatteryPercent

      public int getBatteryPercent()
      Returns the Quest's battery level (0-100%), or -1 if no data is available
      Returns:
      The battery percentage as an int, or -1 if no data is available
    • isTracking

      public boolean isTracking()
      Gets the current tracking state of the Quest headset.
      Returns:
      Boolean indicating if the Quest is currently tracking (true) or not (false)
    • getFrameCount

      public int getFrameCount()
      Gets the current frame count from the Quest headset.
      Returns:
      The frame count value
    • getTrackingLostCounter

      public int getTrackingLostCounter()
      Gets the number of tracking lost events since the Quest connected to the robot.
      Returns:
      The tracking lost counter value
    • isConnected

      public boolean isConnected()
      Determines if the Quest headset is currently connected to the robot. Connection is determined by how stale the last received frame from the Quest is.
      Returns:
      Boolean indicating if the Quest is connected (true) or not (false)
    • getLatency

      public double getLatency()
      Gets the latency of the Quest > Robot Connection. Returns the latency between the current time and the last frame data update.
      Returns:
      The latency in milliseconds
    • getAppTimestamp

      public double getAppTimestamp()
      Returns the Quest app's uptime timestamp. For integration with a pose estimator, use getDataTimestamp() instead!
      Returns:
      The timestamp as a double value
    • getDataTimestamp

      public double getDataTimestamp()
      Gets the NT timestamp of when the last frame data was sent. This is the value which should be used with a pose estimator.
      Returns:
      The timestamp as a double value in seconds
    • getPose

      public edu.wpi.first.math.geometry.Pose2d getPose()
      Returns the current pose of the Quest on the field. This will only return the field-relative pose if setPose(Pose2d) has been called at least once.
      Returns:
      Pose2d representing the Quest's location on the field
    • commandPeriodic

      public void commandPeriodic()
      Cleans up QuestNav responses after processing on the headset.