Skip to content

Commit 603180e

Browse files
committed
Views: Mission-planning: Add context menu and mission editing
Signed-off-by: Arturo Manzoli <[email protected]>
1 parent c70b359 commit 603180e

File tree

8 files changed

+2273
-1032
lines changed

8 files changed

+2273
-1032
lines changed

src/components/widgets/Map.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ const topProgressBarDisplacement = computed(() => {
592592
})
593593
</script>
594594

595-
<style>
595+
<style scoped>
596596
.page-base {
597597
min-height: 100vh;
598598
display: flex;

src/router/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
22

33
import AboutViewVue from '../views/AboutView.vue'
4-
import MissionPlanningView from '../views/MissionPlanningView.vue'
4+
import MissionPlanningView from '../views/MissionPlanning/MissionPlanningView.vue'
55
import WidgetsView from '../views/WidgetsView.vue'
66

77
const router = createRouter({

src/stores/mission.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useStorage } from '@vueuse/core'
2+
import { Path } from 'leaflet'
23
import { defineStore } from 'pinia'
34
import { reactive, ref, watch } from 'vue'
45

@@ -7,7 +8,7 @@ import { useBlueOsStorage } from '@/composables/settingsSyncer'
78
import { askForUsername } from '@/composables/usernamePrompDialog'
89
import { eventCategoriesDefaultMapping } from '@/libs/slide-to-confirm'
910
import { reloadCockpit } from '@/libs/utils'
10-
import type { Waypoint, WaypointCoordinates } from '@/types/mission'
11+
import type { Survey, Waypoint, WaypointCoordinates } from '@/types/mission'
1112

1213
import { useMainVehicleStore } from './mainVehicle'
1314

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

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

34+
const surveys = reactive<Survey[]>([])
35+
36+
const paths = reactive<Path[]>([])
37+
38+
const addSurvey = (survey: Survey): void => {
39+
surveys.push(survey)
40+
}
41+
42+
const updateSurvey = (id: string, updatedSurvey: Partial<Survey>): void => {
43+
const index = surveys.findIndex((s) => s.id === id)
44+
if (index !== -1) {
45+
surveys[index] = { ...surveys[index], ...updatedSurvey }
46+
}
47+
}
48+
49+
const removeSurvey = (id: string): void => {
50+
const index = surveys.findIndex((s) => s.id === id)
51+
if (index !== -1) {
52+
surveys.splice(index, 1)
53+
}
54+
}
55+
3356
const moveWaypoint = (id: string, newCoordinates: WaypointCoordinates): void => {
3457
const waypoint = currentPlanningWaypoints.find((w) => w.id === id)
3558
if (waypoint === undefined) {
@@ -89,6 +112,14 @@ export const useMissionStore = defineStore('mission', () => {
89112
{ immediate: true }
90113
)
91114

115+
const clearWaypoints = (): void => {
116+
currentPlanningWaypoints.splice(0)
117+
}
118+
119+
const clearPaths = (): void => {
120+
paths.splice(0)
121+
}
122+
92123
return {
93124
username,
94125
lastConnectedUser,
@@ -101,5 +132,11 @@ export const useMissionStore = defineStore('mission', () => {
101132
slideEventsCategoriesRequired,
102133
moveWaypoint,
103134
clearMission,
135+
surveys,
136+
addSurvey,
137+
updateSurvey,
138+
removeSurvey,
139+
clearWaypoints,
140+
clearPaths,
104141
}
105142
})

src/types/mission.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export type Waypoint = {
2121
* Unique identification for the waypoint.
2222
*/
2323
id: string
24+
2425
/**
2526
* Geographical coordinates of the waypoint in the following format: [latitude, longitude].
2627
*/
@@ -79,6 +80,77 @@ export type CockpitMission = {
7980
waypoints: Waypoint[]
8081
}
8182

83+
/**
84+
* Survey object that contains the information about the survey to be performed.
85+
*/
86+
export interface Survey {
87+
/**
88+
* Unique identification for the survey.
89+
*/
90+
id: string
91+
/**
92+
* Coordinates of the polygon that will be surveyed.
93+
*/
94+
polygonCoordinates: WaypointCoordinates[]
95+
/**
96+
* Density of the scan.
97+
*/
98+
distanceBetweenLines: number
99+
/**
100+
* Angle of the survey lines.
101+
*/
102+
surveyLinesAngle: number
103+
/**
104+
* Executable mission waypoints.
105+
*/
106+
waypoints: Waypoint[]
107+
}
108+
109+
/**
110+
* Last state of the survey.
111+
*/
112+
export interface SurveyState {
113+
/**
114+
* Coordinates of the waypoints
115+
*/
116+
polygonCoordinates: WaypointCoordinates[]
117+
/**
118+
* Waypoints of the survey.
119+
*/
120+
waypoints: Waypoint[]
121+
/**
122+
* Density of the scan.
123+
*/
124+
distanceBetweenLines: number
125+
/**
126+
* Angle of the survey lines.
127+
*/
128+
surveyLinesAngle: number
129+
}
130+
131+
export type SurveyPolygon = {
132+
/**
133+
* The coordinates of the polygon that will be surveyed.
134+
*/
135+
polygonPositions: L.LatLng[]
136+
/**
137+
* The markers that represent the polygon vertices.
138+
*/
139+
polygonMarkers: L.Marker[]
140+
/**
141+
* The markers that represent the polygon edges.
142+
*/
143+
edgeMarkers: L.Marker[]
144+
/**
145+
* Density of the scan.
146+
*/
147+
distanceBetweenLines: number
148+
/**
149+
* Angle of the survey lines.
150+
*/
151+
surveyLinesAngle: number
152+
}
153+
82154
// eslint-disable-next-line @typescript-eslint/no-explicit-any
83155
export const instanceOfCockpitMission = (maybeMission: any): maybeMission is CockpitMission => {
84156
const requiredKeys = ['version', 'settings', 'waypoints']

0 commit comments

Comments
 (0)