mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-04-22 23:46:37 +00:00
fix: P0+P1 audit — memory leak, hardcoded camera/GPS, lifespan init, background processing, batch validation, ABC interfaces
This commit is contained in:
+13
-6
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user