add missing log and use logger over print (#1596)

This is closer to a port of the Java/C++ stuff and will mean we get a
more standard print output with the rest of the logging in the lib
This commit is contained in:
Lucien Morey
2024-11-21 14:01:08 +11:00
committed by GitHub
parent adb18fe711
commit c536a1c312
2 changed files with 8 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
import logging
import math
from typing import Any
@@ -11,6 +12,8 @@ from .rotTrlTransform3d import RotTrlTransform3d
NWU_TO_EDN = Rotation3d(np.array([[0, -1, 0], [0, 0, -1], [1, 0, 0]]))
EDN_TO_NWU = Rotation3d(np.array([[0, 0, 1], [-1, 0, 0], [0, -1, 0]]))
logger = logging.getLogger(__name__)
class OpenCVHelp:
@staticmethod
@@ -243,7 +246,7 @@ class OpenCVHelp:
# solvePnP failed
if reprojectionError is None or math.isnan(reprojectionError[0, 0]):
print("SolvePNP_Square failed!")
logger.error("SolvePNP_Square failed!")
return None
if alt:
@@ -303,6 +306,7 @@ class OpenCVHelp:
)
if math.isnan(error):
logger.error("SolvePNP_SQPNP failed!")
return None
# We have no alternative so set it to best as well

View File

@@ -9,6 +9,8 @@ from wpimath.units import hertz, seconds
from ..estimation import RotTrlTransform3d
logger = logging.getLogger(__name__)
class SimCameraProperties:
"""Calibration and performance values for this camera.
@@ -46,7 +48,7 @@ class SimCameraProperties:
) -> None:
if fovDiag.degrees() < 1.0 or fovDiag.degrees() > 179.0:
fovDiag = Rotation2d.fromDegrees(max(min(fovDiag.degrees(), 179.0), 1.0))
logging.error("Requested invalid FOV! Clamping between (1, 179) degrees...")
logger.error("Requested invalid FOV! Clamping between (1, 179) degrees...")
resDiag = math.sqrt(width * width + height * height)
diagRatio = math.tan(fovDiag.radians() / 2.0)