fix: P0+P1 audit — memory leak, hardcoded camera/GPS, lifespan init, background processing, batch validation, ABC interfaces

This commit is contained in:
Yuzviak
2026-03-22 23:35:12 +02:00
parent 8649d13a78
commit ca327034c0
9 changed files with 161 additions and 38 deletions
+13 -4
View File
@@ -155,19 +155,28 @@ async def test_ac4_user_anchor_fix(wired_processor):
flight = "ac4_anchor"
graph = wired_processor._graph
# Inject initial pose
# Inject two poses
graph._init_flight(flight)
graph._flights_state[flight]["poses"][0] = Pose(
frame_id=0, position=np.zeros(3),
orientation=np.eye(3), timestamp=datetime.now(),
)
graph._flights_state[flight]["poses"][1] = Pose(
frame_id=1, position=np.zeros(3),
orientation=np.eye(3), timestamp=datetime.now(),
)
gps = GPSPoint(lat=49.5, lon=31.0)
ok = graph.add_absolute_factor(flight, 0, gps, np.eye(2), is_user_anchor=True)
# First GPS sets origin
origin = GPSPoint(lat=49.0, lon=30.0)
graph.add_absolute_factor(flight, 0, origin, np.eye(2), is_user_anchor=True)
# Second GPS — 0.5° north
gps2 = GPSPoint(lat=49.5, lon=31.0)
ok = graph.add_absolute_factor(flight, 1, gps2, np.eye(2), is_user_anchor=True)
assert ok is True
traj = graph.get_trajectory(flight)
assert traj[0].position[1] > 50000 # ~55 km north of origin
assert traj[1].position[1] > 50000 # ~55 km north of origin
# ---------------------------------------------------------------
+13 -6
View File
@@ -50,21 +50,28 @@ def test_add_absolute_factor(optimizer):
flight_id = "test_f_2"
optimizer._init_flight(flight_id)
# Inject 0
# Inject frame 0 and frame 1
from gps_denied.schemas.graph import Pose
from datetime import datetime
optimizer._flights_state[flight_id]["poses"][0] = Pose(
frame_id=0, position=np.zeros(3), orientation=np.eye(3), timestamp=datetime.now()
)
optimizer._flights_state[flight_id]["poses"][1] = Pose(
frame_id=1, position=np.zeros(3), orientation=np.eye(3), timestamp=datetime.now()
)
gps = GPSPoint(lat=49.1, lon=30.1)
res = optimizer.add_absolute_factor(flight_id, 0, gps, np.eye(2), is_user_anchor=True)
# First GPS sets the ENU origin → position becomes [0,0,0]
origin_gps = GPSPoint(lat=49.0, lon=30.0)
optimizer.add_absolute_factor(flight_id, 0, origin_gps, np.eye(2), is_user_anchor=True)
assert np.allclose(optimizer.get_trajectory(flight_id)[0].position, [0, 0, 0])
# Second GPS at different coords → should produce non-zero ENU displacement
gps2 = GPSPoint(lat=49.1, lon=30.1)
res = optimizer.add_absolute_factor(flight_id, 1, gps2, np.eye(2), is_user_anchor=True)
assert res is True
# Verify modification
traj = optimizer.get_trajectory(flight_id)
# The x,y are roughly calcualted
assert traj[0].position[1] > 1000 # lat 49.1 > 49.0
assert traj[1].position[1] > 1000 # ~11 km north
def test_optimize_and_retrieve(optimizer):
flight_id = "test_f_3"