diff --git a/src/stores/mainVehicle.ts b/src/stores/mainVehicle.ts index 77061f8b7..575d28f69 100644 --- a/src/stores/mainVehicle.ts +++ b/src/stores/mainVehicle.ts @@ -1,4 +1,5 @@ import { useStorage, useTimestamp } from '@vueuse/core' +import { differenceInSeconds } from 'date-fns' import { defineStore } from 'pinia' import { computed, onBeforeUnmount, reactive, ref, watch } from 'vue' @@ -452,6 +453,24 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => { setInterval(() => updateMavlinkButtonsPrettyNames(), 1000) + // Generate datalog + const loggedVariables = { + 'roll': 'ATTITUDE.roll', + 'pitch': 'ATTITUDE.pitch', + 'heading': 'ATTITUDE.yaw', + 'altitude': 'AHRS2.altitude', + } + const initialTime = new Date() + // eslint-disable-next-line jsdoc/require-jsdoc + const dataLog = {} + // const dataLog: { [epoch: number]; seconds: number; data: Record } = {} + setInterval(() => { + const secondsNow = differenceInSeconds(new Date(), initialTime) + dataLog[secondsNow] = {} + Object.entries(loggedVariables).forEach((entry) => (dataLog[secondsNow][entry[0]] = genericVariables[entry[1]])) + console.log(dataLog) + }, 1000) + return { arm, disarm,