Contents
Optical navigation demo in the solar system
Simulates optical navigation in the solar system.
%-------------------------------------------------------------------------- % See also: NavigationCameraSunStar, StarCameraViewer, % OpticalNavigationSun %-------------------------------------------------------------------------- %-------------------------------------------------------------------------- % Copyright (c) 2020 Princeton Satellite Systems, Inc. % All rights reserved. %-------------------------------------------------------------------------- % Since 2020.2 %--------------------------------------------------------------------------
Constants
aU = Constant('au'); mu = Constant('mu sun'); dayToSec = 86400; dayInYear = 365.25; secInYear = dayToSec*dayInYear;
Viewers slow the simulation down
viewersOn = true;
User inputs
[semi-najor axis, inclination, ascending node, argument of perigee, eccentricity, mean anomaly]
t = linspace(0,1e7);
el = [3*aU 0 0 0 0.8 0]; % For hyperbolic orbit e > 1 a must be negative
[r,v] = RVOrbGen(el,t,[],mu);
jD0 = Date2JD([2023 4 5]);
Julian date vector
n = length(t); jD = jD0 + t/dayToSec;
Setup the camera
d = NavigationCameraSunStar;
Set up the viewer
if( viewersOn ) hNav = StarCameraViewer('initialize','Navigation Camera',n); %#ok<*UNRCH> end
Set up Optical Navigation
dONS = OpticalNavigationSun; dONS.dT = t(2); OpticalNavigationSun( 'initialize', dONS, r(:,1), v(:,1) ); yN = NavigationCameraSunStar( r(:,1), [1;0;0;0], d ); dONS = OpticalNavigationSun( 'get unit vector', dONS, r(:,1), jD(1) ); dONS = OpticalNavigationSun( 'update', dONS, yN, r(:,1) );
Size the arrays
rE = r; vE = v; nStars = zeros(1,n);
Simulate
for k = 1:n if( k > 1 ) dONS.dT = t(k) - t(k-1); else dONS.dT = t(2); end dONS = OpticalNavigationSun( 'get unit vector', dONS, r(:,k), jD(k) ); q = U2Q(dONS.u,[0;0;1]); yN = NavigationCameraSunStar( r(:,k), q, d ); % ONS [dONS,rE(:,k),vE(:,k)] = OpticalNavigationSun( 'update', dONS, yN, r(:,k) ); nStars(k) = dONS.nStars; % Display the cameras if( viewersOn ) StarCameraViewer('update',yN,[],hNav, d,k); end end
Plot the results
% Heliocentric rECI = zeros(3,n); for k = 1:n rECI(:,k) = CEcl2Eq( jD(k) )*r(:,k); end HelioPlot(3:5,t(end)/secInYear,jD0,rECI,{'Spacecraft'}); % Position and velocity [t,tL] = TimeLabl(t); yL = {'r_x (km)' 'r_y (km)' 'r_z (km)' }; vL = {'v_x (km/s)' 'v_y (km/s)' 'v_z (km/s)' }; legX = {'True' 'Estimate'}; leg = { legX legX legX }; Plot2D(t,[r;rE],tL,yL,'Position','lin',{'[1 4]','[2 5]','[3 6]'},[],[],[],[],leg) Plot2D(t,[v;vE],tL,vL,'Velocity','lin',{'[1 4]','[2 5]','[3 6]'},[],[],[],[],leg) Figui %--------------------------------------