-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathECI2COE_test.m
142 lines (111 loc) · 3.61 KB
/
ECI2COE_test.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
%% ECI2COE TEST SCRIPT
%
% This is to test the ECI to Classical Orbital Elements function.
%
% Date: May 3, 2017
%
%% WORKSPACE
clc
clear
close all
% load physical constants file to enter them into the global workspace
physical_constants_GPS
% Define global variables.
global omega_e mu R_e
%% TEST 1 - ARBITRARY ORBIT
% Orbital elements.
a = R_e + 800e3; % [m]
e = 0.1;
inc = 51.0 * pi / 180; % [rad]
RAAN = 192.0 * pi / 180; % [rad]
omega = 19.0 * pi / 180; % [rad]
M = 45.0 * pi / 180; % [deg]
% Convert to ECI position and velocity.
[X_truth,V_truth] = COE2RV(a,e,inc,RAAN,omega,M);
% Get orbital elemtents.
[coe, undefined, orbit_type] = ECI2COE(X_truth,V_truth);
% coe
% Convert orbital elements back to ECI position and velcity.
[X_test,V_test] = COE2RV(coe.a,coe.e,coe.i*pi/180,...
coe.RAAN*pi/180,coe.omega*pi/180,coe.M*pi/180);
% Assess error.
position_error = norm(X_truth - X_test);
velocity_error = norm(V_truth - V_test);
disp('Test 1 - Inclined, Elliptical')
disp(['Position error = ',num2str(position_error*100), ' cm'])
disp(['Velocity error = ',num2str(velocity_error*100), ' cm/second'])
coe
orbit_type
disp(' ')
%% TEST 2 - ELLIPTICAL EQUITORIAL
% Orbital elements.
a = R_e + 800e3; % [m]
e = 0.1;
inc = 0.0 * pi / 180; % [rad]
RAAN = 270.0 * pi / 180; % [rad]
omega = 19.0 * pi / 180; % [rad]
M = 45.0 * pi / 180; % [deg]
% Convert to ECI position and velocity.
[X_truth,V_truth] = COE2RV(a,e,inc,RAAN,omega,M);
% Get orbital elemtents.
[coe, undefined, orbit_type] = ECI2COE(X_truth,V_truth);
% coe
% Convert orbital elements back to ECI position and velcity.
[X_test,V_test] = COE2RV(coe.a,coe.e,coe.i*pi/180,...
coe.RAAN*pi/180,coe.omega*pi/180,coe.M*pi/180);
% Assess error.
position_error = norm(X_truth - X_test);
velocity_error = norm(V_truth - V_test);
disp('Test 2 - Elliptical, Equitorial')
disp(['Position error = ',num2str(position_error*100), ' cm'])
disp(['Velocity error = ',num2str(velocity_error*100), ' cm/second'])
coe
orbit_type
disp(' ')
%% TEST 3 - CIRCULAR INCLINED
% Orbital elements.
a = R_e + 800e3; % [m]
e = 0.0;
inc = 2 * pi / 180; % [rad]
RAAN = 192.0 * pi / 180; % [rad]
omega = 145.0 * pi / 180; % [rad]
M = 45.0 * pi / 180; % [deg]
% Convert to ECI position and velocity.
[X_truth,V_truth] = COE2RV(a,e,inc,RAAN,omega,M);
% Get orbital elemtents.
[coe, undefined, orbit_type] = ECI2COE(X_truth,V_truth);
% Convert orbital elements back to ECI position and velcity.
[X_test,V_test] = COE2RV(coe.a,coe.e,coe.i*pi/180,...
coe.RAAN*pi/180,coe.omega*pi/180,coe.M*pi/180);
% Assess error.
position_error = norm(X_truth - X_test);
velocity_error = norm(V_truth - V_test);
disp('Test 3 - Circular Inclined')
disp(['Position error = ',num2str(position_error*100), ' cm'])
disp(['Velocity error = ',num2str(velocity_error*100), ' cm/second'])
coe
orbit_type
disp(' ')
%% TEST 4 - CIRCULAR EQUITORIAL
% Orbital elements.
a = R_e + 800e3; % [m]
e = 0;
inc = 1e-9; % [rad]
RAAN = 192.0 * pi / 180; % [rad]
omega = 19.0 * pi / 180; % [rad]
M = 45.0 * pi / 180; % [deg]
% Convert to ECI position and velocity.
[X_truth,V_truth] = COE2RV(a,e,inc,RAAN,omega,M);
% Get orbital elemtents.
[coe, undefined, orbit_type] = ECI2COE(X_truth,V_truth);
% Convert orbital elements back to ECI position and velcity.
[X_test,V_test] = COE2RV(coe.a,coe.e,coe.i*pi/180,...
coe.RAAN*pi/180,coe.omega*pi/180,coe.M*pi/180);
% Assess error.
position_error = norm(X_truth - X_test);
velocity_error = norm(V_truth - V_test);
disp('Test 4 - Circular, Equitorial')
disp(['Position error = ',num2str(position_error*100), ' cm'])
disp(['Velocity error = ',num2str(velocity_error*100), ' cm/second'])
coe
orbit_type