Browse Source

Consolidate rendezvous types into orbital_objects.h

- 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)
main
cinnaboot 3 months ago
parent
commit
2679ec270f
  1. 1
      Makefile
  2. 2
      src/config_loader.h
  3. 2
      src/config_validator.h
  4. 2
      src/maneuver.cpp
  5. 2
      src/maneuver.h
  6. 106
      src/orbital_objects.h
  7. 2
      src/renderer.h
  8. 81
      src/rendezvous.cpp
  9. 41
      src/rendezvous.h
  10. 2
      src/simulation.cpp
  11. 49
      src/simulation.h
  12. 5
      src/spacecraft.cpp
  13. 28
      src/spacecraft.h
  14. 2
      src/ui_renderer.cpp
  15. 2
      tests/test_cartesian_to_elements_advanced.cpp
  16. 2
      tests/test_hybrid_burns.cpp
  17. 2
      tests/test_hybrid_energy_conservation.cpp
  18. 2
      tests/test_maneuver_planning.cpp
  19. 2
      tests/test_maneuvers.cpp
  20. 2
      tests/test_omega_debug.cpp
  21. 2
      tests/test_orbit_rendering.cpp
  22. 2
      tests/test_periapsis_burn.cpp
  23. 36
      tests/test_rendezvous.cpp

1
Makefile

@ -81,7 +81,6 @@ test-build: $(BUILD_DIR) $(C_OBJECTS) $(CPP_OBJECTS) $(TEST_OBJECTS)
build/config_loader.o \
build/config_validator.o \
build/maneuver.o \
build/spacecraft.o \
build/rendezvous.o \
-o $(TEST_TARGET) -lCatch2Main -lCatch2 -lm

2
src/config_loader.h

@ -2,7 +2,7 @@
#define CONFIG_LOADER_H
#include "simulation.h"
#include "spacecraft.h"
#include "orbital_objects.h"
#include "../ext/tomlc17/src/tomlc17.h"
#include "config_validator.h"

2
src/config_validator.h

@ -2,7 +2,7 @@
#define CONFIG_VALIDATOR_H
#include "simulation.h"
#include "spacecraft.h"
#include "orbital_objects.h"
#define MIN_MASS_RATIO 1000.0
#define NESTED_ORBIT_FRACTION 5.0

2
src/maneuver.cpp

@ -1,6 +1,6 @@
#include "maneuver.h"
#include "physics.h"
#include "spacecraft.h"
#include "orbital_objects.h"
#include "simulation.h"
#include "orbital_mechanics.h"
#include <cmath>

2
src/maneuver.h

@ -2,7 +2,7 @@
#define MANEUVER_H
#include "physics.h"
#include "spacecraft.h"
#include "orbital_objects.h"
struct SimulationState;

106
src/orbital_objects.h

@ -0,0 +1,106 @@
#ifndef ORBITAL_OBJECTS_H
#define ORBITAL_OBJECTS_H
#include "physics.h"
#include "orbital_mechanics.h"
// Forward declarations
struct SimulationState;
// ============================================================================
// Rendezvous Types
// ============================================================================
/**
* Rendezvous state machine
*
* States:
* - NONE: No rendezvous active
* - PLANNING: Target selected, approaching
* - APPROACHING: Closing in on target
* - MATCHING: Velocity matching phase
* - COMPLETE: Rendezvous successful
* - FAILED: Rendezvous failed
*/
typedef enum {
RENDEZVOUS_NONE,
RENDEZVOUS_PLANNING,
RENDEZVOUS_APPROACHING,
RENDEZVOUS_MATCHING,
RENDEZVOUS_COMPLETE,
RENDEZVOUS_FAILED
} RendezvousState;
/**
* Rendezvous target structure
*
* Tracks the active rendezvous target and state for a spacecraft
*/
typedef struct {
int target_index; // Index of target spacecraft/body
int state; // RendezvousState
double approach_distance; // Distance to start approach phase (m)
double capture_distance; // Distance for capture (m)
double max_relative_velocity; // Max closing speed for capture (m/s)
double cw_linearization_time; // Last time CW equations were linearized (s)
bool is_spacecraft_target; // True if target is spacecraft, false if body
} RendezvousTarget;
// ============================================================================
// Celestial Body Structure
/**
* Celestial Body Structure
*
* Represents a planet, star, moon, or other gravitational body
* in the simulation. Supports hierarchical orbital mechanics with
* parent-child relationships and sphere of influence calculations.
*/
struct CelestialBody {
char name[64];
double mass; // kg
double radius; // meters
int parent_index; // index of gravitational parent (-1 for root body like Sun)
float color[3]; // RGB color for rendering
// Orbital elements from config (Keplerian elements)
OrbitalElements orbit;
// Global frame (from origin)
Vec3 global_position; // meters from origin
Vec3 global_velocity; // m/s
// Local frame (relative to parent)
Vec3 local_position; // meters from parent
Vec3 local_velocity; // m/s relative to parent
double soi_radius; // sphere of influence radius (meters)
};
/**
* Spacecraft Structure
*
* Represents a spacecraft or probe in the simulation.
* Supports orbital mechanics, maneuvers, and rendezvous operations.
*/
struct Spacecraft {
char name[64];
double mass;
int parent_index;
// Orbital elements from config
OrbitalElements orbit;
// Global frame (from origin)
Vec3 global_position;
Vec3 global_velocity;
// Local frame (relative to parent)
Vec3 local_position;
Vec3 local_velocity;
// Rendezvous support
RendezvousTarget rendezvous_target; // Active rendezvous target (if any)
};
#endif // ORBITAL_OBJECTS_H

2
src/renderer.h

@ -2,7 +2,7 @@
#define RENDERER_H
#include "simulation.h"
#include "spacecraft.h"
#include "orbital_objects.h"
#include "maneuver.h"
#include "raylib.h"

81
src/rendezvous.cpp

@ -89,7 +89,7 @@ CWValidityResult check_cw_validity(
Spacecraft* chaser,
void* target,
CelestialBody* parent,
SimulationState* sim
double current_time
) {
CWValidityResult result = {0};
@ -143,7 +143,7 @@ CWValidityResult check_cw_validity(
bool spatial_ok = spatial_fraction < CW_SPATIAL_LIMIT_FRACTION;
// Check time validity
double time_since_linearization = sim->time - chaser->rendezvous_target.cw_linearization_time;
double time_since_linearization = current_time - chaser->rendezvous_target.cw_linearization_time;
double n_dt = n * time_since_linearization;
bool time_ok = n_dt < CW_TIME_LIMIT_N_DT;
@ -170,7 +170,7 @@ CWGuidanceSolution solve_cw_guidance(
void* target,
CelestialBody* parent,
double time_to_intercept,
SimulationState* sim
double current_time
) {
CWGuidanceSolution solution = {0};
@ -325,88 +325,58 @@ void initialize_rendezvous_target(
target->is_spacecraft_target = is_spacecraft_target;
}
void* get_rendezvous_target(
SimulationState* sim,
int target_index,
bool* is_spacecraft_target
) {
if (target_index < 0 || target_index >= sim->craft_count) {
*is_spacecraft_target = true;
return NULL;
}
// Default to spacecraft
*is_spacecraft_target = true;
return &sim->spacecraft[target_index];
}
void update_rendezvous_state(
Spacecraft* chaser,
SimulationState* sim
RendezvousTarget* target,
CelestialBody* parent,
double current_time,
void* target_obj
) {
RendezvousTarget* target = &chaser->rendezvous_target;
if (target->state == RENDEZVOUS_NONE || target->state == RENDEZVOUS_COMPLETE ||
target->state == RENDEZVOUS_FAILED) {
return;
}
// Get target object
void* target_obj = get_rendezvous_target(sim, target->target_index, &target->is_spacecraft_target);
if (target_obj == NULL) {
target->state = RENDEZVOUS_FAILED;
return;
}
// Get parent body (assumed same for both)
CelestialBody* parent = NULL;
if (chaser->parent_index >= 0 && chaser->parent_index < sim->body_count) {
parent = &sim->bodies[chaser->parent_index];
} else {
target->state = RENDEZVOUS_FAILED;
return;
}
// Calculate current distance and relative velocity
double distance = calculate_rendezvous_distance(chaser, target_obj);
double rel_vel_mag = calculate_relative_velocity_magnitude(chaser, target_obj, parent);
// Check CW validity
CWValidityResult validity = check_cw_validity(chaser, target_obj, parent, sim);
CWValidityResult validity = check_cw_validity(chaser, target_obj, parent, current_time);
// State machine transitions
switch (chaser->rendezvous_target.state) {
switch (target->state) {
case RENDEZVOUS_PLANNING:
// Transition to APPROACHING when within approach distance
if (distance <= chaser->rendezvous_target.approach_distance && validity.overall_valid) {
chaser->rendezvous_target.cw_linearization_time = sim->time;
chaser->rendezvous_target.state = RENDEZVOUS_APPROACHING;
if (distance <= target->approach_distance && validity.overall_valid) {
target->cw_linearization_time = current_time;
target->state = RENDEZVOUS_APPROACHING;
}
break;
case RENDEZVOUS_APPROACHING:
// Transition to MATCHING when relative velocity is low
if (rel_vel_mag < chaser->rendezvous_target.max_relative_velocity * 0.5) {
chaser->rendezvous_target.state = RENDEZVOUS_MATCHING;
if (rel_vel_mag < target->max_relative_velocity * 0.5) {
target->state = RENDEZVOUS_MATCHING;
}
// Check if we've moved away (failed approach)
else if (distance > chaser->rendezvous_target.approach_distance * 1.5) {
chaser->rendezvous_target.state = RENDEZVOUS_FAILED;
else if (distance > target->approach_distance * 1.5) {
target->state = RENDEZVOUS_FAILED;
}
// Update CW linearization time periodically
else if (sim->time - chaser->rendezvous_target.cw_linearization_time > 100.0) {
chaser->rendezvous_target.cw_linearization_time = sim->time;
else if (current_time - target->cw_linearization_time > 100.0) {
target->cw_linearization_time = current_time;
}
break;
case RENDEZVOUS_MATCHING:
// Transition to COMPLETE when within capture distance
if (distance <= chaser->rendezvous_target.capture_distance && rel_vel_mag < chaser->rendezvous_target.max_relative_velocity) {
chaser->rendezvous_target.state = RENDEZVOUS_COMPLETE;
if (distance <= target->capture_distance && rel_vel_mag < target->max_relative_velocity) {
target->state = RENDEZVOUS_COMPLETE;
}
// Check if CW validity is lost
else if (!validity.overall_valid) {
chaser->rendezvous_target.state = RENDEZVOUS_FAILED;
target->state = RENDEZVOUS_FAILED;
}
break;
@ -422,18 +392,13 @@ void update_rendezvous_state(
void apply_cw_guidance_burn(
Spacecraft* chaser,
CWGuidanceSolution* solution,
SimulationState* sim
CelestialBody* parent,
double current_time
) {
if (!solution->valid) {
return;
}
// Get parent body
if (chaser->parent_index < 0 || chaser->parent_index >= sim->body_count) {
return;
}
CelestialBody* parent = &sim->bodies[chaser->parent_index];
// Compute LVLH basis
Vec3 r_hat, v_hat, h_hat;
cartesian_to_lvlh_basis(chaser->local_position, chaser->local_velocity,

41
src/rendezvous.h

@ -1,8 +1,9 @@
#ifndef RENDEZVOUS_H
#define RENDEZVOUS_H
#include "simulation.h"
#include "spacecraft.h"
#include "physics.h"
#include "orbital_mechanics.h"
#include "orbital_objects.h"
/**
* Rendezvous Module
@ -132,14 +133,14 @@ void lvlh_to_cartesian(
* @param chaser Chaser spacecraft
* @param target Target (body or spacecraft)
* @param parent Central body
* @param sim Simulation state
* @param current_time Current simulation time
* @return CWValidityResult with validity flags and error estimates
*/
CWValidityResult check_cw_validity(
Spacecraft* chaser,
void* target, // Can be Spacecraft* or CelestialBody*
CelestialBody* parent,
SimulationState* sim
double current_time
);
/**
@ -172,6 +173,7 @@ double compute_mean_motion(
* @param target Target
* @param parent Central body
* @param time_to_intercept Desired time to intercept
* @param current_time Current simulation time
* @return CWGuidanceSolution with required delta-v
*/
CWGuidanceSolution solve_cw_guidance(
@ -179,7 +181,7 @@ CWGuidanceSolution solve_cw_guidance(
void* target,
CelestialBody* parent,
double time_to_intercept,
SimulationState* sim
double current_time
);
/**
@ -221,20 +223,6 @@ void initialize_rendezvous_target(
double max_relative_velocity
);
/**
* Get target object (spacecraft or body) from index
*
* @param sim Simulation state
* @param target_index Index of target
* @param is_spacecraft_target Output: whether target is spacecraft
* @return Pointer to target (Spacecraft* or CelestialBody*)
*/
void* get_rendezvous_target(
SimulationState* sim,
int target_index,
bool* is_spacecraft_target
);
/**
* Update rendezvous state machine based on current relative state
*
@ -246,11 +234,16 @@ void* get_rendezvous_target(
*
* @param chaser Chaser spacecraft
* @param target Rendezvous target
* @param sim Simulation state
* @param parent Central body
* @param current_time Current simulation time
* @param target_obj Target object (Spacecraft* or CelestialBody*)
*/
void update_rendezvous_state(
Spacecraft* chaser,
SimulationState* sim
RendezvousTarget* target,
CelestialBody* parent,
double current_time,
void* target_obj // Can be Spacecraft* or CelestialBody*
);
// ============================================================================
@ -262,12 +255,14 @@ void update_rendezvous_state(
*
* @param chaser Chaser spacecraft
* @param solution CW guidance solution
* @param sim Simulation state
* @param parent Central body
* @param current_time Current simulation time
*/
void apply_cw_guidance_burn(
Spacecraft* chaser,
CWGuidanceSolution* solution,
SimulationState* sim
CelestialBody* parent,
double current_time
);
/**

2
src/simulation.cpp

@ -1,5 +1,5 @@
#include "simulation.h"
#include "spacecraft.h"
#include "orbital_objects.h"
#include "maneuver.h"
#include "orbital_mechanics.h"
#include <cassert>

49
src/simulation.h

@ -1,56 +1,13 @@
#ifndef BODIES_H
#define BODIES_H
#include "physics.h"
#include "orbital_mechanics.h"
#include "orbital_objects.h"
#include "maneuver.h"
// Forward declarations
struct Spacecraft;
struct SimulationState;
struct Maneuver;
// Rendezvous state machine (needed by Spacecraft)
typedef enum {
RENDEZVOUS_NONE,
RENDEZVOUS_PLANNING,
RENDEZVOUS_APPROACHING,
RENDEZVOUS_MATCHING,
RENDEZVOUS_COMPLETE,
RENDEZVOUS_FAILED
} RendezvousState;
// Rendezvous target structure
typedef struct {
int target_index;
int state;
double approach_distance;
double capture_distance;
double max_relative_velocity;
double cw_linearization_time;
bool is_spacecraft_target;
} RendezvousTarget;
// Celestial body structure
struct CelestialBody {
char name[64];
double mass; // kg
double radius; // meters
int parent_index; // index of gravitational parent (-1 for root body like Sun)
float color[3]; // RGB color for rendering
// Orbital elements from config (Keplerian elements)
OrbitalElements orbit;
// Global frame (from origin)
Vec3 global_position; // meters from origin
Vec3 global_velocity; // m/s
// Local frame (relative to parent)
Vec3 local_position; // meters from parent
Vec3 local_velocity; // m/s relative to parent
double soi_radius; // sphere of influence radius (meters)
};
// Simulation state
struct SimulationState {
CelestialBody* bodies;

5
src/spacecraft.cpp

@ -1,5 +0,0 @@
#include "spacecraft.h"
#include "simulation.h"
#include <cstdio>
#include <cstring>
#include <cmath>

28
src/spacecraft.h

@ -1,28 +0,0 @@
#ifndef SPACECRAFT_H
#define SPACECRAFT_H
#include "physics.h"
#include "orbital_mechanics.h"
#include "simulation.h"
struct Spacecraft {
char name[64];
double mass;
int parent_index;
// Orbital elements from config
OrbitalElements orbit;
// Global frame (from origin)
Vec3 global_position;
Vec3 global_velocity;
// Local frame (relative to parent)
Vec3 local_position;
Vec3 local_velocity;
// Rendezvous support
RendezvousTarget rendezvous_target; // Active rendezvous target (if any)
};
#endif

2
src/ui_renderer.cpp

@ -1,5 +1,5 @@
#include "ui_renderer.h"
#include "spacecraft.h"
#include "orbital_objects.h"
#include "maneuver.h"
#include <cstdio>
#include <cstring>

2
tests/test_cartesian_to_elements_advanced.cpp

@ -2,7 +2,7 @@
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <cmath>
#include "../src/orbital_mechanics.h"
#include "../src/spacecraft.h"
#include "../src/orbital_objects.h"
#include "../src/test_utilities.h"
#include "../src/config_loader.h"
#include "../src/simulation.h"

2
tests/test_hybrid_burns.cpp

@ -3,7 +3,7 @@
#include "../src/physics.h"
#include "../src/orbital_mechanics.h"
#include "../src/simulation.h"
#include "../src/spacecraft.h"
#include "../src/orbital_objects.h"
#include "../src/maneuver.h"
#include "../src/config_loader.h"
#include "../src/test_utilities.h"

2
tests/test_hybrid_energy_conservation.cpp

@ -3,7 +3,7 @@
#include "../src/physics.h"
#include "../src/orbital_mechanics.h"
#include "../src/simulation.h"
#include "../src/spacecraft.h"
#include "../src/orbital_objects.h"
#include "../src/maneuver.h"
#include "../src/config_loader.h"
#include <cmath>

2
tests/test_maneuver_planning.cpp

@ -1,7 +1,7 @@
#include <catch2/catch_test_macros.hpp>
#include "../src/physics.h"
#include "../src/simulation.h"
#include "../src/spacecraft.h"
#include "../src/orbital_objects.h"
#include "../src/maneuver.h"
#include "../src/config_loader.h"
#include <cmath>

2
tests/test_maneuvers.cpp

@ -1,7 +1,7 @@
#include <catch2/catch_test_macros.hpp>
#include "../src/physics.h"
#include "../src/simulation.h"
#include "../src/spacecraft.h"
#include "../src/orbital_objects.h"
#include "../src/maneuver.h"
#include "../src/config_loader.h"
#include "../src/test_utilities.h"

2
tests/test_omega_debug.cpp

@ -2,7 +2,7 @@
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include "../src/physics.h"
#include "../src/simulation.h"
#include "../src/spacecraft.h"
#include "../src/orbital_objects.h"
#include "../src/maneuver.h"
#include "../src/config_loader.h"
#include "../src/orbital_mechanics.h"

2
tests/test_orbit_rendering.cpp

@ -1,7 +1,7 @@
#include <catch2/catch_test_macros.hpp>
#include "../src/physics.h"
#include "../src/simulation.h"
#include "../src/spacecraft.h"
#include "../src/orbital_objects.h"
#include "../src/config_loader.h"
#include <cmath>

2
tests/test_periapsis_burn.cpp

@ -2,7 +2,7 @@
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include "../src/physics.h"
#include "../src/simulation.h"
#include "../src/spacecraft.h"
#include "../src/orbital_objects.h"
#include "../src/maneuver.h"
#include "../src/config_loader.h"
#include "../src/orbital_mechanics.h"

36
tests/test_rendezvous.cpp

@ -3,7 +3,7 @@
#include "../src/physics.h"
#include "../src/orbital_mechanics.h"
#include "../src/simulation.h"
#include "../src/spacecraft.h"
#include "../src/orbital_objects.h"
#include "../src/rendezvous.h"
#include "../src/config_loader.h"
#include <cmath>
@ -121,7 +121,7 @@ SCENARIO("CW validity check for close spacecraft", "[rendezvous][cw][validity]")
SECTION("Valid when within 5% of orbital radius") {
// Initial separation is small (different semi-major axes)
CWValidityResult validity = check_cw_validity(chaser, target, earth, sim);
CWValidityResult validity = check_cw_validity(chaser, target, earth, sim->time);
INFO("Spatial fraction: " << validity.spatial_fraction);
INFO("n*dt: " << validity.n_dt);
@ -136,7 +136,7 @@ SCENARIO("CW validity check for close spacecraft", "[rendezvous][cw][validity]")
double old_time = sim->time - 2000.0; // 2000 seconds ago
chaser->rendezvous_target.cw_linearization_time = old_time;
CWValidityResult validity = check_cw_validity(chaser, target, earth, sim);
CWValidityResult validity = check_cw_validity(chaser, target, earth, sim->time);
INFO("Time since linearization: " << (sim->time - chaser->rendezvous_target.cw_linearization_time));
INFO("n*dt: " << validity.n_dt);
@ -180,7 +180,7 @@ SCENARIO("CW guidance calculation for rendezvous", "[rendezvous][cw][guidance]")
double orbital_period = 2.0 * M_PI * sqrt(pow(6.771e6, 3) / (G * earth->mass));
double intercept_time = orbital_period; // 1 orbit
CWGuidanceSolution solution = solve_cw_guidance(chaser, target, earth, intercept_time, sim);
CWGuidanceSolution solution = solve_cw_guidance(chaser, target, earth, intercept_time, sim->time);
INFO("Intercept time: " << intercept_time << " s");
INFO("Solution valid: " << solution.valid);
@ -197,7 +197,7 @@ SCENARIO("CW guidance calculation for rendezvous", "[rendezvous][cw][guidance]")
double orbital_period = 2.0 * M_PI * sqrt(pow(6.771e6, 3) / (G * earth->mass));
double intercept_time = orbital_period / 2.0; // Half orbit
CWGuidanceSolution solution = solve_cw_guidance(chaser, target, earth, intercept_time, sim);
CWGuidanceSolution solution = solve_cw_guidance(chaser, target, earth, intercept_time, sim->time);
INFO("Intercept time: " << intercept_time << " s");
INFO("Delta-v magnitude: " << solution.delta_v_magnitude << " m/s");
@ -268,11 +268,11 @@ SCENARIO("Rendezvous execution with CW guidance", "[rendezvous][execution]") {
// Calculate and execute CW guidance burn
double orbital_period = 2.0 * M_PI * sqrt(pow(6.771e6, 3) / (G * earth->mass));
CWGuidanceSolution solution = solve_cw_guidance(chaser, target, earth, orbital_period, sim);
CWGuidanceSolution solution = solve_cw_guidance(chaser, target, earth, orbital_period, sim->time);
INFO("Calculated delta-v: " << solution.delta_v_magnitude << " m/s");
apply_cw_guidance_burn(chaser, &solution, sim);
apply_cw_guidance_burn(chaser, &solution, earth, sim->time);
// Propagate for one orbital period
double propagation_time = orbital_period;
@ -307,8 +307,8 @@ SCENARIO("Rendezvous execution with CW guidance", "[rendezvous][execution]") {
// Execute burn to get into approach phase
double orbital_period = 2.0 * M_PI * sqrt(pow(6.771e6, 3) / (G * earth->mass));
CWGuidanceSolution solution = solve_cw_guidance(chaser, target, earth, orbital_period, sim);
apply_cw_guidance_burn(chaser, &solution, sim);
CWGuidanceSolution solution = solve_cw_guidance(chaser, target, earth, orbital_period, sim->time);
apply_cw_guidance_burn(chaser, &solution, earth, sim->time);
// Propagate for half an orbit
int num_steps = (int)(orbital_period / 2.0 / TIME_STEP);
@ -319,7 +319,7 @@ SCENARIO("Rendezvous execution with CW guidance", "[rendezvous][execution]") {
}
// Update state machine
update_rendezvous_state(chaser, sim);
update_rendezvous_state(chaser, &chaser->rendezvous_target, earth, sim->time, target);
INFO("Final rendezvous state: " << sim->spacecraft[1].rendezvous_target.state);
@ -369,8 +369,8 @@ SCENARIO("Rendezvous with different initial separations", "[rendezvous][separati
// Execute rendezvous
double orbital_period = 2.0 * M_PI * sqrt(pow(6.771e6, 3) / (G * earth->mass));
CWGuidanceSolution solution = solve_cw_guidance(chaser, target, earth, orbital_period, sim);
apply_cw_guidance_burn(chaser, &solution, sim);
CWGuidanceSolution solution = solve_cw_guidance(chaser, target, earth, orbital_period, sim->time);
apply_cw_guidance_burn(chaser, &solution, earth, sim->time);
// Propagate
int num_steps = (int)(orbital_period / TIME_STEP);
@ -406,15 +406,15 @@ SCENARIO("Rendezvous with different initial separations", "[rendezvous][separati
REQUIRE(initial_distance < 20000.0); // Should be ~10 km
// Check CW validity (should still be valid at 10 km)
CWValidityResult validity = check_cw_validity(chaser, target, earth, sim);
CWValidityResult validity = check_cw_validity(chaser, target, earth, sim->time);
INFO("Spatial fraction: " << validity.spatial_fraction);
REQUIRE(validity.overall_valid == true);
// Execute rendezvous
double orbital_period = 2.0 * M_PI * sqrt(pow(6.771e6, 3) / (G * earth->mass));
CWGuidanceSolution solution = solve_cw_guidance(chaser, target, earth, orbital_period, sim);
apply_cw_guidance_burn(chaser, &solution, sim);
CWGuidanceSolution solution = solve_cw_guidance(chaser, target, earth, orbital_period, sim->time);
apply_cw_guidance_burn(chaser, &solution, earth, sim->time);
// Propagate
int num_steps = (int)(orbital_period / TIME_STEP);
@ -454,8 +454,8 @@ SCENARIO("Rendezvous with CW linearization updates", "[rendezvous][linearization
// Execute burn
double orbital_period = 2.0 * M_PI * sqrt(pow(6.771e6, 3) / (G * earth->mass));
CWGuidanceSolution solution = solve_cw_guidance(chaser, target, earth, orbital_period, sim);
apply_cw_guidance_burn(chaser, &solution, sim);
CWGuidanceSolution solution = solve_cw_guidance(chaser, target, earth, orbital_period, sim->time);
apply_cw_guidance_burn(chaser, &solution, earth, sim->time);
// Propagate for 2 orbits with periodic linearization updates
int num_steps = (int)(2.0 * orbital_period / TIME_STEP);
@ -490,7 +490,7 @@ SCENARIO("Rendezvous with CW linearization updates", "[rendezvous][linearization
// Artificially delay linearization
chaser->rendezvous_target.cw_linearization_time = sim->time - 3000.0; // 3000 seconds ago
CWValidityResult validity = check_cw_validity(chaser, target, earth, sim);
CWValidityResult validity = check_cw_validity(chaser, target, earth, sim->time);
INFO("n*dt: " << validity.n_dt);
INFO("Overall valid: " << validity.overall_valid);

Loading…
Cancel
Save