diff --git a/src/components/MiniWidgetInstantiator.vue b/src/components/MiniWidgetInstantiator.vue index 461c8e130..ba80b706c 100644 --- a/src/components/MiniWidgetInstantiator.vue +++ b/src/components/MiniWidgetInstantiator.vue @@ -2,6 +2,9 @@ + @@ -45,6 +48,7 @@ import { type MiniWidget, MiniWidgetType } from '@/types/miniWidgets' import ArmerButton from './mini-widgets/ArmerButton.vue' import BaseCommIndicator from './mini-widgets/BaseCommIndicator.vue' import BatteryIndicator from './mini-widgets/BatteryIndicator.vue' +import ChangeAltitudeCommander from './mini-widgets/ChangeAltitudeCommander.vue' import DepthIndicator from './mini-widgets/DepthIndicator.vue' import JoystickCommIndicator from './mini-widgets/JoystickCommIndicator.vue' import MiniVideoRecorder from './mini-widgets/MiniVideoRecorder.vue' diff --git a/src/components/mini-widgets/ChangeAltitudeCommander.vue b/src/components/mini-widgets/ChangeAltitudeCommander.vue new file mode 100644 index 000000000..f9ceeb8ed --- /dev/null +++ b/src/components/mini-widgets/ChangeAltitudeCommander.vue @@ -0,0 +1,18 @@ + + + diff --git a/src/components/mini-widgets/TakeoffLandCommander.vue b/src/components/mini-widgets/TakeoffLandCommander.vue index c9d7822e3..754dd1192 100644 --- a/src/components/mini-widgets/TakeoffLandCommander.vue +++ b/src/components/mini-widgets/TakeoffLandCommander.vue @@ -1,10 +1,10 @@ diff --git a/src/libs/vehicle/ardupilot/ardupilot.ts b/src/libs/vehicle/ardupilot/ardupilot.ts index fb2b340c2..046057fbc 100644 --- a/src/libs/vehicle/ardupilot/ardupilot.ts +++ b/src/libs/vehicle/ardupilot/ardupilot.ts @@ -388,6 +388,44 @@ export abstract class ArduPilotVehicle extends Vehicle.AbstractVehicle extends Vehicle.AbstractVehicle extends Vehicle.AbstractVehicle extends Vehicle.AbstractVehicle { throw new Error('Takeoff cancelled by the user') } } + /** + * Change the altitude of the vehicle. + * @returns {Promise} A Promise that resolves when the altitude is changed or rejects if the action is cancelled. + */ + async function changeAlt(): Promise { + if (!mainVehicle.value) { + throw new Error('No vehicle available to change altitude.') + } + + showAltitudeSlider.value = true + + const confirmed = await slideToConfirm('Confirm Altitude Change', 'Alt Change Cmd Confirmed') + showAltitudeSlider.value = false + + if (confirmed) { + mainVehicle.value.changeAltitude(altitude.rel - altitude_setpoint.value) + } else { + console.error('Altitude change cancelled by the user') + throw new Error('Altitude change cancelled by the user') + } + } /** * Land the vehicle. @@ -463,6 +484,7 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => { return { arm, takeoff, + changeAlt, land, disarm, goTo, diff --git a/src/types/miniWidgets.ts b/src/types/miniWidgets.ts index 746028447..ce7124f0e 100644 --- a/src/types/miniWidgets.ts +++ b/src/types/miniWidgets.ts @@ -6,6 +6,7 @@ export enum MiniWidgetType { ArmerButton = 'ArmerButton', BaseCommIndicator = 'BaseCommIndicator', BatteryIndicator = 'BatteryIndicator', + ChangeAltitudeCommander = 'ChangeAltitudeCommander', DepthIndicator = 'DepthIndicator', RelativeAltitudeIndicator = 'RelativeAltitudeIndicator', TakeoffLandCommander = 'TakeoffLandCommander',