Skip to content

Commit

Permalink
main-vehicle: Add goTo functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ericjohnson97 authored and patrickelectric committed Dec 16, 2023
1 parent 8e7286d commit 1bf092b
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/stores/mainVehicle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import * as Protocol from '@/libs/vehicle/protocol/protocol'
import type {
Altitude,
Attitude,
Coordinates,
PageDescription,
PowerSupply,
StatusGPS,
StatusText,
VehicleConfigurationSettings,
Velocity,
} from '@/libs/vehicle/types'
import { Coordinates } from '@/libs/vehicle/types'
import * as Vehicle from '@/libs/vehicle/vehicle'
import { VehicleFactory } from '@/libs/vehicle/vehicle-factory'
import type { MissionLoadingCallback, Waypoint } from '@/types/mission'
Expand Down Expand Up @@ -150,6 +150,33 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => {
mainVehicle.value?.land()
}

/**
* Go to a given position
* @param { number } hold Time to hold position in seconds
* @param { number } acceptanceRadius Radius in meters to consider the waypoint reached
* @param { number } passRadius Radius in meters to pass the waypoint
* @param { number } yaw Yaw angle in degrees
* @param { number } latitude Latitude in degrees
* @param { number } longitude Longitude in degrees
* @param { number } alt Altitude in meters
*/
function goTo(
hold: number,
acceptanceRadius: number,
passRadius: number,
yaw: number,
latitude: number,
longitude: number,
alt: number
): void {
const waypoint = new Coordinates()
waypoint.latitude = latitude
waypoint.altitude = alt
waypoint.longitude = longitude

mainVehicle.value?.goTo(hold, acceptanceRadius, passRadius, yaw, waypoint)
}

/**
* Configure the vehicle somehow
* @param { VehicleConfigurationSettings } settings Configuration data
Expand Down Expand Up @@ -365,6 +392,7 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => {
takeoff,
land,
disarm,
goTo,
modesAvailable,
setFlightMode,
sendGcsHeartbeat,
Expand Down

0 comments on commit 1bf092b

Please sign in to comment.