11<template >
2- <v-card class =" ma-2 pa-2" >
3- <v-card-title class =" align-center" >
4- Load Default Parameters
5- </v-card-title >
6- <v-card-text >
7- <v-btn
8- v-for =" (paramSet, name) in filtered_param_sets"
9- :key =" name"
10- color =" primary"
11- @click =" loadParams(name, paramSet)"
12- >
13- {{ name.split('/').pop() }}
14- </v-btn >
15- <p v-if =" (Object.keys(filtered_param_sets).length === 0)" >
16- No parameters available for this setup
17- </p >
18- </v-card-text >
19- <parameterloader
20- v-if =" selected_paramset"
21- :parameters =" selected_paramset"
22- @done =" selected_paramset = {}"
23- />
24- </v-card >
2+ <v-row >
3+ <v-card class =" ma-2 pa-2" >
4+ <v-card-title class =" align-center" >
5+ Reset Parameters to Firmware Defaults
6+ </v-card-title >
7+ <v-card-text >
8+ <p >
9+ This will effectively wipe your "eeprom". You will lose all your parameters, vehicle setup, and calibrations.
10+ Use this if you don't know which parameters you changed and need a clean start.
11+ </p >
12+ <v-btn :disabled =" wipe_successful" :loading =" erasing" color =" primary" @click =" wipe" >
13+ Reset All Parameters
14+ </v-btn >
15+ <v-btn
16+ v-if =" wipe_successful && !done"
17+ color =" warning"
18+ :loading =" rebooting"
19+ @click =" restartAutopilot"
20+ >
21+ Reboot Autopilot
22+ </v-btn >
23+ <v-alert
24+ v-if =" wipe_successful"
25+ dense
26+ text
27+ type =" success"
28+ >
29+ Parameters reset <b >successful</b >. <span v-if =" !done" > Please reboot the vehicle to apply changes. </span >
30+ </v-alert >
31+ </v-card-text >
32+ <parameterloader
33+ v-if =" selected_paramset"
34+ :parameters =" selected_paramset"
35+ @done =" selected_paramset = {}"
36+ />
37+ </v-card >
38+ <v-card class =" ma-2 pa-2" >
39+ <v-card-title class =" align-center" >
40+ Load Recommended Parameter sets
41+ </v-card-title >
42+ <v-card-text >
43+ <p >
44+ These are the recommended parameter sets for your vehicle and firmware version. Curated by Blue Robotics
45+ </p >
46+ <v-btn
47+ v-for =" (paramSet, name) in filtered_param_sets"
48+ :key =" name"
49+ color =" primary"
50+ @click =" loadParams(name, paramSet)"
51+ >
52+ {{ name.split('/').pop() }}
53+ </v-btn >
54+ <p v-if =" (Object.keys(filtered_param_sets).length === 0)" >
55+ No parameters available for this setup
56+ </p >
57+ </v-card-text >
58+ <parameterloader
59+ v-if =" selected_paramset"
60+ :parameters =" selected_paramset"
61+ @done =" selected_paramset = {}"
62+ />
63+ </v-card >
64+ </v-row >
2565</template >
2666
2767<script lang="ts">
2868import { SemVer } from ' semver'
2969import Vue from ' vue'
30- import { Dictionary } from ' vue-router'
3170
71+ import * as AutopilotManager from ' @/components/autopilot/AutopilotManagerUpdater'
3272import parameterloader from ' @/components/parameter-editor/ParameterLoader.vue'
73+ import mavlink2rest from ' @/libs/MAVLink2Rest'
74+ import { MavCmd } from ' @/libs/MAVLink2Rest/mavlink2rest-ts/messages/mavlink2rest-enum'
75+ import Notifier from ' @/libs/notifier'
76+ import autopilot_data from ' @/store/autopilot'
3377import autopilot from ' @/store/autopilot_manager'
78+ import { Dictionary } from ' @/types/common'
79+ import { frontend_service } from ' @/types/frontend_services'
3480
81+ const notifier = new Notifier (frontend_service )
3582const REPOSITORY_URL = ' https://docs.bluerobotics.com/Blueos-Parameter-Repository/params_v1.json'
3683
3784export default Vue .extend ({
@@ -43,6 +90,10 @@ export default Vue.extend({
4390 all_param_sets: {} as Dictionary <Dictionary <number >>,
4491 selected_paramset: {} as Dictionary <number >,
4592 selected_paramset_name: undefined as (undefined | string ),
93+ wipe_successful: false ,
94+ rebooting: false ,
95+ done: false ,
96+ erasing: false ,
4697 }),
4798 computed: {
4899 board(): string | undefined {
@@ -92,6 +143,65 @@ export default Vue.extend({
92143 this .selected_paramset_name = name
93144 this .selected_paramset = paramset
94145 },
146+ async restartAutopilot(): Promise <void > {
147+ this .rebooting = true
148+ await AutopilotManager .restart ()
149+ autopilot_data .reset ()
150+ // reset to initial
151+ this .done = true
152+ this .rebooting = false
153+ },
154+ wipe() {
155+ this .erasing = true
156+ mavlink2rest .sendMessage ({
157+ header: {
158+ system_id: 255 ,
159+ component_id: 1 ,
160+ sequence: 1 ,
161+ },
162+ message: {
163+ type: ' COMMAND_LONG' ,
164+ param1: 2 , // PARAM_RESET_CONFIG_DEFAULT from MAV_CMD_PREFLIGHT_STORAGE
165+ param2: 0 ,
166+ param3: 0 ,
167+ param4: 0 ,
168+ param5: 0 ,
169+ param6: 0 ,
170+ param7: 0 ,
171+ command: {
172+ type: MavCmd .MAV_CMD_PREFLIGHT_STORAGE ,
173+ },
174+ target_system: autopilot_data .system_id ,
175+ target_component: 1 ,
176+ confirmation: 1 ,
177+ },
178+ })
179+ let timeout = 0
180+ const ack_listener = mavlink2rest .startListening (' COMMAND_ACK' ).setCallback ((message ) => {
181+ if (message .message .command .type === ' MAV_CMD_PREFLIGHT_STORAGE' ) {
182+ if (message .message .result .type === ' MAV_RESULT_ACCEPTED' ) {
183+ clearTimeout (timeout )
184+ this .wipe_successful = true
185+ ack_listener .discard ()
186+ autopilot_data .setRebootRequired (true )
187+ this .erasing = false
188+ return
189+ }
190+ this .wipe_successful = false
191+ ack_listener .discard ()
192+ clearTimeout (timeout )
193+ this .erasing = false
194+ notifier .pushError (' PARAM_RESET_FAIL' , ` Parameters Reset failed: ${message .message .result .type } ` , true )
195+ }
196+ })
197+ timeout = setTimeout (() => {
198+ ack_listener .discard ()
199+ this .wipe_successful = false
200+ this .erasing = false
201+ notifier .pushError (' PARAM_RESET_TIMEOUT' , ' Parameters Reset timed out' , true )
202+ }, 2000 )
203+ },
204+
95205 },
96206})
97207 </script >
0 commit comments