Skip to content

Commit

Permalink
Completed code documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymond LeClair committed Jan 17, 2023
1 parent 8c22be5 commit 24c02c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
15 changes: 5 additions & 10 deletions axis-ptz/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,18 +410,15 @@ def calculateCameraPositionB(
# Assign position of the tripod
t_varphi = camera_latitude # [deg]
t_lambda = camera_longitude # [deg]
# t_h = camera_altitude # [m]

# Compute position in the XYZ coordinate system of the aircraft
# relative to the tripod at time zero, the observation time
r_XYZ_a_0 = utils.compute_r_XYZ(a_lambda, a_varphi, a_h)
# r_XYZ_t = utils.compute_r_XYZ(t_lambda, t_varphi, t_h)
r_XYZ_a_0_t = r_XYZ_a_0 - r_XYZ_t

# Compute position and velocity in the ENz coordinate system of
# the aircraft relative to the tripod at time zero, and position at
# slightly later time one
# E_XYZ_to_ENz, e_E_XYZ, e_N_XYZ, e_z_XYZ = utils.compute_E(t_lambda, t_varphi)
r_ENz_a_0_t = np.matmul(E_XYZ_to_ENz, r_XYZ_a_0 - r_XYZ_t)
a_track = math.radians(a_track)
v_ENz_a_0_t = np.array(
Expand Down Expand Up @@ -455,12 +452,6 @@ def calculateCameraPositionB(
bearing = math.degrees(math.atan2(r_ENz_a_1_t[0], r_ENz_a_1_t[1]))

# Compute pan and tilt to point the camera at the aircraft
# alpha = 0.0 # [deg]
# beta = 0.0 # [deg]
# gamma = 0.0 # [deg]
# q_alpha, q_beta, q_gamma, E_XYZ_to_uvw, _, _, _ = compute_rotations(
# e_E_XYZ, e_N_XYZ, e_z_XYZ, alpha, beta, gamma, 0.0, 0.0
# )
r_uvw_a_1_t = np.matmul(E_XYZ_to_uvw, r_XYZ_a_1_t)
rho = math.degrees(math.atan2(r_uvw_a_1_t[0], r_uvw_a_1_t[1])) # [deg]
tau = math.degrees(
Expand Down Expand Up @@ -532,10 +523,14 @@ def moveCamera(ip, username, password):
t_lambda = camera_longitude # [deg]
t_h = camera_altitude # [m]

# Compute position in the XYZ coordinate system of the tripod
# Compute orthogonal transformation matrix from geocentric to
# topocentric coordinates, and position in the XYZ coordinate
# system of the tripod
E_XYZ_to_ENz, e_E_XYZ, e_N_XYZ, e_z_XYZ = utils.compute_E(t_lambda, t_varphi)
r_XYZ_t = utils.compute_r_XYZ(t_lambda, t_varphi, t_h)

# Compute the rotations from the XYZ coordinate system to the uvw
# (camera housing fixed) coordinate system
alpha = 0.0 # [deg]
beta = 0.0 # [deg]
gamma = 0.0 # [deg]
Expand Down
8 changes: 6 additions & 2 deletions axis-ptz/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,16 @@ def test_calculateCameraPositionB(self):
E_XYZ_to_ENz, e_E_XYZ, e_N_XYZ, e_z_XYZ = utils.compute_E(t_lambda, t_varphi)
r_XYZ_t = utils.compute_r_XYZ(t_lambda, t_varphi, t_h)

# Compute the rotations from the XYZ coordinate system to the
# uvw (camera housing fixed) coordinate system
alpha = 0.0 # [deg]
beta = 0.0 # [deg]
gamma = 0.0 # [deg]
q_alpha, q_beta, q_gamma, E_XYZ_to_uvw, _, _, _ = camera.compute_rotations(
e_E_XYZ, e_N_XYZ, e_z_XYZ, alpha, beta, gamma, 0.0, 0.0
)

# Test each data value
for index in range(0, data.shape[0]):
camera.currentPlane = data.iloc[index, :].to_dict()

Expand Down Expand Up @@ -277,7 +280,7 @@ def test_compute_r_XYZ(self, o_lambda, o_varphi, o_h, r_XYZ_exp):
# Decrease precision to accommodate R_OPLUS [ft]
assert np.linalg.norm(r_XYZ_act - r_XYZ_exp) < 10000 * PRECISION

# Construct quaternions from a list or numpy.ndarray
# Construct quaternions from a numpy.ndarray
@pytest.mark.parametrize(
"s, v, q_exp",
[
Expand All @@ -288,7 +291,7 @@ def test_as_quaternion(self, s, v, q_exp):
q_act = utils.as_quaternion(s, v)
assert np.equal(q_act, q_exp).any()

# Construct rotation quaternions from a list or numpy.ndarray
# Construct rotation quaternions from numpy.ndarrays
@pytest.mark.parametrize(
"s, v, r_exp",
[
Expand Down Expand Up @@ -331,6 +334,7 @@ def test_norm(self):
assert n_exp == n_act

# Compute the great-circle distance between two points on a sphere
# separated by a quarter circumference
@pytest.mark.parametrize(
"varphi_1, lambda_1, varphi_2, lambda_2, d_exp",
[
Expand Down

0 comments on commit 24c02c2

Please sign in to comment.