ModelSpace
All Classes Namespaces Functions Variables Enumerations Pages
CalcRangeRangeRate.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/****************************************************
17* @brief Function to calculate range and range rate
18of a target with respect to an observer.
19****************************************************/
20
21#ifndef CALC_RANGE_RANGE_RATE_HPP
22#define CALC_RANGE_RANGE_RATE_HPP
23
24#include <cmath>
25
26#include "utils/Measurements.hpp"
27#include "core/safemath.hpp"
28
29#define RANGE_RANGERATE_TARGET_STATES 6
30#define RANGE_RANGERATE_OBSERVER_STATES 6
31#define RANGE_RANGERATE_MEASUREMENTS 2
32
33namespace clockwerk {
34
35 template <typename T>
37 public:
38 /// @brief Function to calculate rate of change in 6-element orbit position with J2, J3
39 /// @param time The reference time
40 /// @param tar_state The target reference state [x, y, z, vx, vy, vz] of spacecraft
41 /// @param obs_state The observer reference state [x, y, z, vx, vy, vz] of ground station
42 /// @param out_measurements Implicit return of [range, range rate]
43 int calculateMeasurements(T time, const std::array<T, RANGE_RANGERATE_TARGET_STATES> &tar_state, const std::array<T, RANGE_RANGERATE_OBSERVER_STATES> &obs_state,
44 std::array<T, RANGE_RANGERATE_MEASUREMENTS> &out_measurements);
45 private:
46
47 };
48
49 template <typename T>
50 int CalcRangeRangeRate<T>::calculateMeasurements(T time, const std::array<T, RANGE_RANGERATE_TARGET_STATES> &tar_state, const std::array<T, RANGE_RANGERATE_OBSERVER_STATES> &obs_state,
51 std::array<T, RANGE_RANGERATE_MEASUREMENTS> &out_measurements) {
52
53 // Calculate range
54 out_measurements[0] = std::sqrt( (tar_state[0]-obs_state[0])*(tar_state[0]-obs_state[0]) + (tar_state[1]-obs_state[1])*(tar_state[1]-obs_state[1]) + (tar_state[2]-obs_state[2])*(tar_state[2]-obs_state[2]));
55 // Calculate range rate
56 int err = clockwerk::safeDivide((tar_state[0]-obs_state[0])*(tar_state[3]-obs_state[3]) + (tar_state[1]-obs_state[1])*(tar_state[4]-obs_state[4]) + (tar_state[2]-obs_state[2])*(tar_state[5]-obs_state[5]),
57 out_measurements[0], out_measurements[1]);
58
59 return err;
60
61 };
62
63}
64
65#endif
#define RANGE_RANGERATE_MEASUREMENTS
Definition CalcRangeRangeRate.hpp:31
#define RANGE_RANGERATE_TARGET_STATES
Definition CalcRangeRangeRate.hpp:29
#define RANGE_RANGERATE_OBSERVER_STATES
Definition CalcRangeRangeRate.hpp:30
Definition CalcRangeRangeRate.hpp:36
int calculateMeasurements(T time, const std::array< T, 6 > &tar_state, const std::array< T, 6 > &obs_state, std::array< T, 2 > &out_measurements)
Function to calculate rate of change in 6-element orbit position with J2, J3.
Definition CalcRangeRangeRate.hpp:50
Definition Measurements.hpp:39