Skip to content

Improve robustness of save data#89

Merged
thompson318 merged 7 commits into
mainfrom
km/save-robust
Jun 3, 2026
Merged

Improve robustness of save data#89
thompson318 merged 7 commits into
mainfrom
km/save-robust

Conversation

@K-Meech
Copy link
Copy Markdown
Collaborator

@K-Meech K-Meech commented May 29, 2026

For #77

  • Adds option to write sampled speeds to file for star collector (matching existing option for rocket launch). Rocket launch / star collector are the only games that use the buffers.

  • Added a minimum interval between falls for the zero gravity save data. This can be adjusted on the 'sway line' - currently set to 0.5 seconds.

  • Updated constructor of GazeItem to match HeadPoseItem

  • Updated docs to match changes

  • At the moment, we have to manually set the buffer size large enough to handle the time range we are interested in for each game. Potentially, this may cause issues in future if the time is updated without the buffer size.

    To help make this more robust, I checked the rate with which new items are added to the pose and gaze buffers. I made two simple scenes on a separate branch for testing (km/tracker-refresh) called RotationRefresh and GazeRefresh. Each has a simple script enabled that pulls data from the tracker every update and adds it to the buffer + logs some values. For both, the interval between new readings seemed to consistently be ~0.03 seconds (or 33 Hertz, matching the recorded head tracking specs for Tobii 5. Based on other spec sheets I might have expected the gaze rate to be higher, but it also seems to be 0.03seconds consistently). This matches @thompson318 's estimates in this comment: Expand data for star collector game #76 (comment) My frame rate (the rate with which update was called) was higher than this, as I could see the game trying to add the same value to the buffer multiple times, but being rejected due to their identical time stamps - so hopefully this is reasonably reflective of the fastest rate with which we can get new values from the tracker.

    Based on this I've updated TrackerBuffers so you can provide an expected time period in seconds, and it will set the capacity accordingly as: 1.5 * (secondsOfData / 0.03). The 1.5x is to make the buffer 50% larger than the minimum required value, to give some headroom in case there are a few extra values added. This should mean the buffer always has enough capacity to match the time periods needed in the games that use it (rocket launch and star collector).

@K-Meech K-Meech requested review from mmcleod89 and thompson318 May 29, 2026 14:09
@K-Meech K-Meech mentioned this pull request May 29, 2026
6 tasks
Copy link
Copy Markdown
Member

@thompson318 thompson318 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks good to me. Nice work on replacing the minimum buffer size with something more sensible. I found one comparison on a float that might cause problems if code was changed in the future.

Comment thread projects/AstroBalance/Assets/Scripts/ZeroGravity/SwayLine.cs Outdated
Co-authored-by: Stephen Thompson <s.thompson@ucl.ac.uk>
@K-Meech
Copy link
Copy Markdown
Collaborator Author

K-Meech commented Jun 3, 2026

Thanks @thompson318 - I agree, comparison to 0 (rather than -1) is more robust, so I've added that change. Feel free to merge this if you're happy with it 👍

@thompson318 thompson318 merged commit 26796f4 into main Jun 3, 2026
1 check passed
@K-Meech K-Meech deleted the km/save-robust branch June 3, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants