Replace manual buffer management (malloc/free/snprintf) with a simple
stack-allocated TestOutput helper. Uses dump_simulation_state's 4-param
API with a single dump_state() method. Verification stays as individual
INFO() calls outside the loop.
Planning doc updates:
- Replace estimate table with actual measured values from DT sweep test
- Add 0.5s and 2.0s data points (69m and 228m respectively)
- Mark DT sweep tests as COMPLETED section
- Add analysis note about linear scaling with DT
New tests in test_maneuver_planning.cpp:
1. DT sweep: Hohmann transfer separation vs time step
- Runs full Hohmann transfer at DT = {0.1, 0.5, 1.0, 2.0, 5.0, 10.0}
- Verifies final separation matches expected ranges
- Confirms ecc < 0.01 for DT <= 1.0
2. DT sweep: quantization error is bounded by DT
- Tests 9 trigger offsets per DT value at DT = {1, 5, 10, 30}
- Verifies quantization error is always in [0, DT)
- Verifies execution time matches ceil-to-step-boundary
3. DT sweep: Hohmann arrival burn timing error
- Measures exact timing error at each DT
- Reports position error estimate (timing_error × velocity)
- Confirms timing error < DT
All 157 tests pass (240,742 assertions).
Previous: 154 tests, 240,445 assertions.
Mark Issues 1, 2, 5, 6 as RESOLVED. Mark Issue 3 as PARTIALLY RESOLVED.
Mark Issue 4 as UNRESOLVED (time-triggered quantization).
Update call chain diagram to show current merged structure.
Update call sites summary to show final 4 call sites (3 contexts).
Add remaining work section for interpolated time triggers and
parabolic/hyperbolic orbit support.
Consolidate execute_pending_maneuvers() into update_spacecraft_physics()
so every spacecraft goes through exactly one propagation path.
Changes:
- Remove spacecraft_handled_this_frame[256] static array
- Remove reset_spacecraft_tracking() function
- Remove execute_pending_maneuvers() function
- Check maneuver triggers before propagation in update_spacecraft_physics
- Propagate to burn time, execute burn, propagate remainder (same order
as old code)
- Remove execute_pending_maneuvers declaration from simulation.h
Benefits:
- Single propagation call per spacecraft per frame (was 2 paths)
- No static array with magic number
- Simpler call chain: no separate maneuver pass
- Enables sub-step interpolation for true-anomaly triggers
- Sets up foundation for interpolated time triggers
Adds TODO in update_spacecraft_physics about testing interpolated burns.
All 154 tests pass (240,445 assertions).
In check_maneuver_trigger() (true-anomaly branch), eliminate the
propagate_orbital_elements() look-ahead probe that was called every
frame for pending maneuvers. Replace with direct analytical computation
of dt_needed from mean anomaly delta.
Benefits:
- Eliminates ~24k redundant Kepler solves per Hohmann transfer wait
period (DT=10s, 244k s wait time)
- More precise: no discretization error from single-step propagation
- Simpler logic: removed angle_between check, wraparound detection
- Removes dead angle_between() helper function
Elliptical orbits only — added TODO for parabolic/hyperbolic support.
All 154 tests pass (240,445 assertions).
Update planning doc to reflect:
- File renames (rendezvous_hohmann -> rendezvous)
- test_maneuver_timing.cpp merged into test_maneuver_planning.cpp
- Old CW rendezvous module removed (eliminated 3 pre-existing failures)
- Current test results: 154/154 all passing
- Completed work section with full file list
- Remaining work section with optional future tasks
Rename src/rendezvous_hohmann.{h,cpp} to src/rendezvous.{h,cpp} and
tests/test_rendezvous_hohmann.{cpp,toml} to tests/test_rendezvous.{cpp,toml}.
This consolidates the rendezvous module under a simpler name since the
old CW-based rendezvous module was removed and only Hohmann transfer
functionality remains.
Update all includes, config paths, and Makefile references.
Reduce TIME_STEP from 10.0 to 0.1 and increase MAX_STEPS to 700000
to achieve sub-10m rendezvous accuracy. Update milestone dump timing
to correctly capture pre/post-burn states. Revert test config to
original values to match test expectations.
Remove src/rendezvous.h, src/rendezvous.cpp, tests/test_rendezvous.cpp,
and tests/test_rendezvous.toml. No other modules depend on these files.
Also remove RendezvousState enum, RendezvousTarget struct, and
rendezvous_target field from Spacecraft in orbital_objects.h.
For coplanar orbits (inclination < 0.01 rad), compute omega from the
eccentricity vector (longitude of periapsis) instead of forcing omega=0.
This is necessary for correct post-burn orbital element conversion,
critical for Hohmann transfer accuracy.
Update test_omega_debug to accept the new behavior: omega is computed
from the eccentricity vector direction for coplanar orbits.
Add validate_hohmann_transfer_parameters(), calculate_relative_orbit_period(),
and calculate_next_hohmann_wait_time() for robust Hohmann transfer setup.
Update required_separation() and calculate_wait_time_for_hohmann() to use
[-pi, pi] normalization instead of [0, 2pi).
- Convert typedef enum to C++ style enum
- Convert typedef struct to C++ style struct {}
- Add RendezvousState type to RendezvousTarget::state field
- Update comments to one-liners with inline descriptions
- Remove redundant struct names from comments
- Move RendezvousState and RendezvousTarget from rendezvous_types.h to orbital_objects.h
- Remove rendezvous_types.h entirely
- Simplify rendezvous.h to depend on orbital_objects.h
- Delete spacecraft.h and spacecraft.cpp (consolidated into orbital_objects.h)
- Update all include paths across codebase
- All tests pass (4 pre-existing failures unchanged)
- Add scheduled_dt field to Maneuver struct for precise timing
- Propagate spacecraft to exact trigger position before burn execution
- Handle 2π→0 wraparound in trigger crossing detection
- Add spacecraft tracking to prevent double-propagation in same frame
- Fix test configs and tolerances for new behavior
All 143 tests passing.
- Fix omega = π bug for near-zero inclination orbits (src/orbital_mechanics.cpp:277)
- Added inclination threshold (0.01 rad) before using atan2 path
- Prevents unstable omega calculation when h_vec.y is tiny
- Fix true anomaly trigger firing at wrong location (src/maneuver.cpp:172-213)
- Replaced binary search with O(1) analytical time calculation
- Uses mean motion: n = √(μ/a³) to compute exact time to target
- Added true_anomaly_to_eccentric_anomaly() function
See docs/planning/periapsis_burn_bug_analysis.md for technical details
See docs/periaapsis_burn_test_results.md for test results and next steps
Test status:
- Issue 1 (omega): ✅ FIXED and validated
- Issue 2 (triggers): ✅ IMPLEMENTED, 4 tests fail due to design (expected behavior)
- Full suite: 139 passed, 4 failed (all periapsis burn tests)
Next steps: Decide on test tolerance approach (see docs/periaapsis_burn_test_results.md)
Added planning document detailing two separate issues causing
periapsis burns to execute at incorrect locations:
Issue 1: Omega = π instead of 0 for near-zero inclination orbits
- Unstable atan2 calculation in cartesian_to_orbital_elements()
- Occurs when n_mag > 1e-10 due to tiny h_vec.y from i ≈ 0
- Fix: Add inclination threshold (0.01 rad) before using atan2 path
Issue 2: True anomaly trigger fires early at wrong location
- angle_between() detects upcoming crossing, fires immediately
- Executes burn at current position instead of waiting for target angle
- Proposed fixes: Defer execution, interpolate, or remove future check
Also cleaned up:
- Removed temporary debug files (debug_test_burn.cpp, debug_trace.cpp)
- Removed debug output from src/orbital_mechanics.cpp
- Kept tests/test_omega_debug.cpp as it validates Issue 1 fix
See docs/planning/periapsis_burn_bug_analysis.md for full details.
Added test cases that reveal the bug where periapsis burns execute
at apoapsis instead of periapsis after the first burn.
Changes:
- Modified tests/test_periapsis_burn.toml to include second spacecraft
(TestSatelliteCrossing) starting at true_anomaly = 1.57
- Replaced test "Prograde burn at periapsis raises apoapsis" with
"Two periapsis burns execute at same location" to verify sequential
periapsis burns one orbit apart both fire at correct location
- Added test "Periapsis burn fires when crossing periapsis" to verify burn
triggers when spacecraft crosses periapsis from 90 degrees
Both new tests fail as expected, confirming the bug exists in
cartesian_to_orbital_elements() where argument_of_periapsis is
calculated as π instead of 0 after a burn.
Test status: 4 periapsis tests fail (capturing bug)
Swap order in update_simulation() to check maneuvers before physics update.
This ensures triggers fire at the correct position instead of after the
spacecraft has moved past the trigger point.
Also fix test config to avoid interference between time-based and true
anomaly triggers.
Documents a bug where true anomaly triggers set to 0 (periapsis) don't
execute because the spacecraft moves past periapsis before the trigger
check happens. The trigger check occurs after physics propagation in the
simulation update order.
- test_periapsis_burn.cpp: Three test cases demonstrating expected behavior
1. Verify periapsis distance is preserved after prograde burn (fails - shows bug)
2. Verify apoapsis raises and periapsis stays same (skipped - depends on fix)
3. Verify burn location equals new periapsis (skipped - depends on fix)
- test_periapsis_burn.toml: Test configuration with elliptical orbit satellite
starting at periapsis with a true anomaly trigger at 0