11import { differenceInMilliseconds } from 'date-fns'
2+ import { defaultMessageIntervalsOptions } from 'defaults'
23import { unit } from 'mathjs'
34
45import {
@@ -48,28 +49,22 @@ import {
4849 StatusText ,
4950 Velocity ,
5051} from '@/libs/vehicle/types'
51- import type { MetadataFile } from '@/types/ardupilot-metadata'
5252import { type MissionLoadingCallback , type Waypoint , defaultLoadingCallback } from '@/types/mission'
5353
5454import { flattenData } from '../common/data-flattener'
55- import { defaultMessageIntervalsOptions } from '../mavlink/defaults'
56- import * as MAVLinkVehicle from '../mavlink/vehicle'
5755import * as Vehicle from '../vehicle'
5856
5957export const MAVLINK_MESSAGE_INTERVALS_STORAGE_KEY = 'cockpit-mavlink-message-intervals'
6058
61- // eslint-disable-next-line @typescript-eslint/no-explicit-any
62- export type ArduPilot = ArduPilotVehicle < any >
63-
6459const preDefinedDataLakeVariables = {
6560 cameraTilt : { id : 'cameraTiltDeg' , name : 'Camera Tilt Degrees' , type : 'number' } ,
66- ardupilotSystemId : { id : 'ardupilotSystemId ' , name : 'ArduPilot System ID' , type : 'number' } ,
61+ autopilotSystemId : { id : 'autopilotSystemId ' , name : 'Autopilot System ID' , type : 'number' } ,
6762}
6863
6964/**
70- * Generic ArduPilot vehicle
65+ * Generic MAVLink vehicle
7166 */
72- export abstract class ArduPilotVehicle < Modes > extends MAVLinkVehicle . MAVLinkVehicle < Modes > {
67+ export abstract class MAVLinkVehicle < Modes > extends Vehicle . AbstractVehicle < Modes > {
7368 _altitude = new Altitude ( { msl : unit ( 0 , 'm' ) , rel : 0 } )
7469 _attitude = new Attitude ( { roll : 0 , pitch : 0 , yaw : 0 } )
7570 _communicationDropRate = 0
@@ -90,7 +85,7 @@ export abstract class ArduPilotVehicle<Modes> extends MAVLinkVehicle.MAVLinkVehi
9085 _statusText = new StatusText ( )
9186 _statusGPS = new StatusGPS ( )
9287 _vehicleSpecificErrors = [ 0 , 0 , 0 , 0 ]
93- _metadata : MetadataFile
88+
9489 _messages : MAVLinkMessageDictionary = new Map ( )
9590
9691 onIncomingMAVLinkMessage = new SignalTyped ( )
@@ -100,31 +95,13 @@ export abstract class ArduPilotVehicle<Modes> extends MAVLinkVehicle.MAVLinkVehi
10095 protected currentSystemId = 1
10196
10297 /**
103- * Returns the current system ID
104- * @returns {number }
105- */
106- get systemId ( ) : number {
107- return this . currentSystemId
108- }
109-
110- /**
111- * Function for subclass inheritance
112- * Helps to deal with specialized vehicles that has particular or custom behaviour
113- * @param {Package } mavlink message
114- */
115- protected onMAVLinkPackage ( mavlink : Package ) : void {
116- // Nothing here, typescript does not not have clean optional abstract methods
117- // without abstract class
118- mavlink
119- }
120-
121- /**
122- * Construct a new generic ArduPilot type
98+ * Create MAVLink vehicle
99+ * @param {Vehicle.Firmware } firmware
123100 * @param {Vehicle.Type } type
124101 * @param {number } systemId
125102 */
126- constructor ( type : Vehicle . Type , systemId : number ) {
127- super ( Vehicle . Firmware . ArduPilot , type )
103+ constructor ( firmware : Vehicle . Firmware , type : Vehicle . Type , systemId : number ) {
104+ super ( firmware , type )
128105 this . currentSystemId = systemId
129106
130107 // Request vehicle to stream a pre-defined list of messages so the GCS can receive them
@@ -139,7 +116,26 @@ export abstract class ArduPilotVehicle<Modes> extends MAVLinkVehicle.MAVLinkVehi
139116 this . createPredefinedDataLakeVariables ( )
140117
141118 // Set the system ID in the data-lake
142- setDataLakeVariableData ( preDefinedDataLakeVariables . ardupilotSystemId . id , systemId )
119+ setDataLakeVariableData ( preDefinedDataLakeVariables . autopilotSystemId . id , systemId )
120+ }
121+
122+ /**
123+ * Returns the current system ID
124+ * @returns {number }
125+ */
126+ get systemId ( ) : number {
127+ return this . currentSystemId
128+ }
129+
130+ /**
131+ * Function for subclass inheritance
132+ * Helps to deal with specialized vehicles that has particular or custom behaviour
133+ * @param {Package } mavlink message
134+ */
135+ protected onMAVLinkPackage ( mavlink : Package ) : void {
136+ // Nothing here, typescript does not not have clean optional abstract methods
137+ // without abstract class
138+ mavlink
143139 }
144140
145141 /**
@@ -694,14 +690,6 @@ export abstract class ArduPilotVehicle<Modes> extends MAVLinkVehicle.MAVLinkVehi
694690 return this . _flying
695691 }
696692
697- /**
698- * Return metadata from the vehicle
699- * @returns {MetadataFile }
700- */
701- metadata ( ) : MetadataFile {
702- return this . _metadata
703- }
704-
705693 /**
706694 * Return vehicle position information
707695 * @returns {Coordinates }
0 commit comments