Skip to content

Commit

Permalink
vehicle-alerter: Remove pitch range alert
Browse files Browse the repository at this point in the history
This alert was developed to test initial alerts integration.

Right now this alert does not help much, since boats and ROVs do not have much problem with high/low pitches, and it is alerting a lot unnecessarily.

I'm removing it for now, and for the future I propose we have a generic alert configuration where the user can choose a variable and set a alert-range for it, completelly custom for his setup.
  • Loading branch information
rafaellehmkuhl committed Jul 11, 2023
1 parent 780ca1f commit e5145b9
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/stores/vehicleAlerter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { defineStore } from 'pinia'
import { ref, watch } from 'vue'
import { watch } from 'vue'

import { degrees } from '@/libs/utils'
import { useAlertStore } from '@/stores/alert'
import { useMainVehicleStore } from '@/stores/mainVehicle'
import { Alert, AlertLevel } from '@/types/alert'
Expand All @@ -10,8 +9,6 @@ export const useVehicleAlerterStore = defineStore('vehicle-alerter', () => {
const vehicleStore = useMainVehicleStore()
const alertStore = useAlertStore()

const pitchDegreeLimit = ref(30)

watch(vehicleStore.statusText, () => {
alertStore.pushAlert(new Alert(vehicleStore.statusText.severity, `Status: ${vehicleStore.statusText.text}`))
})
Expand All @@ -28,19 +25,4 @@ export const useVehicleAlerterStore = defineStore('vehicle-alerter', () => {
alertStore.pushAlert(new Alert(AlertLevel.Info, `Vehicle ${state}`))
}
)

let lastPitch = 0
watch(vehicleStore.attitude, (newAttitude) => {
if (degrees(Math.abs(newAttitude.pitch - lastPitch)) < 0.1) return
lastPitch = newAttitude.pitch

const pitchDegrees = degrees(newAttitude.pitch)
const parsedPitch = pitchDegrees.toFixed(2)
if (pitchDegrees < -pitchDegreeLimit.value) {
alertStore.pushAlert(new Alert(AlertLevel.Critical, `Pitch too low (${parsedPitch})`))
}
if (pitchDegrees > pitchDegreeLimit.value) {
alertStore.pushAlert(new Alert(AlertLevel.Critical, `Pitch too high (${parsedPitch})`))
}
})
})

0 comments on commit e5145b9

Please sign in to comment.