Complete INS/DVL/LBL Integration
Full navigation system implementation with sensor fusion.
class NavigationSystem {
constructor(config) {
this.filter = new ExtendedKalmanFilter(config);
this.imu = new IMU(config.imu);
this.dvl = new DVL(config.dvl);
this.lbl = new LBL(config.lbl);
this.state = {
position: [0, 0, 100],
velocity: [0, 0, 0],
attitude: [0, 0, 0]
};
}
update(dt) {
const gyro = this.imu.readGyro();
const accel = this.imu.readAccel();
this.filter.predict(gyro, accel, dt);
if (this.dvl.hasNewData()) {
const velocity = this.dvl.read();
if (velocity.isValid()) {
this.filter.updateDVL(velocity.data, 0.01);
}
}
if (this.lbl.hasNewFix()) {
const position = this.lbl.getPosition();
const gdop = this.lbl.getGDOP();
if (gdop < 3.0) {
this.filter.updateLBL(position, 6.25);
}
}
this.state = this.filter.getState();
return this.state;
}
}
const nav = new NavigationSystem({
imu: { rate: 100, gyroNoise: 0.001, accelNoise: 0.01 },
dvl: { rate: 5, accuracy: 0.1 },
lbl: { transponders: [[-500, -500, 0], [500, -500, 0], ...] }
});
setInterval(() => {
const state = nav.update(0.01);
console.log(`Position: ${state.position}`);
}, 10);
Mission Planning Example
Plan a survey mission with waypoints and uncertainty analysis.
function planSurveyMission(area, spacing) {
const waypoints = [];
let direction = 1;
for (let y = area.minY; y <= area.maxY; y += spacing) {
if (direction === 1) {
waypoints.push({ x: area.minX, y: y, z: 100 });
waypoints.push({ x: area.maxX, y: y, z: 100 });
} else {
waypoints.push({ x: area.maxX, y: y, z: 100 });
waypoints.push({ x: area.minX, y: y, z: 100 });
}
direction *= -1;
}
const totalDistance = computePathLength(waypoints);
const missionTime = totalDistance / 2.0;
const maxUncertainty = predictMaxError(waypoints);
return {
waypoints,
distance: totalDistance,
duration: missionTime,
maxError: maxUncertainty
};
}
const mission = planSurveyMission(
{ minX: -400, maxX: 400, minY: -300, maxY: 300 },
100
);
console.log(`Mission: ${mission.waypoints.length} waypoints`);
console.log(`Distance: ${mission.distance.toFixed(0)}m`);
console.log(`Duration: ${mission.duration.toFixed(0)}s`);
Sound Velocity Profile Correction
Apply SVP correction to acoustic range measurements.
function raytraceSVP(depth, offset, svp) {
const numSteps = 100;
let x = 0, z = 0;
let angle = Math.atan2(depth, offset);
let totalDistance = 0;
for (let i = 0; i < numSteps; i++) {
const c = getSoundSpeed(z, svp);
const dcDz = getSoundSpeedGradient(z, svp);
const ds = Math.sqrt(depth*depth + offset*offset) / numSteps;
x += ds * Math.cos(angle);
z += ds * Math.sin(angle);
angle += ds * (dcDz / c) * Math.cos(angle);
totalDistance += ds;
}
return totalDistance;
}
const svp = measureSVP();
const rawRanges = getLBLRanges();
const correctedRanges = rawRanges.map((range, i) => {
const transponder = transponders[i];
return raytraceSVP(vehicleDepth,
Math.sqrt(transponder.x**2 + transponder.y**2),
svp);
});
Data Export Example
Export navigation data in multiple formats.
function exportToCSV(navData) {
let csv = 'Time,X,Y,Z,VX,VY,VZ,Roll,Pitch,Yaw\n';
navData.forEach(d => {
csv += `${d.time},${d.pos.join(',')},${d.vel.join(',')},${d.att.join(',')}\n`;
});
return csv;
}
function exportToJSON(navData) {
return JSON.stringify({
metadata: {
mission: 'Survey Mission 2024-01-15',
vehicle: 'AUV-01',
sensors: ['IMU', 'DVL', 'LBL']
},
data: navData
}, null, 2);
}
function exportToMATLAB(navData) {
let matlab = '% Navigation Data\n';
matlab += `time = [${navData.map(d => d.time).join(', ')}];\n`;
matlab += `x = [${navData.map(d => d.pos[0]).join(', ')}];\n`;
matlab += `y = [${navData.map(d => d.pos[1]).join(', ')}];\n`;
matlab += `figure; plot(x, y); xlabel('East'); ylabel('North');\n`;
return matlab;
}
const csvData = exportToCSV(navigationLog);
downloadFile('mission.csv', csvData);