diff --git a/axis-ptz-controller/axis_ptz_controller.py b/axis-ptz-controller/axis_ptz_controller.py index 182c5b2..308dcdc 100644 --- a/axis-ptz-controller/axis_ptz_controller.py +++ b/axis-ptz-controller/axis_ptz_controller.py @@ -203,9 +203,9 @@ def __init__( self.gamma = 0.0 # [deg] # Tripod yaw, pitch, and roll rotation quaternions - self.q_alpha = np.quaternion() # type: ignore - self.q_beta = np.quaternion() # type: ignore - self.q_gamma = np.quaternion() # type: ignore + self.q_alpha = quaternion.quaternion() + self.q_beta = quaternion.quaternion() + self.q_gamma = quaternion.quaternion() # Orthogonal transformation matrix from geocentric (XYZ) to # camera housing fixed (uvw) coordinates @@ -228,8 +228,8 @@ def __init__( self.tau_a = 0.0 # [deg] # Pan, and tilt rotation quaternions - self.q_row = np.quaternion() # type: ignore - self.q_tau = np.quaternion() # type: ignore + self.q_row = quaternion.quaternion() + self.q_tau = quaternion.quaternion() # Orthogonal transformation matrix from camera housing (uvw) # to camera fixed (rst) coordinates diff --git a/axis-ptz-controller/axis_ptz_utilities.py b/axis-ptz-controller/axis_ptz_utilities.py index d6a2e45..63a6853 100644 --- a/axis-ptz-controller/axis_ptz_utilities.py +++ b/axis-ptz-controller/axis_ptz_utilities.py @@ -3,7 +3,7 @@ import logging import math import os -from typing import Generator, Tuple, Union +from typing import cast, Generator, Tuple, Union import numpy as np import numpy.typing as npt @@ -162,14 +162,14 @@ def compute_r_XYZ( ] ) elif type(d_lambda) == np.ndarray: - r_lambda = np.radians(d_lambda) # type: ignore - r_varphi = np.radians(d_varphi) # type: ignore - N = R_OPLUS / np.sqrt(1.0 - f * (2.0 - f) * np.sin(r_varphi) ** 2) + r_lambda_np = np.radians(d_lambda) + r_varphi_np = np.radians(d_varphi) + N = R_OPLUS / np.sqrt(1.0 - f * (2.0 - f) * np.sin(r_varphi_np) ** 2) r_XYZ = np.row_stack( ( - (N + o_h) * np.cos(r_varphi) * np.cos(r_lambda), - (N + o_h) * np.cos(r_varphi) * np.sin(r_lambda), - ((1.0 - f) ** 2 * N + o_h) * np.sin(r_varphi), + (N + o_h) * np.cos(r_varphi_np) * np.cos(r_lambda_np), + (N + o_h) * np.cos(r_varphi_np) * np.sin(r_lambda_np), + ((1.0 - f) ** 2 * N + o_h) * np.sin(r_varphi_np), ), ) return r_XYZ @@ -190,7 +190,7 @@ def as_quaternion(s: float, v: npt.NDArray[np.float64]) -> quaternion.quaternion quaternion.quaternion A quaternion with the specified scalar and vector parts """ - return np.quaternion(s, v[0], v[1], v[2]) # type: ignore + return quaternion.quaternion(s, v[0], v[1], v[2]) def as_rotation_quaternion( @@ -213,7 +213,7 @@ def as_rotation_quaternion( """ r_omega = math.radians(d_omega) v = math.sin(r_omega / 2.0) * u - return np.quaternion(math.cos(r_omega / 2.0), v[0], v[1], v[2]) # type: ignore + return quaternion.quaternion(math.cos(r_omega / 2.0), v[0], v[1], v[2]) def as_vector(q: quaternion.quaternion) -> npt.NDArray[np.float64]: @@ -504,7 +504,7 @@ def convert_time(time_a: Union[str, float]) -> datetime: # Construct datetime from aircraft time try: - datetime_a = datetime.fromtimestamp(time_a) # type: ignore + datetime_a = datetime.fromtimestamp(cast(float, time_a)) except Exception as e: logger.warning(f"Could not construct datetime from aircraft time: {e}") diff --git a/axis-ptz-controller/test_modules.py b/axis-ptz-controller/test_modules.py index 92bf6cb..9ad010f 100644 --- a/axis-ptz-controller/test_modules.py +++ b/axis-ptz-controller/test_modules.py @@ -359,7 +359,7 @@ def test_compute_r_XYZ( @pytest.mark.parametrize( "s, v, q_exp", [ - (0.0, np.array([1.0, 2.0, 3.0]), np.quaternion(0.0, 1.0, 2.0, 3.0)), # type: ignore + (0.0, np.array([1.0, 2.0, 3.0]), quaternion.quaternion(0.0, 1.0, 2.0, 3.0)), ], ) def test_as_quaternion( @@ -372,8 +372,12 @@ def test_as_quaternion( @pytest.mark.parametrize( "s, v, r_exp", [ - (0.0, np.array([1.0, 2.0, 3.0]), np.quaternion(1.0, 0.0, 0.0, 0.0)), # type: ignore - (180.0, np.array([1.0, 2.0, 3.0]), np.quaternion(0.0, 1.0, 2.0, 3.0)), # type: ignore + (0.0, np.array([1.0, 2.0, 3.0]), quaternion.quaternion(1.0, 0.0, 0.0, 0.0)), + ( + 180.0, + np.array([1.0, 2.0, 3.0]), + quaternion.quaternion(0.0, 1.0, 2.0, 3.0), + ), ], ) def test_as_rotation_quaternion( @@ -386,7 +390,7 @@ def test_as_rotation_quaternion( @pytest.mark.parametrize( "q, v_exp", [ - (np.quaternion(0.0, 1.0, 2.0, 3.0), np.array([1.0, 2.0, 3.0])), # type: ignore + (quaternion.quaternion(0.0, 1.0, 2.0, 3.0), np.array([1.0, 2.0, 3.0])), ], ) def test_as_vector( diff --git a/template.axis-ptz-controller.env b/template.axis-ptz-controller.env index 9ea5b86..2a04a1a 100644 --- a/template.axis-ptz-controller.env +++ b/template.axis-ptz-controller.env @@ -13,6 +13,7 @@ TRIPOD_LONGITUDE={{TRIPOD_LONGITUDE}} TRIPOD_ALTITUDE={{TRIPOD_ALTITUDE}} UPDATE_INTERVAL=0.1 CAPTURE_INTERVAL=2.0 +CAPTURE_DIR=/data/tosort LEAD_TIME=0.25 PAN_GAIN=0.2 PAN_RATE_MIN=1.8