Skip to content

Commit 34f4c15

Browse files
committed
main-vehicle: Add goTo functionality
1 parent 091ef7f commit 34f4c15

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/stores/mainVehicle.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ import * as Protocol from '@/libs/vehicle/protocol/protocol'
2121
import type {
2222
Altitude,
2323
Attitude,
24-
Coordinates,
2524
PageDescription,
2625
PowerSupply,
2726
StatusGPS,
2827
StatusText,
2928
VehicleConfigurationSettings,
3029
Velocity,
3130
} from '@/libs/vehicle/types'
31+
import { Coordinates } from '@/libs/vehicle/types'
3232
import * as Vehicle from '@/libs/vehicle/vehicle'
3333
import { VehicleFactory } from '@/libs/vehicle/vehicle-factory'
3434
import type { MissionLoadingCallback, Waypoint } from '@/types/mission'
@@ -151,6 +151,33 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => {
151151
mainVehicle.value?.land()
152152
}
153153

154+
/**
155+
* Go to a given position
156+
* @param { number } hold Time to hold position in seconds
157+
* @param { number } acceptanceRadius Radius in meters to consider the waypoint reached
158+
* @param { number } passRadius Radius in meters to pass the waypoint
159+
* @param { number } yaw Yaw angle in degrees
160+
* @param { number } latitude Latitude in degrees
161+
* @param { number } longitude Longitude in degrees
162+
* @param { number } alt Altitude in meters
163+
*/
164+
function goTo(
165+
hold: number,
166+
acceptanceRadius: number,
167+
passRadius: number,
168+
yaw: number,
169+
latitude: number,
170+
longitude: number,
171+
alt: number
172+
): void {
173+
const waypoint = new Coordinates()
174+
waypoint.latitude = latitude
175+
waypoint.altitude = alt
176+
waypoint.longitude = longitude
177+
178+
mainVehicle.value?.goTo(hold, acceptanceRadius, passRadius, yaw, waypoint)
179+
}
180+
154181
/**
155182
* Configure the vehicle somehow
156183
* @param { VehicleConfigurationSettings } settings Configuration data
@@ -370,6 +397,7 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => {
370397
takeoff,
371398
land,
372399
disarm,
400+
goTo,
373401
modesAvailable,
374402
setFlightMode,
375403
sendGcsHeartbeat,

0 commit comments

Comments
 (0)