Skip to content

Commit

Permalink
frontend: calibrations.ts: make it ts-friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
Williangalvani committed Sep 18, 2024
1 parent f98a380 commit e862291
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions core/frontend/src/components/vehiclesetup/calibration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class Calibrator {
* @param {PreflightCalibration} type
*/
private static start(type: PreflightCalibration): void {
const getParamValue = (mapping: Partial<Record<PreflightCalibration, number>>): number => {
return mapping[type] ?? 0;
};

mavlink2rest.sendMessage({
header: {
system_id: 255,
Expand All @@ -65,38 +69,38 @@ class Calibrator {
},
message: {
type: MAVLinkType.COMMAND_LONG,
param1: {
param1: getParamValue({
[PreflightCalibration.GYROSCOPE]: 1,
[PreflightCalibration.GYROSCOPE_TEMPERATURE]: 3,
}[type] || 0,
}),
param2: type === PreflightCalibration.MAGNETOMETER ? 1 : 0,
param3: type === PreflightCalibration.PRESSURE ? 1 : 0,
param4: {
param4: getParamValue({
[PreflightCalibration.RC]: 1,
[PreflightCalibration.RC_TRIM]: 2,
}[type] || 0,
param5: {
}),
param5: getParamValue({
[PreflightCalibration.ACCELEROMETER]: 1,
[PreflightCalibration.BOARD_LEVEL]: 2,
[PreflightCalibration.ACCELEROMETER_TEMPERATURE]: 3,
[PreflightCalibration.SIMPLE_ACCELEROMETER]: 4,
}[type] || 0,
param6: {
}),
param6: getParamValue({
[PreflightCalibration.COMPASS_MOTOR_INTERFERENCE]: 1,
[PreflightCalibration.AIRPSEED]: 2,
}[type] || 0,
param7: {
}),
param7: getParamValue({
[PreflightCalibration.ESC]: 1,
[PreflightCalibration.BAROMETER_TEMPERATURE]: 3,
}[type] || 0,
}),
command: {
type: MavCmd.MAV_CMD_PREFLIGHT_CALIBRATION,
},
target_system: autopilot_data.system_id,
target_component: 1,
confirmation: 0,
},
})
});
}

/**
Expand Down

0 comments on commit e862291

Please sign in to comment.