Skip to content

Commit

Permalink
Views: Mission-planning: Add context menu and mission editing
Browse files Browse the repository at this point in the history
Signed-off-by: Arturo Manzoli <[email protected]>
  • Loading branch information
ArturoManzoli committed Nov 26, 2024
1 parent 60ea097 commit 8e01666
Show file tree
Hide file tree
Showing 7 changed files with 1,432 additions and 187 deletions.
2 changes: 1 addition & 1 deletion src/components/widgets/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ const topProgressBarDisplacement = computed(() => {
})
</script>

<style>
<style scoped>
.page-base {
min-height: 100vh;
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'

import AboutViewVue from '../views/AboutView.vue'
import MissionPlanningView from '../views/MissionPlanningView.vue'
import MissionPlanningView from '../views/MissionPlanning/MissionPlanningView.vue'
import WidgetsView from '../views/WidgetsView.vue'

const router = createRouter({
Expand Down
39 changes: 38 additions & 1 deletion src/stores/mission.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useStorage } from '@vueuse/core'
import { Path } from 'leaflet'
import { defineStore } from 'pinia'
import { reactive, ref, watch } from 'vue'

Expand All @@ -7,7 +8,7 @@ import { useBlueOsStorage } from '@/composables/settingsSyncer'
import { askForUsername } from '@/composables/usernamePrompDialog'
import { eventCategoriesDefaultMapping } from '@/libs/slide-to-confirm'
import { reloadCockpit } from '@/libs/utils'
import type { Waypoint, WaypointCoordinates } from '@/types/mission'
import type { Survey, Waypoint, WaypointCoordinates } from '@/types/mission'

import { useMainVehicleStore } from './mainVehicle'

Expand All @@ -30,6 +31,28 @@ export const useMissionStore = defineStore('mission', () => {

const currentPlanningWaypoints = reactive<Waypoint[]>([])

const surveys = reactive<Survey[]>([])

const paths = reactive<Path[]>([])

const addSurvey = (survey: Survey): void => {
surveys.push(survey)
}

const updateSurvey = (id: string, updatedSurvey: Partial<Survey>): void => {
const index = surveys.findIndex((s) => s.id === id)
if (index !== -1) {
surveys[index] = { ...surveys[index], ...updatedSurvey }
}
}

const removeSurvey = (id: string): void => {
const index = surveys.findIndex((s) => s.id === id)
if (index !== -1) {
surveys.splice(index, 1)
}
}

const moveWaypoint = (id: string, newCoordinates: WaypointCoordinates): void => {
const waypoint = currentPlanningWaypoints.find((w) => w.id === id)
if (waypoint === undefined) {
Expand Down Expand Up @@ -89,6 +112,14 @@ export const useMissionStore = defineStore('mission', () => {
{ immediate: true }
)

const clearWaypoints = (): void => {
currentPlanningWaypoints.splice(0)
}

const clearPaths = (): void => {
paths.splice(0)
}

return {
username,
lastConnectedUser,
Expand All @@ -101,5 +132,11 @@ export const useMissionStore = defineStore('mission', () => {
slideEventsCategoriesRequired,
moveWaypoint,
clearMission,
surveys,
addSurvey,
updateSurvey,
removeSurvey,
clearWaypoints,
clearPaths,
}
})
72 changes: 72 additions & 0 deletions src/types/mission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type Waypoint = {
* Unique identification for the waypoint.
*/
id: string

/**
* Geographical coordinates of the waypoint in the following format: [latitude, longitude].
*/
Expand Down Expand Up @@ -79,6 +80,77 @@ export type CockpitMission = {
waypoints: Waypoint[]
}

/**
* Survey object that contains the information about the survey to be performed.
*/
export interface Survey {
/**
* Unique identification for the survey.
*/
id: string
/**
* Coordinates of the polygon that will be surveyed.
*/
polygonCoordinates: WaypointCoordinates[]
/**
* Density of the scan.
*/
distanceBetweenLines: number
/**
* Angle of the survey lines.
*/
surveyLinesAngle: number
/**
* Executable mission waypoints.
*/
waypoints: Waypoint[]
}

/**
* Last state of the survey.
*/
export interface SurveyState {
/**
* Coordinates of the waypoints
*/
polygonCoordinates: WaypointCoordinates[]
/**
* Waypoints of the survey.
*/
waypoints: Waypoint[]
/**
* Density of the scan.
*/
distanceBetweenLines: number
/**
* Angle of the survey lines.
*/
surveyLinesAngle: number
}

export type SurveyPolygon = {
/**
* The coordinates of the polygon that will be surveyed.
*/
polygonPositions: L.LatLng[]
/**
* The markers that represent the polygon vertices.
*/
polygonMarkers: L.Marker[]
/**
* The markers that represent the polygon edges.
*/
edgeMarkers: L.Marker[]
/**
* Density of the scan.
*/
distanceBetweenLines: number
/**
* Angle of the survey lines.
*/
surveyLinesAngle: number
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const instanceOfCockpitMission = (maybeMission: any): maybeMission is CockpitMission => {
const requiredKeys = ['version', 'settings', 'waypoints']
Expand Down
Loading

0 comments on commit 8e01666

Please sign in to comment.