Skip to content

Commit 33ff64a

Browse files
💀
1 parent f168bcb commit 33ff64a

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

vision/lib/fuel_estimator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ def rot_z(deg: float) -> np.ndarray:
6969

7070

7171
def R_field_from_cam_ypr(yaw_deg: float, pitch_deg: float, roll_deg: float) -> np.ndarray:
72-
return rot_z(yaw_deg) @ rot_y(pitch_deg) @ rot_x(roll_deg)
72+
# Use a camera-centric pitch convention where negative values tilt the
73+
# camera downward toward the floor.
74+
return rot_z(yaw_deg) @ rot_y(-pitch_deg) @ rot_x(roll_deg)
7375

7476

7577
def bbox_center_u(b: YoloBBox) -> float:
@@ -110,7 +112,7 @@ def apply_axis_conversion(ray_cv: np.ndarray, A_cam_from_cv: Optional[np.ndarray
110112
def ray_camera_to_field(pose: CameraPoseField, ray_c: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
111113
R = np.asarray(pose.R_f_c, dtype=np.float64).reshape(3, 3)
112114
p = np.asarray(pose.p_f, dtype=np.float64).reshape(3)
113-
d_f = R.T @ np.asarray(ray_c, dtype=np.float64).reshape(3)
115+
d_f = R @ np.asarray(ray_c, dtype=np.float64).reshape(3)
114116
d_f = d_f / float(np.linalg.norm(d_f))
115117
return p, d_f
116118

vision/tests/test_fuel.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def test_estimator_matches_manual_grid_with_frac(self):
231231

232232
p_f = np.array([2.0, 1.0, 0.7], dtype=np.float64)
233233
pose = CameraPoseField(
234-
R_f_c=R_field_from_cam_ypr(yaw_deg=0.0, pitch_deg=30.0, roll_deg=0.0),
234+
R_f_c=R_field_from_cam_ypr(yaw_deg=0.0, pitch_deg=-30.0, roll_deg=0.0),
235235
p_f=p_f,
236236
)
237237

@@ -271,7 +271,7 @@ def test_estimator_deterministic_same_inputs(self):
271271
A_cam_from_cv = np.array([[0.0, 0.0, 1.0], [-1.0, 0.0, 0.0], [0.0, -1.0, 0.0]], dtype=np.float64)
272272

273273
pose = CameraPoseField(
274-
R_f_c=R_field_from_cam_ypr(yaw_deg=12.0, pitch_deg=25.0, roll_deg=-3.0),
274+
R_f_c=R_field_from_cam_ypr(yaw_deg=12.0, pitch_deg=-25.0, roll_deg=-3.0),
275275
p_f=np.array([2.0, -1.0, 0.9], dtype=np.float64),
276276
)
277277

@@ -290,7 +290,7 @@ def test_estimator_invariance_to_bbox_width_same_center(self):
290290

291291
A_cam_from_cv = np.array([[0.0, 0.0, 1.0], [-1.0, 0.0, 0.0], [0.0, -1.0, 0.0]], dtype=np.float64)
292292
pose = CameraPoseField(
293-
R_f_c=R_field_from_cam_ypr(yaw_deg=10.0, pitch_deg=25.0, roll_deg=-5.0),
293+
R_f_c=R_field_from_cam_ypr(yaw_deg=10.0, pitch_deg=-25.0, roll_deg=-5.0),
294294
p_f=np.array([2.0, 1.0, 0.7], dtype=np.float64),
295295
)
296296

@@ -322,7 +322,7 @@ def test_estimator_changes_with_bbox_height_when_frac_not_zero(self):
322322

323323
A_cam_from_cv = np.array([[0.0, 0.0, 1.0], [-1.0, 0.0, 0.0], [0.0, -1.0, 0.0]], dtype=np.float64)
324324
pose = CameraPoseField(
325-
R_f_c=R_field_from_cam_ypr(yaw_deg=0.0, pitch_deg=30.0, roll_deg=0.0),
325+
R_f_c=R_field_from_cam_ypr(yaw_deg=0.0, pitch_deg=-30.0, roll_deg=0.0),
326326
p_f=np.array([2.0, 1.0, 0.7], dtype=np.float64),
327327
)
328328

@@ -348,7 +348,7 @@ def test_estimator_min_abs_dz_gate(self):
348348

349349
A_cam_from_cv = np.array([[0.0, 0.0, 1.0], [-1.0, 0.0, 0.0], [0.0, -1.0, 0.0]], dtype=np.float64)
350350
pose = CameraPoseField(
351-
R_f_c=R_field_from_cam_ypr(yaw_deg=0.0, pitch_deg=30.0, roll_deg=0.0),
351+
R_f_c=R_field_from_cam_ypr(yaw_deg=0.0, pitch_deg=-30.0, roll_deg=0.0),
352352
p_f=np.array([2.0, 1.0, 0.7], dtype=np.float64),
353353
)
354354

@@ -367,7 +367,7 @@ def test_estimator_max_range_gate(self):
367367

368368
A_cam_from_cv = np.array([[0.0, 0.0, 1.0], [-1.0, 0.0, 0.0], [0.0, -1.0, 0.0]], dtype=np.float64)
369369
pose = CameraPoseField(
370-
R_f_c=R_field_from_cam_ypr(yaw_deg=0.0, pitch_deg=30.0, roll_deg=0.0),
370+
R_f_c=R_field_from_cam_ypr(yaw_deg=0.0, pitch_deg=-30.0, roll_deg=0.0),
371371
p_f=np.array([2.0, 1.0, 0.7], dtype=np.float64),
372372
)
373373

0 commit comments

Comments
 (0)