Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 MATLAB/+Observers/ExtendedKalmanFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
% See also Observers.Observer, Observers.KalmanFilter,
% Observers.UnscentedKalmanFilter
%
% Copyright (c) 2016 United States Government as represented by the
% Copyright (c)2016 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% No copyright is claimed in the United States under Title 17, U.S.
% Code. All Other Rights Reserved.
Expand Down
2 changes: 1 addition & 1 deletion 2 MATLAB/+Observers/KalmanFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
% See also Observers.Observer, Observers.ExtendedKalmanFilter,
% Observers.UnscentedKalmanFilter
%
% Copyright (c) 2016 United States Government as represented by the
% Copyright (c)2016 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% No copyright is claimed in the United States under Title 17, U.S.
% Code. All Other Rights Reserved.
Expand Down
2 changes: 1 addition & 1 deletion 2 MATLAB/+Observers/Observer.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
% See also Observers.KalmanFilter, Observers.ExtendedKalmanFilter,
% Observers.ParticleFilter, Observers.UnscentedKalmanFilter
%
% Copyright (c) 2016 United States Government as represented by the
% Copyright (c)2016 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% No copyright is claimed in the United States under Title 17, U.S.
% Code. All Other Rights Reserved.
Expand Down
2 changes: 1 addition & 1 deletion 2 MATLAB/+Observers/ParticleFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
% getStateEstimate(PF) - Return a state estimate structure with samples
% and weights fields
%
% Copyright (c) 2016 United States Government as represented by the
% Copyright (c)2016 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% No copyright is claimed in the United States under Title 17, U.S.
% Code. All Other Rights Reserved.
Expand Down
2 changes: 1 addition & 1 deletion 2 MATLAB/+Observers/UnscentedKalmanFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
% Observers.ExtendedKalmanFilter, Observers.ParticleFilter,
% Observers.computeSigmaPoints
%
% Copyright (c) 2016 United States Government as represented by the
% Copyright (c)2016 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% No copyright is claimed in the United States under Title 17, U.S.
% Code. All Other Rights Reserved.
Expand Down
2 changes: 1 addition & 1 deletion 2 MATLAB/+Observers/computeSigmaPoints.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
% See also Observers.wmean, Observers.wcov,
% Observers.UnscentedKalmanFilter
%
% Copyright (c) 2016 United States Government as represented by the
% Copyright (c)2016 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% No copyright is claimed in the United States under Title 17, U.S.
% Code. All Other Rights Reserved.
Expand Down
2 changes: 1 addition & 1 deletion 2 MATLAB/+Observers/meanCovSampler.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
% See also Observers.KalmanFilter, Observers.ExtendedKalmanFilter,
% Observers.UnscentedKalmanFilter
%
% Copyright (c) 2016 United States Government as represented by the
% Copyright (c)2016 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% No copyright is claimed in the United States under Title 17, U.S.
% Code. All Other Rights Reserved.
Expand Down
2 changes: 1 addition & 1 deletion 2 MATLAB/+Observers/wcov.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
%
% See also Observers.wmean
%
% Copyright (c) 2016 United States Government as represented by the
% Copyright (c)2016 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% No copyright is claimed in the United States under Title 17, U.S.
% Code. All Other Rights Reserved.
Expand Down
2 changes: 1 addition & 1 deletion 2 MATLAB/+Observers/wmean.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
%
% See also Observers.wcov
%
% Copyright (c) 2016 United States Government as represented by the
% Copyright (c)2016 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% No copyright is claimed in the United States under Title 17, U.S.
% Code. All Other Rights Reserved.
Expand Down
2 changes: 1 addition & 1 deletion 2 MATLAB/+Prognosis/Predictor.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
%
% See also Prognosis.Prognoser, Model.PrognosticsModel
%
% Copyright (c) 2016 United States Government as represented by the
% Copyright (c)2016 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% No copyright is claimed in the United States under Title 17, U.S.
% Code. All Other Rights Reserved.
Expand Down
2 changes: 1 addition & 1 deletion 2 MATLAB/+Prognosis/Prognoser.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
%
% See also Model.PrognosticsModel, Observers.Observer, Prognosis.Predictor
%
% Copyright (c) 2016 United States Government as represented by the
% Copyright (c)2016 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% No copyright is claimed in the United States under Title 17, U.S.
% Code. All Other Rights Reserved.
Expand Down
2 changes: 1 addition & 1 deletion 2 MATLAB/testKalmanFilter.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function testKalmanFilter
% tesKalmanFilter Test Kalman filter class with a simple model.
%
% Copyright (c) 2016 United States Government as represented by the
% Copyright (c)2016 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% No copyright is claimed in the United States under Title 17, U.S.
% Code. All Other Rights Reserved.
Expand Down
2 changes: 1 addition & 1 deletion 2 MATLAB/testParticleFilter.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function testParticleFilter
% testParticleFilter Test particle filter algorithm on Battery model
%
% Copyright (c) 2016 United States Government as represented by the
% Copyright (c)2016 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% No copyright is claimed in the United States under Title 17, U.S.
% Code. All Other Rights Reserved.
Expand Down
2 changes: 1 addition & 1 deletion 2 MATLAB/testPredictor.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function testPredictor
% testPredictor Test Predictor class for Battery model
%
% Copyright (c) 2016 United States Government as represented by the
% Copyright (c)2016 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% No copyright is claimed in the United States under Title 17, U.S.
% Code. All Other Rights Reserved.
Expand Down
49 changes: 32 additions & 17 deletions 49 MATLAB/testPrognoser.m
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
function testPrognoser
% testPrognoser Test Prognoser class for Battery model
%
% Copyright (c) 2016 United States Government as represented by the
% Copyright (c) 2016 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% No copyright is claimed in the United States under Title 17, U.S.
% Code. All Other Rights Reserved.

% Create battery model
battery = Battery.Create;
%batt = BatteryCircuit.Create;
batt = Battery.Create;

% Set variable input profile
loads = [8; 10*60; 4; 5*60; 12; 15*60; 5; 20*60; 10; 10*60];
% Dependent on model (circuit uses current, electrochemistry uses power)
if strcmp(batt.name,'BatteryCircuit')
loads = [2.63; 100*60];
elseif strcmp(batt.name,'Battery')
loads = [8; 100*60];
else
error('Model ' + batt.name + ' not supported');
end

% Set up noise covariance matrices
Q = diag(battery.V);
R = diag(battery.N);
Q = diag(batt.V);
R = diag(batt.N);

% Create UKF
UKF = Observers.UnscentedKalmanFilter(@battery.stateEqn,@battery.outputEqn,...
Q,R,'symmetric',3-8,1);
UKF = Observers.UnscentedKalmanFilter(@batt.stateEqn,@batt.outputEqn,...
Q,R,'symmetric',3-size(batt.states,2),1);

% Create sample generator for input equation parameters
% For each of the 5 load segments, sample from a uniform distribution with
Expand All @@ -31,17 +39,18 @@
% Create Prognoser
horizon = 5000;
numSamples = 100;
prognoser = Prognosis.Prognoser('model',battery,'observer',UKF,...
prognoser = Prognosis.Prognoser('model',batt,'observer',UKF,...
'horizon',horizon,'numSamples',numSamples,...
'stateSampler',@Observers.meanCovSampler,...
'inputParameterSampler',inputParameterSampler,...
'processNoiseSampler',@battery.generateProcessNoise);
'processNoiseSampler',@batt.generateProcessNoise);

% Get initial state for battery simulation
t0 = 0;
[x0,u0,z0] = battery.getDefaultInitialization(t0,loads);
[x0,u0,z0] = batt.getDefaultInitialization(t0,loads);

% Update/initialize prognoser based on initial data
prognoser.initialize(t0,x0,u0);
prognoser.update(t0,u0,z0);

% Set up output data matrices
Expand All @@ -68,11 +77,11 @@
% Simulate battery and run prognoser
for i=2:length(T)
% Update state from T(i-1) to T(i)
x = battery.stateEqn(T(i-1),x,u,battery.generateProcessNoise(),dt);
x = batt.stateEqn(T(i-1),x,u,batt.generateProcessNoise(),dt);
% Get inputs for time T(i)
u = battery.inputEqn(T(i),loads);
u = batt.inputEqn(T(i),loads);
% Compute outputs for time T(i)
z = battery.outputEqn(T(i),x,u,battery.generateSensorNoise());
z = batt.outputEqn(T(i),x,u,batt.generateSensorNoise());

% Update step for prognoser
prognoser.update(T(i),u,z);
Expand All @@ -83,7 +92,7 @@

% Print some status
fprintf('Time: %g s\n',T(i));
battery.printOutputs(z);
batt.printOutputs(z);
fprintf(' EOD: %g s\n',mean(prognoser.predictor.predictions.thresholdTimes));

% Save some prediction data
Expand Down Expand Up @@ -115,16 +124,22 @@
legend('Measured','Estimated');

% Compute actual end of discharge time, giving the exact loading parameters
battery.inputEqnHandle = @(P,t)Battery.InputEqn(P,t,loads);
T = battery.simulateToThreshold();
if strcmp(batt.name,'BatteryCircuit')
batt.inputEqnHandle = @(P,t)BatteryCircuit.InputEqn(P,t,loads);
elseif strcmp(batt.name,'Battery')
batt.inputEqnHandle = @(P,t)Battery.InputEqn(P,t,loads);
else
error('Model ' + batt.name + ' not supported');
end
T = batt.simulateToThreshold();
trueEOD = T(end);

% Plot prediction results
figure;
plot(predictionTimes,EODMean,'o',predictionTimes,EODMin,'o',...
predictionTimes,EODMax,'o',predictionTimes,...
trueEOD*ones(size(predictionTimes)),'o');
legend('Predicted EOD Mean','Predicted EOD Max','Predicted EOD Min',...
legend('Predicted EOD Mean','Predicted EOD Min','Predicted EOD Max',...
'True EOD');
axis tight;
xlabel('Time (s)')
Expand Down
2 changes: 1 addition & 1 deletion 2 MATLAB/testUnscentedKalmanFilter.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function testUnscentedKalmanFilter
% testUnscentedKalmanFilter Test UKF algorithm on Battery model
%
% Copyright (c) 2016 United States Government as represented by the
% Copyright (c)2016 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% No copyright is claimed in the United States under Title 17, U.S.
% Code. All Other Rights Reserved.
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.