Package gg.questnav.questnav
Class QuestNav
java.lang.Object
gg.questnav.questnav.QuestNav
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidCleans up QuestNav responses after processing on the headset.doubleReturns the Quest app's uptime timestamp.intReturns the Quest's battery level (0-100%), or -1 if no data is availabledoubleGets the NT timestamp of when the last frame data was sent.intGets the current frame count from the Quest headset.doubleGets the latency of the Quest > Robot Connection.edu.wpi.first.math.geometry.Pose2dgetPose()Returns the current pose of the Quest on the field.intGets the number of tracking lost events since the Quest connected to the robot.booleanDetermines if the Quest headset is currently connected to the robot.booleanGets the current tracking state of the Quest headset.voidsetPose(edu.wpi.first.math.geometry.Pose2d pose) Sets the field-relative pose of the Quest.
-
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, usegetDataTimestamp()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 ifsetPose(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.
-