Skip to content

Commit fe2d2c3

Browse files
committed
added goto in mainVehicle
1 parent 84f9d69 commit fe2d2c3

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/stores/mainVehicle.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import type {
3535
VehicleConfigurationSettings,
3636
Velocity,
3737
} from '@/libs/vehicle/types'
38+
import { Coordinates } from '@/libs/vehicle/types'
3839
import * as Vehicle from '@/libs/vehicle/vehicle'
3940
import { VehicleFactory } from '@/libs/vehicle/vehicle-factory'
4041
import { type MetadataFile } from '@/types/ardupilot-metadata'
@@ -153,6 +154,33 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => {
153154
function disarm(): void {
154155
mainVehicle.value?.disarm()
155156
}
157+
/**
158+
* Go to a given position
159+
* @param { number } hold Time to hold position in seconds
160+
* @param { number } acceptanceRadius Radius in meters to consider the waypoint reached
161+
* @param { number } passRadius Radius in meters to pass the waypoint
162+
* @param { number } yaw Yaw angle in degrees
163+
* @param { number } latitude Latitude in degrees
164+
* @param { number } longitude Longitude in degrees
165+
* @param { number } alt Altitude in meters
166+
*/
167+
function goTo(
168+
hold: number,
169+
acceptanceRadius: number,
170+
passRadius: number,
171+
yaw: number,
172+
latitude: number,
173+
longitude: number,
174+
alt: number
175+
): void {
176+
const waypoint = new Coordinates()
177+
waypoint.latitude = latitude
178+
waypoint.altitude = alt
179+
waypoint.longitude = longitude
180+
181+
mainVehicle.value?.goTo(hold, acceptanceRadius, passRadius, yaw, waypoint)
182+
}
183+
156184

157185
/**
158186
* Configure the vehicle somehow
@@ -455,6 +483,7 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => {
455483
return {
456484
arm,
457485
disarm,
486+
goTo,
458487
modesAvailable,
459488
setFlightMode,
460489
sendGcsHeartbeat,

0 commit comments

Comments
 (0)