Skip to content

Commit

Permalink
Added headset battery telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
juchong committed Dec 8, 2024
1 parent 6f27dca commit a4c1cdc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions unity/Assets/Robot/MotionStreamer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions unity/ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a4c1cdc

Please sign in to comment.