amost fixed imu simulation
parent
2e3dcd2ab7
commit
3cae615991
|
@ -11,6 +11,8 @@ clc
|
||||||
clear all
|
clear all
|
||||||
close all
|
close all
|
||||||
|
|
||||||
|
saveResults = 0;
|
||||||
|
|
||||||
%% Configuration
|
%% Configuration
|
||||||
options.useRealData = 1; % controls whether or not to use the real data (if available) as the ground truth traj
|
options.useRealData = 1; % controls whether or not to use the real data (if available) as the ground truth traj
|
||||||
options.includeBetweenFactors = 1; % if true, BetweenFactors will be added between consecutive poses
|
options.includeBetweenFactors = 1; % if true, BetweenFactors will be added between consecutive poses
|
||||||
|
@ -106,6 +108,13 @@ plot3DPoints(gtValues);
|
||||||
plot3DTrajectory(gtValues, '-r', [], 1, Marginals(gtGraph, gtValues));
|
plot3DTrajectory(gtValues, '-r', [], 1, Marginals(gtGraph, gtValues));
|
||||||
axis equal
|
axis equal
|
||||||
|
|
||||||
|
% optimize
|
||||||
|
optimizer = GaussNewtonOptimizer(gtGraph, gtValues);
|
||||||
|
gtEstimate = optimizer.optimize();
|
||||||
|
% estimate should match gtValues if graph is correct.
|
||||||
|
fprintf('Error in ground truth graph at gtValues: %g \n', gtGraph.error(gtValues) );
|
||||||
|
fprintf('Error in ground truth graph at gtEstimate: %g \n', gtGraph.error(gtEstimate) );
|
||||||
|
|
||||||
disp('Plotted ground truth')
|
disp('Plotted ground truth')
|
||||||
|
|
||||||
%% Monte Carlo Runs
|
%% Monte Carlo Runs
|
||||||
|
@ -174,16 +183,18 @@ plot(3*ones(size(ANEES,2),1),'k--'); % Expectation(ANEES) = number of dof
|
||||||
box on
|
box on
|
||||||
set(gca,'Fontsize',16)
|
set(gca,'Fontsize',16)
|
||||||
title('NEES and ANEES');
|
title('NEES and ANEES');
|
||||||
%print('-djpeg', horzcat('runs-',testName));
|
if saveResults
|
||||||
saveas(gcf,horzcat(folderName,'runs-',testName,'.fig'),'fig');
|
saveas(gcf,horzcat(folderName,'runs-',testName,'.fig'),'fig');
|
||||||
|
end
|
||||||
|
|
||||||
%%
|
%%
|
||||||
figure(1)
|
figure(1)
|
||||||
box on
|
box on
|
||||||
set(gca,'Fontsize',16)
|
set(gca,'Fontsize',16)
|
||||||
title('Ground truth and estimates for each MC runs');
|
title('Ground truth and estimates for each MC runs');
|
||||||
%print('-djpeg', horzcat('gt-',testName));
|
if saveResults
|
||||||
saveas(gcf,horzcat(folderName,'gt-',testName,'.fig'),'fig');
|
saveas(gcf,horzcat(folderName,'gt-',testName,'.fig'),'fig');
|
||||||
|
end
|
||||||
|
|
||||||
%% Let us compute statistics on the overall NEES
|
%% Let us compute statistics on the overall NEES
|
||||||
n = 3; % position vector dimension
|
n = 3; % position vector dimension
|
||||||
|
@ -208,11 +219,11 @@ plot(r2*ones(size(ANEES,2),1),'k-.');
|
||||||
box on
|
box on
|
||||||
set(gca,'Fontsize',16)
|
set(gca,'Fontsize',16)
|
||||||
title('NEES normalized by dof VS bounds');
|
title('NEES normalized by dof VS bounds');
|
||||||
%print('-djpeg', horzcat('ANEES-',testName));
|
if saveResults
|
||||||
saveas(gcf,horzcat(folderName,'ANEES-',testName,'.fig'),'fig');
|
saveas(gcf,horzcat(folderName,'ANEES-',testName,'.fig'),'fig');
|
||||||
|
logFile = horzcat(folderName,'log-',testName);
|
||||||
logFile = horzcat(folderName,'log-',testName);
|
save(logFile)
|
||||||
%save(logFile)
|
end
|
||||||
|
|
||||||
%% NEES COMPUTATION (Bar-Shalom 2001, Section 5.4)
|
%% NEES COMPUTATION (Bar-Shalom 2001, Section 5.4)
|
||||||
% the nees for a single experiment (i) is defined as
|
% the nees for a single experiment (i) is defined as
|
||||||
|
|
|
@ -74,6 +74,9 @@ for i=0:length(measurements)
|
||||||
|
|
||||||
% Preintegrate
|
% Preintegrate
|
||||||
imuMeasurement.integrateMeasurement(imuAccel, imuGyro, measurements(i).imu(j).deltaT);
|
imuMeasurement.integrateMeasurement(imuAccel, imuGyro, measurements(i).imu(j).deltaT);
|
||||||
|
end
|
||||||
|
%imuMeasurement.print('imuMeasurement');
|
||||||
|
|
||||||
% Add Imu factor
|
% Add Imu factor
|
||||||
graph.add(ImuFactor(currentPoseKey-1, currentVelKey-1, currentPoseKey, currentVelKey, ...
|
graph.add(ImuFactor(currentPoseKey-1, currentVelKey-1, currentPoseKey, currentVelKey, ...
|
||||||
currentBiasKey-1, imuMeasurement, metadata.imu.g, metadata.imu.omegaCoriolis));
|
currentBiasKey-1, imuMeasurement, metadata.imu.g, metadata.imu.omegaCoriolis));
|
||||||
|
@ -81,7 +84,6 @@ for i=0:length(measurements)
|
||||||
graph.add(BetweenFactorConstantBias(currentBiasKey-1, currentBiasKey, metadata.imu.zeroBias, ...
|
graph.add(BetweenFactorConstantBias(currentBiasKey-1, currentBiasKey, metadata.imu.zeroBias, ...
|
||||||
noiseModel.Isotropic.Sigma(6, metadata.imu.epsBias)));
|
noiseModel.Isotropic.Sigma(6, metadata.imu.epsBias)));
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
if options.imuFactorType == 2
|
if options.imuFactorType == 2
|
||||||
|
|
|
@ -64,11 +64,12 @@ if options.useRealData == 1
|
||||||
% gyro rate: Logmap(R_i' * R_i+1) / deltaT
|
% gyro rate: Logmap(R_i' * R_i+1) / deltaT
|
||||||
measurements(i).imu(j).gyro = IMUdeltaRotVector./deltaT;
|
measurements(i).imu(j).gyro = IMUdeltaRotVector./deltaT;
|
||||||
|
|
||||||
|
% deltaPij += deltaVij * deltaT + 0.5 * deltaRij.matrix() * biasHat.correctAccelerometer(measuredAcc) * deltaT*deltaT;
|
||||||
% acc = (deltaPosition - initialVel * dT) * (2/dt^2)
|
% acc = (deltaPosition - initialVel * dT) * (2/dt^2)
|
||||||
measurements(i).imu(j).accel = (IMUdeltaPositionVector - currentVel.*deltaT).*(2/(deltaT*deltaT));
|
measurements(i).imu(j).accel = (IMUdeltaPositionVector - currentVel.*deltaT).*(2/(deltaT*deltaT));
|
||||||
|
|
||||||
% Update velocity
|
% Update velocity
|
||||||
currentVel = IMUdeltaPositionVector./deltaT;
|
currentVel = currentVel + measurements(i).imu(j).accel * deltaT;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ dZ = gtECEF(3) - initialPositionECEF(3);
|
||||||
[xlt, ylt, zlt] = imuSimulator.ct2ENU(dX, dY, dZ,Org_lat, Org_lon);
|
[xlt, ylt, zlt] = imuSimulator.ct2ENU(dX, dY, dZ,Org_lat, Org_lon);
|
||||||
|
|
||||||
gtPosition = [xlt, ylt, zlt]';
|
gtPosition = [xlt, ylt, zlt]';
|
||||||
gtRotation = Rot3; %Rot3.ypr(gtScenario.Heading(scenarioInd), gtScenario.Pitch(scenarioInd), gtScenario.Roll(scenarioInd));
|
gtRotation = Rot3; %Rot3.Expmap(rand(3,1)); %Rot3.ypr(gtScenario.Heading(scenarioInd), gtScenario.Pitch(scenarioInd), gtScenario.Roll(scenarioInd));
|
||||||
currentPose = Pose3(gtRotation, Point3(gtPosition));
|
currentPose = Pose3(gtRotation, Point3(gtPosition));
|
||||||
|
|
||||||
end
|
end
|
Loading…
Reference in New Issue