ModelSpace
All Classes Namespaces Functions Variables Enumerations Pages
EkfOrbitStateRelState.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/*
17Orbit EKF with state and relative state file
18
19Author: Alex Reynolds
20*/
21
22#ifndef GNC_NAVIGATION_EKF_EKF_ORBIT_STATE_REL_STATE_H
23#define GNC_NAVIGATION_EKF_EKF_ORBIT_STATE_REL_STATE_H
24
25#include "core/macros.h"
26#include "architecture/Tasks.h"
27#include "architecture/Time.h"
28#include "core/CartesianVector.hpp"
29
30#include "gnc/navigation/dynamics/CalcXdotPhiDotGravityJ2J3.hpp"
31#include "utils/RK4Integrator.hpp"
32#include "gnc/navigation/ekf/EkfTimeUpdate.hpp"
33
34namespace clockwerk {
35 /**
36 * @brief EKF Time Update step for Orbit dynamics spacecraft and relative state
37 *
38 * This function performs an EKF time update using orbit dynamics
39 * including J2 and J3 effects. It does NOT include noising models
40 * such as state noise compensation, which must be added later.
41 *
42 * It propagates forward in time a spacecraft state and spacecraft relative
43 * state in the same frame using orbit dynamics accounting for J2 and J3
44 * effects. It also propagates forward covariance. The inputs to the function
45 * include a spacecraft inertial position and velocity, as well as the
46 * associated covariance. Inputs also include a relative inertial position
47 * and velocity in the same frame, as well as covariance.
48 *
49 * This EKF assumes that the provided position and velocity are inertial
50 * and that the x-y plane of the inertial frame is aligned to the x-y
51 * plane of the planet rotating frame (thus allowing the spacecraft dynamics
52 * to be calculated in an inertial frame without the need to rotate into
53 * a planet fixed frame)
54 *
55 * Author: Alex Reynolds <alex.reynolds@attx.tech>
56 */
57 class EkfOrbitStateRelState : public clockwerk::Task {
58 public:
59 // Model params
60 // NAME TYPE DEFAULT VALUE
62 /** This is the gravitational parameter of our parent planet. Defaults to
63 * Earth's gravitational parameter for ease of use */
64 SIGNAL(mu, double, 3.986004418e+14)
65 /** This is the J2 parameter of our parent planet. Defaults to
66 * Earth's J2 parameter for ease of use */
67 SIGNAL(J2, double, 1.082635854e-3)
68 /** This is the J3 parameter of our parent planet. Defaults to
69 * Earth's J3 parameter for ease of use */
70 SIGNAL(J3, double, -2.532435346e-6)
71 /** The reference radius for the planet. Must be set prior to calculation. */
72 SIGNAL(R, double, 6378140.0)
74
75 // Model inputs
76 // NAME TYPE DEFAULT VALUE
78 /** The input time stamp representing the currently known spacecraft state
79 * Can be configured to loopback to outputs/time_state */
80 SIGNAL(time_prev, clockwerk::Time, clockwerk::Time(0))
81 /** The input time stamp representing the end of the spacecraft state integration.
82 * Will be written to time_state */
83 SIGNAL(time_update, clockwerk::Time, clockwerk::Time(0))
84 /** The inertial position estimate for the spacecraft before EKF time update */
86 /** The inertial velocity estimate for the spacecraft before EKF time update */
88 /** The covariance matrix for the object before EKF time update */
90 /** The relative position estimate in the inertial frame for the object before EKF time update */
92 /** The relative velocity estimate in the inertial frame for the object before EKF time update */
94 /** The covariance matrix for the relative state before EKF time update */
97
98 // Model outputs
99 // NAME TYPE DEFAULT VALUE
101 /** The time stamp associated with the post snc covariance matrix */
102 SIGNAL(time_state, clockwerk::Time, clockwerk::Time(0))
103 /** The inertial position estimate for the spacecraft after EKF time update */
105 /** The inertial velocity estimate for the spacecraft after EKF time update */
107 /** The covariance matrix for the object after EKF time update */
109 /** The relative position estimate in the inertial frame for the object after EKF time update */
111 /** The relative velocity estimate in the inertial frame for the object after EKF time update */
113 /** The covariance matrix for the relative state after EKF time update */
115 /** The state transition matrix for the spacecraft propagation from t_prev to t_update */
117 /** The state transition matrix for the spacecraft relative propagation from t_prev to t_update */
120
121 // Model-specific implementations of startup and derivative
122 EkfOrbitStateRelState();
123 EkfOrbitStateRelState(clockwerk::Task &pnt, int schedule_slot=0, const std::string &m_name="ekf_state_relstate_update");
124 EkfOrbitStateRelState(clockwerk::Executive &e, int schedule_slot=0, const std::string &m_name="ekf_state_relstate_update");
125 virtual ~EkfOrbitStateRelState() {}
126 protected:
127 int start();
128 int execute();
129
130 // Kalman filtering variables
131 CalcXdotPhiDotGravityJ2J3<double> _dynamics;
132 RK4Integrator<double, 42> _integrator;
133 EkfTimeUpdate<double, 6> _ekf_time_update;
134
135 // I/O to EKF
136 std::array<double, 6> _state_input;
137 std::array<double, 6> _state_output;
138 std::array<double, 6> _state_input_rel;
139 std::array<double, 6> _state_output_rel;
140 };
141
142}
143
144#endif
Definition CalcXdotPhiDotGravityJ2J3.hpp:29
DataIO(GraphTreeObject *data_parent, std::string data_name, T initial_value)
Constructor for the DataIO object.
Definition DataIO.hpp:134
EKF Time Update step for Orbit dynamics spacecraft and relative state.
Definition EkfOrbitStateRelState.h:57
int execute()
Function to execute the task. All math and calculations should be here.
Definition EkfOrbitStateRelState.cpp:49
int start()
Function to perform task startup activities (step once after creation)
Definition EkfOrbitStateRelState.cpp:36
Class to perform EKF time update step.
Definition EkfTimeUpdate.hpp:33
Central control mechanism to run simulations and software.
Definition Executive.h:43
Definition RK4Integrator.hpp:34
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
#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 START_OUTPUTS
Definition macros.h:88
#define END_INPUTS
Definition macros.h:94
#define START_INPUTS
Definition macros.h:92
clockwerk::DataIO< clockwerk::Matrix< double, 6, 6 > > cov_prev_sc__i
Definition EkfOrbitStateRelState.h:89
clockwerk::DataIO< clockwerk::Time > time_update
Definition EkfOrbitStateRelState.h:83
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > vel_prev_sc__i
Definition EkfOrbitStateRelState.h:87
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > pos_prev_sc_rel__i
Definition EkfOrbitStateRelState.h:91
clockwerk::DataIO< clockwerk::Matrix< double, 6, 6 > > cov_prev_sc_rel__i
Definition EkfOrbitStateRelState.h:95
clockwerk::DataIO< clockwerk::Time > time_prev
Definition EkfOrbitStateRelState.h:80
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > vel_prev_sc_rel__i
Definition EkfOrbitStateRelState.h:93
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > pos_prev_sc__i
Definition EkfOrbitStateRelState.h:85
clockwerk::DataIO< clockwerk::Matrix< double, 6, 6 > > phi_sc_rel__i
Definition EkfOrbitStateRelState.h:118
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > pos_update_sc__i
Definition EkfOrbitStateRelState.h:104
clockwerk::DataIO< clockwerk::Matrix< double, 6, 6 > > cov_update_sc_rel__i
Definition EkfOrbitStateRelState.h:114
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > vel_update_sc__i
Definition EkfOrbitStateRelState.h:106
clockwerk::DataIO< clockwerk::Matrix< double, 6, 6 > > cov_update_sc__i
Definition EkfOrbitStateRelState.h:108
clockwerk::DataIO< clockwerk::Matrix< double, 6, 6 > > phi_sc__i
Definition EkfOrbitStateRelState.h:116
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > pos_update_sc_rel__i
Definition EkfOrbitStateRelState.h:110
clockwerk::DataIO< clockwerk::Time > time_state
Definition EkfOrbitStateRelState.h:102
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > vel_update_sc_rel__i
Definition EkfOrbitStateRelState.h:112
clockwerk::DataIO< double > mu
Definition EkfOrbitStateRelState.h:64
clockwerk::DataIO< double > J3
Definition EkfOrbitStateRelState.h:70
clockwerk::DataIO< double > R
Definition EkfOrbitStateRelState.h:72
clockwerk::DataIO< double > J2
Definition EkfOrbitStateRelState.h:67