ModelSpace
All Classes Namespaces Functions Variables Enumerations Pages
EkfFocalAnglesMeasUpdate.h
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/*
17Simple PID header file
18
19Author: Alex Reynolds
20*/
21
22#ifndef GNC_NAVIGATION_EKF_EKF_FOCAL_ANGLES_MEAS_UPDATE_H
23#define GNC_NAVIGATION_EKF_EKF_FOCAL_ANGLES_MEAS_UPDATE_H
24
25#include "core/macros.h"
26#include "architecture/Tasks.h"
27#include "architecture/Time.h"
28#include "core/CartesianVector.hpp"
29#include "six_dof_dynamics/Quaternion.hpp"
30
31#include "gnc/navigation/measurements/CalcFocalPlaneAngles.hpp"
32#include "gnc/navigation/measurements/CalcFocalPlaneAnglesMatrix.hpp"
33#include "gnc/navigation/ekf/EkfMeasurementUpdate.hpp"
34
35namespace clockwerk {
36 const std::array<double, 3> ZERO_VECTOR_OBS = {0.0, 0.0, 0.0};
37
38 /**
39 * @brief EKF Measurement Update with focal plane angles
40 *
41 * This function performs an EKF measurement update using provided
42 * flocal plane (alpha/beta angles) information and an associated timestamp. The
43 * task checks if the timestamp provided differs from previous
44 * timestamps and only performs an update if the timestamp is
45 * different.
46 *
47 * This class comes with additional inputs to rotate/translate values in any frame
48 * into the focal plane frame, and updates are performed there.
49 * The focal frame is defined as:
50 * Centered in the center of the reference image
51 * X is "up" in the image
52 * Y is "right" in the image
53 * Z is "into" the image completing the right hand frame
54 *
55 * |----------------------|
56 * | x^ |
57 * | |-->y |
58 * | |
59 * |----------------------|
60 *
61 * Output data includes the updated state and covariance as well
62 * as measurement residual and covariance information.
63 *
64 * Author: Alex Reynolds <alex.reynolds@attx.tech>
65 */
66 class EkfFocalAnglesMeasUpdate : public clockwerk::Task {
67 public:
68 // Model params
69 // NAME TYPE DEFAULT VALUE
71 /** The 2D covariance matrix for the angles measurement [alpha, beta]*/
73 /** The maximum alpha angle residual beyond which measurements will not be processed */
74 SIGNAL(alpha_residual_filter, double, 1.0e10)
75 /** The beta angle residual beyond which measurements will not be processed */
76 SIGNAL(beta_residual_filter, double, 1.0e10)
78
79 // Model inputs
80 // NAME TYPE DEFAULT VALUE
82 /** The time stamp associated with the range and rangerate update */
83 SIGNAL(time_update, clockwerk::Time, clockwerk::Time())
84 /** The range measurement which will be used in state update */
85 SIGNAL(alpha, double, 0.0)
86 /** The range rate measurement which will be used in state update */
87 SIGNAL(beta, double, 0.0)
88 /** The position estimate for the object before measurement update, expressed in the input frame */
90 /** The velocity estimate for the object before measurement update, expressed in the input frame */
92 /** The covariance matrix for the object before measurement update, expressed in the input frame */
94 /** The position of the observer relative to which measurement is taken, expressed in the input frame */
96 /** The attitude of the focal frame wrt the observer frame expressed as a Quaternion */
97 SIGNAL(observer_quat_f_i, QuaternionD, QuaternionD({1.0, 0.0, 0.0, 0.0}))
99
100 // Model outputs
101 // NAME TYPE DEFAULT VALUE
103 /** Flag to indicate whether measurement was processed (true) or not (false) */
104 SIGNAL(meas_processed, int, false)
105 /** The position estimate for the object before measurement update, expressed in the input frame */
107 /** The velocity estimate for the object before measurement update, expressed in the input frame */
109 /** The covariance matrix for the object before measurement update, expressed in the input frame */
111 /** The residual in measurements as [range, range rate] prior to measurement update */
113 /** The residual in measurements as [range, range rate] after measurement update */
115 /** The covariance of measurements prior to measurement update*/
117 /** The covariance of measurements after measurement update*/
120
121 // Model-specific implementations of startup and derivative
122 EkfFocalAnglesMeasUpdate();
123 EkfFocalAnglesMeasUpdate(clockwerk::Task &pnt, int schedule_slot=0, const std::string &m_name="ekf_focal_angles");
124 EkfFocalAnglesMeasUpdate(clockwerk::Executive &e, int schedule_slot=0, const std::string &m_name="ekf_focal_angles");
125 virtual ~EkfFocalAnglesMeasUpdate() {}
126 protected:
127 int start();
128 int execute();
129
130 // Measurement EKF functions and class
131 CalcFocalPlaneAngles<double> _measurement_fun;
132 CalcFocalPlaneAnglesMatrix<double> _H_meas_fun;
135 FOCAL_PLANE_MEAS_OBSERVER_STATES> _ekf_meas_update;
136
137 // I/O to EKF
138 std::array<double, FOCAL_PLANE_MEAS_TARGET_STATES> _state_input;
139 std::array<double, FOCAL_PLANE_MEAS_TARGET_STATES> _state_output;
140 std::array<double, FOCAL_PLANE_MEASUREMENTS> _measurement;
141
142 // Measurement EKF variables
144
145 // Variables to manage frame rotation from input into focal frame
146 DCMD _dcm_f_i;
147 DCMD _dcm_i_f;
148 Matrix6D _full_state_rot_f_i;
149 Matrix6D _full_state_rot_i_f;
150 CartesianVector3D _pos__f;
151 CartesianVector3D _vel__f;
152 Matrix6D _cov_minus__f;
153 Matrix6D _cov_plus__f;
154
155 // Record of previous time
156 clockwerk::Time _prev_time;
157 };
158}
159
160#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 angle sensitivity matrix from tgt and observer state.
Definition CalcFocalPlaneAnglesMatrix.hpp:52
Measurement class to calculate focal plane angles from tgt and observer state.
Definition CalcFocalPlaneAngles.hpp:53
DataIO(GraphTreeObject *data_parent, std::string data_name, T initial_value)
Constructor for the DataIO object.
Definition DataIO.hpp:134
EKF Measurement Update with focal plane angles.
Definition EkfFocalAnglesMeasUpdate.h:66
int start()
Function to perform task startup activities (step once after creation)
Definition EkfFocalAnglesMeasUpdate.cpp:34
int execute()
Function to execute the task. All math and calculations should be here.
Definition EkfFocalAnglesMeasUpdate.cpp:42
Generic, templated EKF measurement update class.
Definition EkfMeasurementUpdate.hpp:50
Central control mechanism to run simulations and software.
Definition Executive.h:43
Matrix math implementation.
Definition Matrix.hpp:54
This is the base implementation of the task class.
Definition Tasks.h:68
Wrapper to manage and convert time as timespce.
Definition Time.h:45
Time()
Default, copy constructors and default destructor.
Definition Time.h:48
#define SIGNAL(NAME, TYPE, INITIAL_VALUE)
Definition macros.h:87
#define Matrix6D
Definition macros.h:37
#define START_PARAMS
Definition macros.h:96
#define CartesianVector3D
Definition macros.h:54
#define END_OUTPUTS
Definition macros.h:90
#define END_PARAMS
Definition macros.h:98
#define DCMD
Definition macros.h:70
#define CartesianVector2D
Definition macros.h:52
#define QuaternionD
Definition macros.h:78
#define START_OUTPUTS
Definition macros.h:88
#define END_INPUTS
Definition macros.h:94
#define Matrix2D
Definition macros.h:32
#define START_INPUTS
Definition macros.h:92
clockwerk::DataIO< clockwerk::Matrix< double, 6, 6 > > cov_minus__i
Definition EkfFocalAnglesMeasUpdate.h:93
clockwerk::DataIO< double > beta
Definition EkfFocalAnglesMeasUpdate.h:87
clockwerk::DataIO< clockwerk::Quaternion< double > > observer_quat_f_i
Definition EkfFocalAnglesMeasUpdate.h:97
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > vel_minus__i
Definition EkfFocalAnglesMeasUpdate.h:91
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > observer_pos__i
Definition EkfFocalAnglesMeasUpdate.h:95
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > pos_minus__i
Definition EkfFocalAnglesMeasUpdate.h:89
clockwerk::DataIO< double > alpha
Definition EkfFocalAnglesMeasUpdate.h:85
clockwerk::DataIO< clockwerk::Time > time_update
Definition EkfFocalAnglesMeasUpdate.h:83
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > pos_plus__i
Definition EkfFocalAnglesMeasUpdate.h:106
clockwerk::DataIO< clockwerk::Matrix< double, 6, 6 > > cov_plus__i
Definition EkfFocalAnglesMeasUpdate.h:110
clockwerk::DataIO< clockwerk::CartesianVector< double, 2 > > meas_pre_residual
Definition EkfFocalAnglesMeasUpdate.h:112
clockwerk::DataIO< clockwerk::CartesianVector< double, 2 > > meas_post_residual
Definition EkfFocalAnglesMeasUpdate.h:114
clockwerk::DataIO< clockwerk::Matrix< double, 2, 2 > > meas_post_covariance
Definition EkfFocalAnglesMeasUpdate.h:118
clockwerk::DataIO< int > meas_processed
Definition EkfFocalAnglesMeasUpdate.h:104
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > vel_plus__i
Definition EkfFocalAnglesMeasUpdate.h:108
clockwerk::DataIO< clockwerk::Matrix< double, 2, 2 > > meas_pre_covariance
Definition EkfFocalAnglesMeasUpdate.h:116
clockwerk::DataIO< clockwerk::Matrix< double, 2, 2 > > meas_covariance
Definition EkfFocalAnglesMeasUpdate.h:72
clockwerk::DataIO< double > beta_residual_filter
Definition EkfFocalAnglesMeasUpdate.h:76
clockwerk::DataIO< double > alpha_residual_filter
Definition EkfFocalAnglesMeasUpdate.h:74