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.doubleGets the Quest app's timestamp since start THIS IS NOT THE SAME AS THE TIMESTAMP USED WITH AN ESTIMATOR! See 'getDataTimestamp' insteadintGets the battery percentage of the Quest headset.doubleGets the NT timestamp of when the data was sent.intGets the current frame count from the Quest headset.doubleGets the latency of the Quest > Robot Connectionedu.wpi.first.math.geometry.Pose2dgetPose()Converts the QuestNav rotation to a Rotation2d object.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 FRC 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 FRC field relative pose of the Quest. This is the QUESTS POSITION, NOT THE ROBOTS! 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()Gets the battery percentage of the Quest headset.- Returns:
- The battery percentage as a Double value
-
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 checking when the last battery update was received.- 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:
- double indicating the latency of the frameData (the important part)
-
getAppTimestamp
public double getAppTimestamp()Gets the Quest app's timestamp since start THIS IS NOT THE SAME AS THE TIMESTAMP USED WITH AN ESTIMATOR! See 'getDataTimestamp' instead- Returns:
- The timestamp as a double value
-
getDataTimestamp
public double getDataTimestamp()Gets the NT timestamp of when the data was sent. THIS IS THE VALUE YOU USE WHEN ADDING TO AN ESTIMATOR- Returns:
- The timestamp as a double value
-
getPose
public edu.wpi.first.math.geometry.Pose2d getPose()Converts the QuestNav rotation to a Rotation2d object. Applies necessary coordinate system transformations.- Returns:
- Rotation2d representing the headset's yaw
-
commandPeriodic
public void commandPeriodic()Cleans up QuestNav responses after processing on the headset.
-