ModelSpace
All Classes Namespaces Functions Variables Enumerations Pages
EkfOrbitJ2J3Update.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_ORBIT_J2_J3_H
23#define GNC_NAVIGATION_EKF_EKF_ORBIT_J2_J3_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 with J2, J3
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 * It receives inertial position, velocity, and an associated covariance
42 * matrix, and propagates them forward to the provided time
43 * using an internal RK4 integrator.
44 *
45 * This EKF assumes that the provided position and velocity are inertial
46 * and that the x-y plane of the inertial frame is aligned to the x-y
47 * plane of the planet rotating frame (thus allowing the spacecraft dynamics
48 * to be calculated in an inertial frame without the need to rotate into
49 * a planet fixed frame)
50 *
51 * Author: Alex Reynolds <alex.reynolds@attx.tech>
52 */
53 class EkfOrbitJ2J3Update : public clockwerk::Task {
54 public:
55 // Model params
56 // NAME TYPE DEFAULT VALUE
58 /** This is the gravitational parameter of our parent planet. Defaults to
59 * Earth's gravitational parameter for ease of use */
60 SIGNAL(mu, double, 3.986004418e+14)
61 /** This is the J2 parameter of our parent planet. Defaults to
62 * Earth's J2 parameter for ease of use */
63 SIGNAL(J2, double, 1.082635854e-3)
64 /** This is the J3 parameter of our parent planet. Defaults to
65 * Earth's J3 parameter for ease of use */
66 SIGNAL(J3, double, -2.532435346e-6)
67 /** The reference radius for the planet. Must be set prior to calculation. */
68 SIGNAL(R, double, 6378140.0)
70
71 // Model inputs
72 // NAME TYPE DEFAULT VALUE
74 /** The input time stamp representing the currently known spacecraft state
75 * Can be configured to loopback to outputs/time_state */
76 SIGNAL(time_prev, clockwerk::Time, clockwerk::Time(0))
77 /** The input time stamp representing the end of the spacecraft state integration.
78 * Will be written to time_state */
79 SIGNAL(time_update, clockwerk::Time, clockwerk::Time(0))
80 /** The position estimate for the object before EKF time update */
82 /** The velocity estimate for the object before EKF time update */
84 /** The covariance matrix for the object before EKF time update */
87
88 // Model outputs
89 // NAME TYPE DEFAULT VALUE
91 /** The time stamp associated with the post snc covariance matrix */
92 SIGNAL(time_state, clockwerk::Time, clockwerk::Time(0))
93 /** The position estimate for the object after EKF time update */
95 /** The velocity estimate for the object after EKF time update */
97 /** The covariance matrix for the object after EKF time update */
99 /** The state transition matrix for the propagation from t_prev to t_update */
102
103 // Model-specific implementations of startup and derivative
104 EkfOrbitJ2J3Update();
105 EkfOrbitJ2J3Update(clockwerk::Task &pnt, int schedule_slot=0, const std::string &m_name="ekf_j2_j3_update");
106 EkfOrbitJ2J3Update(clockwerk::Executive &e, int schedule_slot=0, const std::string &m_name="ekf_j2_j3_update");
107 virtual ~EkfOrbitJ2J3Update() {}
108 protected:
109 int start();
110 int execute();
111
112 // Kalman filtering variables
113 CalcXdotPhiDotGravityJ2J3<double> _dynamics;
114 RK4Integrator<double, 42> _integrator;
115 EkfTimeUpdate<double, 6> _ekf_time_update;
116
117 // I/O to EKF
118 std::array<double, 6> _state_input;
119 std::array<double, 6> _state_output;
120 };
121
122}
123
124#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 with J2, J3.
Definition EkfOrbitJ2J3Update.h:53
int execute()
Function to execute the task. All math and calculations should be here.
Definition EkfOrbitJ2J3Update.cpp:49
int start()
Function to perform task startup activities (step once after creation)
Definition EkfOrbitJ2J3Update.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::CartesianVector< double, 3 > > pos_prev
Definition EkfOrbitJ2J3Update.h:81
clockwerk::DataIO< clockwerk::Time > time_prev
Definition EkfOrbitJ2J3Update.h:76
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > vel_prev
Definition EkfOrbitJ2J3Update.h:83
clockwerk::DataIO< clockwerk::Time > time_update
Definition EkfOrbitJ2J3Update.h:79
clockwerk::DataIO< clockwerk::Matrix< double, 6, 6 > > cov_prev
Definition EkfOrbitJ2J3Update.h:85
clockwerk::DataIO< clockwerk::Matrix< double, 6, 6 > > cov_update
Definition EkfOrbitJ2J3Update.h:98
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > pos_update
Definition EkfOrbitJ2J3Update.h:94
clockwerk::DataIO< clockwerk::Matrix< double, 6, 6 > > phi
Definition EkfOrbitJ2J3Update.h:100
clockwerk::DataIO< clockwerk::Time > time_state
Definition EkfOrbitJ2J3Update.h:92
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > vel_update
Definition EkfOrbitJ2J3Update.h:96
clockwerk::DataIO< double > J2
Definition EkfOrbitJ2J3Update.h:63
clockwerk::DataIO< double > J3
Definition EkfOrbitJ2J3Update.h:66
clockwerk::DataIO< double > mu
Definition EkfOrbitJ2J3Update.h:60
clockwerk::DataIO< double > R
Definition EkfOrbitJ2J3Update.h:68