ModelSpace
All Classes Namespaces Functions Variables Enumerations Pages
CalcFocalPlaneAngles.hpp
1/******************************************************************************
2* Copyright (c) ATTX LLC 2024. All Rights Reserved.
3*
4* This software and associated documentation (the "Software") are the
5* proprietary and confidential information of ATTX, LLC. The Software is
6* furnished under a license agreement between ATTX and the user organization
7* and may be used or copied only in accordance with the terms of the agreement.
8* Refer to 'license/attx_license.adoc' for standard license terms.
9*
10* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
11* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION
12* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or
13* transmitted in any form or by any means, for any purpose, without the express
14* written permission of ATTX, LLC.
15******************************************************************************/
16#ifndef GNC_NAVIGATION_MEASUREMENTS_CALC_FOCAL_PLANE_ANGLES_HPP
17#define GNC_NAVIGATION_MEASUREMENTS_CALC_FOCAL_PLANE_ANGLES_HPP
18
19#include <cmath>
20
21#include "utils/Measurements.hpp"
22#include "core/safemath.hpp"
23
24#define FOCAL_PLANE_MEAS_TARGET_STATES 6
25#define FOCAL_PLANE_MEAS_OBSERVER_STATES 3
26#define FOCAL_PLANE_MEASUREMENTS 2
27
28namespace clockwerk {
29
30 /**
31 * @brief Measurement class to calculate focal plane angles from tgt and observer state
32 *
33 * This function calculates focal plane angles as (alpha, beta) for a given target in
34 * an image frame using the known position of the imager and target. The focal plane
35 * angles are defined as follows:
36 * alpha = atan([xtgt - xobs]/[ztgt - zobs])
37 * beta = atan([ytgt - yobs]/[ztgt - zobs])
38 *
39 * Where target and observer states are differenced to generate the target state in the
40 * focal frame. The focal frame is defined as:
41 * Centered in the center of the reference image
42 * X is "up" in the image
43 * Y is "right" in the image
44 * Z is "into" the image completing the right hand frame
45 *
46 * |----------------------|
47 * | x^ |
48 * | |-->y |
49 * | |
50 * |----------------------|
51 */
52 template <typename T>
54 public:
55 /// @brief Function to focal plane angles
56 /// @param time The reference time (unused)
57 /// @param tar_state The target reference state [x, y, z, vx, vy, vz]
58 /// @param obs_state The observer reference state [x, y, z] representing camera position
59 /// @param out_measurements Implicit return of [alpha, beta]
60 int calculateMeasurements(T time, const std::array<T, FOCAL_PLANE_MEAS_TARGET_STATES> &tar_state, const std::array<T, FOCAL_PLANE_MEAS_OBSERVER_STATES> &obs_state,
61 std::array<T, FOCAL_PLANE_MEASUREMENTS> &out_measurements);
62 private:
63
64 };
65
66 template <typename T>
67 int CalcFocalPlaneAngles<T>::calculateMeasurements(T time, const std::array<T, FOCAL_PLANE_MEAS_TARGET_STATES> &tar_state, const std::array<T, FOCAL_PLANE_MEAS_OBSERVER_STATES> &obs_state,
68 std::array<T, FOCAL_PLANE_MEASUREMENTS> &out_measurements) {
69 // First, calculate our Z value and confirm is is not zero
70 T z = tar_state[2] - obs_state[2];
71 if(std::abs(z) < SAFE_MATH_ZERO_TOLERANCE) {
73 }
74
75 // Calculate alpha and beta as atan2
76 out_measurements[0] = atan2(tar_state[0] - obs_state[0], z);
77 out_measurements[1] = atan2(tar_state[1] - obs_state[1], z);
78
79 return NO_ERROR;
80 };
81
82}
83
84#endif
#define FOCAL_PLANE_MEASUREMENTS
Definition CalcFocalPlaneAngles.hpp:26
#define FOCAL_PLANE_MEAS_TARGET_STATES
Definition CalcFocalPlaneAngles.hpp:24
#define FOCAL_PLANE_MEAS_OBSERVER_STATES
Definition CalcFocalPlaneAngles.hpp:25
Measurement class to calculate focal plane angles from tgt and observer state.
Definition CalcFocalPlaneAngles.hpp:53
int calculateMeasurements(T time, const std::array< T, 6 > &tar_state, const std::array< T, 3 > &obs_state, std::array< T, 2 > &out_measurements)
Function to focal plane angles.
Definition CalcFocalPlaneAngles.hpp:67
Definition Measurements.hpp:39
#define NO_ERROR
Definition clockwerkerrors.h:31
#define ERROR_DIVIDE_BY_ZERO
Definition clockwerkerrors.h:46
#define SAFE_MATH_ZERO_TOLERANCE
Definition safemath.hpp:30