Skip to content

Commit

Permalink
Merge pull request #3 from IQTLabs/rl/fix-docker-compose-env-template
Browse files Browse the repository at this point in the history
Add capture directory
  • Loading branch information
mchadwick-iqt authored Apr 19, 2023
2 parents e19002f + c23c1c5 commit 712cea1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
10 changes: 5 additions & 5 deletions axis-ptz-controller/axis_ptz_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions axis-ptz-controller/axis_ptz_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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]:
Expand Down Expand Up @@ -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}")

Expand Down
12 changes: 8 additions & 4 deletions axis-ptz-controller/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down
1 change: 1 addition & 0 deletions template.axis-ptz-controller.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 712cea1

Please sign in to comment.