Skip to content

Fix spiceInterface GPS time and Julian date - #1617

Merged
schaubh merged 5 commits into
AVSLab:developfrom
carlo98:hotfix/bsk-1612-gps_time
Oct 17, 2026
Merged

schaubh merged 5 commits into
AVSLab:developfrom
carlo98:hotfix/bsk-1612-gps_time

Conversation

@carlo98

@carlo98 carlo98 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Description

spiceInterface filled the GPS and Julian date fields of spiceTimeOutMsg incorrectly:

  • GPS time was computed as the elapsed TDB time since the GPS epoch. GPS time is atomic time (TAI - 19 s), so GPSSeconds was off by the periodic TDB - TT term, and GPSWeek / GPSRollovers could be one week early near a week boundary.
  • JulianDateCurrent was parsed from the SPICE et2utc_c Julian date string. That string has at most seven decimals, so the value was quantized to 1e-7 day.
  • GPSSeconds was computed as JDDifference - GPSWeek*7*86400 in integer arithmetic, which overflows a signed 32-bit integer after GPS week 3550.
  • Starting the simulation before the GPS epoch gave invalid GPS outputs (negative elapsed time cast to uint16_t).

Changes:

  1. GPS elapsed time is now the difference of the TAI times at the current time and at the GPS epoch. The UTC Julian date is computed directly from the ephemeris time minus deltet_c (ET - UTC), which removes the string round trip and the now-unused spiceBuffer member.
  2. The total week count is held in a uint64_t and the seconds of week are computed in double.
  3. The TAI of the GPS epoch is computed once in initTimeData() and stored in TAIGPSEpoch (replacing JDGPSEpoch). Negative GPS time is not modeled: if the initial time is before the GPS epoch, a BSK_WARNING is emitted at reset and the GPS outputs are held at zero until the epoch is reached.

Verification

  • Added src/simulation/environment/spiceInterface/_UnitTest/test_spiceTimeOutput.py.
  • Updated test_unitSpice.py: the expected GPS time now removes the periodic TDB - TT term of the SPICE leap seconds kernel, since GPS time is atomic time.
  • Updated test_spiceBufferOwnership.py: tightened the Julian date tolerance from 5e-8 day to 1e-9 day, and removed the spiceBuffer parameter of the private storage test.

Documentation

  • spiceInterface.rst: new section describing the time scales of spiceTimeOutMsg and the behavior before the GPS epoch.
  • SpiceTimeMsgPayload.h and spiceInterface.h: clarified field comments and units.
  • bskKnownIssues.rst: added the GitHub issue 1612 entry.
  • Added a release notes snippet.

Future work

  • Negative GPS time (simulations before 1980 January 6) is not modeled; the outputs are held at zero.

@carlo98
carlo98 requested a review from a team as a code owner October 16, 2026 12:04
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-16T12:05:59.636627Z ef9a58c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@schaubh schaubh self-assigned this Oct 16, 2026
@schaubh schaubh added the bug Something isn't working label Oct 16, 2026
@schaubh schaubh added this to Basilisk Oct 16, 2026
@schaubh schaubh linked an issue Oct 16, 2026 that may be closed by this pull request

@schaubh schaubh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The issue in #1612 is valid, and the TAI-based GPS correction looks sound. I found one reproducible Julian-date regression that should be addressed before merging. The 41 focused tests pass, but an additional test sampling inside a leap second passes on the original implementation and fails on this PR.

Comment thread src/simulation/environment/spiceInterface/spiceInterface.cpp Outdated
@schaubh
schaubh force-pushed the hotfix/bsk-1612-gps_time branch from 5531980 to 251806e Compare October 17, 2026 01:12
@schaubh
schaubh merged commit c3fc9dd into AVSLab:develop Oct 17, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this to ✅ Done in Basilisk Oct 17, 2026
@carlo98
carlo98 deleted the hotfix/bsk-1612-gps_time branch October 17, 2026 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

GPS time off by up to 1.7 ms and UTC Julian date quantized

2 participants