From a4c1cdc89ad90ce872284d2f61290fd9341c9055 Mon Sep 17 00:00:00 2001 From: Juan Chong Date: Sat, 7 Dec 2024 16:52:18 -0800 Subject: [PATCH] Added headset battery telemetry --- .../src/main/java/frc/robot/subsystems/DriveSubsystem.java | 1 + unity/Assets/Robot/MotionStreamer.cs | 4 ++++ unity/ProjectSettings/ProjectSettings.asset | 2 ++ 3 files changed, 7 insertions(+) diff --git a/java-robot/src/main/java/frc/robot/subsystems/DriveSubsystem.java b/java-robot/src/main/java/frc/robot/subsystems/DriveSubsystem.java index 0f4e2de..168966e 100644 --- a/java-robot/src/main/java/frc/robot/subsystems/DriveSubsystem.java +++ b/java-robot/src/main/java/frc/robot/subsystems/DriveSubsystem.java @@ -60,6 +60,7 @@ public class DriveSubsystem extends SubsystemBase { private FloatArraySubscriber questPosition = nt4Table.getFloatArrayTopic("position").subscribe(new float[]{0.0f, 0.0f, 0.0f}); private FloatArraySubscriber questQuaternion = nt4Table.getFloatArrayTopic("quaternion").subscribe(new float[]{0.0f, 0.0f, 0.0f, 0.0f}); private FloatArraySubscriber questEulerAngles = nt4Table.getFloatArrayTopic("eulerAngles").subscribe(new float[]{0.0f, 0.0f, 0.0f}); + private DoubleSubscriber questBattery = nt4Table.getDoubleTopic("batteryLevel").subscribe(0.0f); // Local heading helper variables private float yaw_offset = 0.0f; diff --git a/unity/Assets/Robot/MotionStreamer.cs b/unity/Assets/Robot/MotionStreamer.cs index 4250bc7..8d9f719 100644 --- a/unity/Assets/Robot/MotionStreamer.cs +++ b/unity/Assets/Robot/MotionStreamer.cs @@ -36,6 +36,7 @@ public class MotionStreamer : MonoBehaviour [SerializeField] public Transform vrCamera; // The VR camera transform [SerializeField] public Transform vrCameraRoot; // The root of the camera transform [SerializeField] public Transform resetTransform; // The desired position & rotation (look direction) for your player + private float batteryLevel; // Local variable to store the headset battery level /* NT configuration settings */ private readonly string appName = "Quest3S"; // A fun name to ID the client in the robot logs @@ -95,6 +96,7 @@ private void PublishTopics() frcDataSink.PublishTopic("/oculus/position", "float[]"); frcDataSink.PublishTopic("/oculus/quaternion", "float[]"); frcDataSink.PublishTopic("/oculus/eulerAngles", "float[]"); + frcDataSink.PublishTopic("/oculus/batteryLevel", "double"); frcDataSink.Subscribe("/oculus/mosi", 0.1, false, false, false); } @@ -106,12 +108,14 @@ private void PublishFrameData() position = cameraRig.centerEyeAnchor.position; rotation = cameraRig.centerEyeAnchor.rotation; eulerAngles = cameraRig.centerEyeAnchor.eulerAngles; + batteryLevel = SystemInfo.batteryLevel; frcDataSink.PublishValue("/oculus/frameCount", frameIndex); frcDataSink.PublishValue("/oculus/timestamp", timeStamp); frcDataSink.PublishValue("/oculus/position", position.ToArray()); frcDataSink.PublishValue("/oculus/quaternion", rotation.ToArray()); frcDataSink.PublishValue("/oculus/eulerAngles", eulerAngles.ToArray()); + frcDataSink.PublishValue("/oculus/batteryLevel", batteryLevel); } // Process commands from the robot diff --git a/unity/ProjectSettings/ProjectSettings.asset b/unity/ProjectSettings/ProjectSettings.asset index 39597fd..f5d29d4 100644 --- a/unity/ProjectSettings/ProjectSettings.asset +++ b/unity/ProjectSettings/ProjectSettings.asset @@ -144,6 +144,8 @@ PlayerSettings: preloadedAssets: - {fileID: 11400000, guid: a3acedfb9d10ebb4980afb2325590b51, type: 2} - {fileID: -944628639613478452, guid: 052faaac586de48259a63d0c4782560b, type: 3} + - {fileID: -2134709449523983886, guid: 1ba2bee52a945594c9a9f310bc44469f, type: 2} + - {fileID: 11400000, guid: c1de0065df926df4e9b73f8c9e739146, type: 2} metroInputSource: 0 wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1