WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
GPSMeasurements.hpp
Go to the documentation of this file.
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
17#ifndef GNCUTILS_EKF_GPS_MEASUREMENTS_HPP
18#define GNCUTILS_EKF_GPS_MEASUREMENTS_HPP
19
21#include "dynamics/Quaternion.h"
23
24namespace warpos {
25
26 // ***** Define the number of measurement vector elements, observer vector elements, and measurement noise elements ***** //
27 // Position as defined in the state vector
29 // Here observer state acts as a parameter inputs and must include: The attitude of the frame the state is resolved in
30 // with respect to the attitude of the frame the GPS sensor reports in, provided as a unit quaternion.
32 // Every element of the measurement has an associated Gaussian noise.
34
71 template<uint32 N>
72 class GPSMeasurements : public Measurements<N, GPS_MEASUREMENT_VECTOR_ELEMENTS, GPS_MEASUREMENT_OBSERVER_VECTOR_ELEMENTS>{
73 public:
78 GPSMeasurements(uint32 state_pos_index, uint32 observer_quat_index = 0, uint32 meas_pos_index = 0) :
79 _pos_idx(state_pos_index),
80 _obs_quat_idx(observer_quat_index),
81 _meas_pos_idx(meas_pos_index) {};
82
89 int16 calculateMeasurements(floating_point time,
90 const std::array<floating_point, N> &tar_state,
91 const std::array<floating_point, GPS_MEASUREMENT_OBSERVER_VECTOR_ELEMENTS> &obs_state,
92 floating_point expected_measurement[GPS_MEASUREMENT_VECTOR_ELEMENTS]) override;
93
100 int16 calculateMeasurementsMatrix(floating_point time,
101 const std::array<floating_point, N> &tar_state,
102 const std::array<floating_point, GPS_MEASUREMENT_OBSERVER_VECTOR_ELEMENTS> &obs_state,
103 floating_point measurement_Jacobian[N*GPS_MEASUREMENT_VECTOR_ELEMENTS]) override;
104
105 private:
107 uint32 _pos_idx;
109 uint32 _obs_quat_idx;
111 uint32 _meas_pos_idx;
112 };
113
114
121 template<uint32 N>
123 const std::array<floating_point, N> &tar_state,
124 const std::array<floating_point, GPS_MEASUREMENT_OBSERVER_VECTOR_ELEMENTS> &obs_state,
125 floating_point expected_measurement[GPS_MEASUREMENT_VECTOR_ELEMENTS]) {
126 // Measurement is the same as the position part of the state
127 expected_measurement[_meas_pos_idx] = tar_state[_pos_idx];
128 expected_measurement[_meas_pos_idx+1] = tar_state[_pos_idx+1];
129 expected_measurement[_meas_pos_idx+2] = tar_state[_pos_idx+2];
130
131 return NO_ERROR;
132 }
133
140 template<uint32 N>
142 const std::array<floating_point, N> &tar_state,
143 const std::array<floating_point, GPS_MEASUREMENT_OBSERVER_VECTOR_ELEMENTS> &obs_state,
144 floating_point measurement_Jacobian[N*GPS_MEASUREMENT_VECTOR_ELEMENTS]) {
145 // Make sure quaternion index doesn't overrun the array
146 if (_pos_idx + 3 > N) {return ERROR_DIMENSIONS;}
147
148 // Make matrix of all zeros and edit the correct terms
149 for(uint32 i = 0; i < N*GPS_MEASUREMENT_VECTOR_ELEMENTS; i++) {
150 measurement_Jacobian[i] = 0.0;
151 }
152 for (uint32 i = 0; i < 3; ++i) {
153 for (uint32 j = 0; j < 3; ++j) {
154 measurement_Jacobian[i*N + j+_pos_idx] = IDENTITY_3_3.get(i, j);
155 }
156 }
157 return NO_ERROR;
158 }
159
160}
161
162#endif
int16 calculateMeasurementsMatrix(floating_point time, const std::array< floating_point, N > &tar_state, const std::array< floating_point, GPS_MEASUREMENT_OBSERVER_VECTOR_ELEMENTS > &obs_state, floating_point measurement_Jacobian[N *GPS_MEASUREMENT_VECTOR_ELEMENTS]) override
Function to calculate the measurement function Jacobian from current state of system.
Definition GPSMeasurements.hpp:141
int16 calculateMeasurements(floating_point time, const std::array< floating_point, N > &tar_state, const std::array< floating_point, GPS_MEASUREMENT_OBSERVER_VECTOR_ELEMENTS > &obs_state, floating_point expected_measurement[GPS_MEASUREMENT_VECTOR_ELEMENTS]) override
Function to calculate a measurement from current state of system.
Definition GPSMeasurements.hpp:122
GPSMeasurements(uint32 state_pos_index, uint32 observer_quat_index=0, uint32 meas_pos_index=0)
Constructor of the class.
Definition GPSMeasurements.hpp:78
Definition Measurements.hpp:41
#define NO_ERROR
Error code in the case where matrix math executed successfully.
Definition clockwerkerrors.h:34
#define ERROR_DIMENSIONS
Definition clockwerkerrors.h:41
const clockwerk::Matrix< 3, 3 > IDENTITY_3_3({ {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0} })
Definition DeadReckon.cpp:20
const uint32 GPS_MEASUREMENT_OBSERVER_VECTOR_ELEMENTS(4)
const uint32 GPS_MEASUREMENT_MEASUREMENT_NOISE_ELEMENTS(3)
const uint32 GPS_MEASUREMENT_VECTOR_ELEMENTS(3)