vibe coding an orbital mechanics simulation to try out claude code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

2.2 KiB

Hohmann Transfer Rendezvous — Debug Report

Root Cause

The test uses two different time variables that are off by a factor of 10:

  • sim->time — simulation's internal clock, increments by sim->dt = 0.1 each update_simulation() call
  • sim_time — test loop counter, increments by DT = 1.0 each iteration

The dump milestones use sim_time:

if (i == int(wait_time / DT))  // wait_time=60062.65, DT=1.0 → i=60062

But the maneuvers trigger on sim->time. At i=60062, sim->time = 6006.210x too early. The departure maneuver actually fires at i ≈ 600627 (when sim->time ≥ 60062.65).

What This Means

The "AFTER DEPARTURE BURN" dump at i=60064 shows exec=0 — the burn hasn't happened yet. The dumps are capturing state at completely wrong simulation times.

Why the 11,579 km Separation

With TIME_STEP = 0.1, the Hohmann transfer parameters (wait_time = 60062.65, arrival_time = 62804.47) were computed assuming an instantaneous burn at exactly wait_time.

The sub-step interpolation now propagates burn_dt = 0.05 (from sim->time = 60062.6 to trigger = 60062.65), then burns, then propagates remaining = 0.05. This puts the chaser at a different orbital position at burn time than the old code, which propagated the full 0.1 step before burning.

The chaser's true anomaly at t = 60062.65 differs from its true anomaly at t = 60062.7 by ~0.006 rad. The Hohmann phasing was calculated for one starting position but the burn now happens at the other.

The Two Options

  1. Update test expectations — The sub-step interpolation is more physically accurate. The test expectations were tuned to the old quantized (step-boundary) behavior. The 11,579 km error is the old test asserting old behavior.

  2. Change trigger logic — If you want the burn to fire at the step boundary (old behavior), revert scheduled_dt to sim->dt for time triggers. But then you lose sub-step accuracy.

Files to Look At in New Session

  • tests/test_rendezvous.cpp line ~571 — the rendezvous assertion (expects <100m separation)
  • src/maneuver.cpp check_maneuver_trigger() — the TRIGGER_TIME sub-step logic
  • tests/test_rendezvous.toml — initial conditions for the rendezvous scenario