diff --git a/core/frontend/src/components/autopilot/AutopilotManagerUpdater.ts b/core/frontend/src/components/autopilot/AutopilotManagerUpdater.ts index e22962e788..9668811517 100644 --- a/core/frontend/src/components/autopilot/AutopilotManagerUpdater.ts +++ b/core/frontend/src/components/autopilot/AutopilotManagerUpdater.ts @@ -4,7 +4,7 @@ import { SemVer } from 'semver' import Notifier from '@/libs/notifier' import autopilot_data from '@/store/autopilot' import autopilot from '@/store/autopilot_manager' -import { Firmware, Vehicle } from '@/types/autopilot' +import { Firmware, SITLFrame, Vehicle } from '@/types/autopilot' import { Dictionary } from '@/types/common' import { autopilot_service } from '@/types/frontend_services' import back_axios from '@/utils/api' @@ -114,6 +114,20 @@ export async function fetchFirmwareVehicleType(): Promise { } } +export async function fetchSitlFrame(): Promise { + try { + const response: AxiosResponse = await back_axios({ + method: 'get', + url: `${autopilot.API_URL}/sitl_frame`, + timeout: 10000, + }) + autopilot.setSitlFrame(response.data as SITLFrame) + } catch (error) { + autopilot.setSitlFrame(null) + notifier.pushBackError('AUTOPILOT_SITL_FRAME_FETCH_FAIL', error) + } +} + export async function availableFirmwares(vehicleType: Vehicle): Promise { return back_axios({ method: 'get', diff --git a/core/frontend/src/components/autopilot/SitlConfiguration.vue b/core/frontend/src/components/autopilot/SitlConfiguration.vue new file mode 100644 index 0000000000..3911a75a0e --- /dev/null +++ b/core/frontend/src/components/autopilot/SitlConfiguration.vue @@ -0,0 +1,100 @@ + + + diff --git a/core/frontend/src/store/autopilot_manager.ts b/core/frontend/src/store/autopilot_manager.ts index 2c5c994403..52071b805f 100644 --- a/core/frontend/src/store/autopilot_manager.ts +++ b/core/frontend/src/store/autopilot_manager.ts @@ -5,7 +5,7 @@ import { import store from '@/store' import { AutopilotEndpoint, FirmwareInfo, FirmwareVehicleType, - FlightController, SerialEndpoint, + FlightController, SerialEndpoint, SITLFrame, } from '@/types/autopilot' @Module({ @@ -29,6 +29,8 @@ class AutopilotManagerStore extends VuexModule { firmware_vehicle_type: FirmwareVehicleType | null = null + sitl_frame: SITLFrame | null = null + updating_endpoints = true updating_boards = true @@ -72,6 +74,13 @@ class AutopilotManagerStore extends VuexModule { this.firmware_vehicle_type = firmware_vehicle_type } + @Mutation + setSitlFrame(sitl_frame: SITLFrame | null): void { + // UNDEFINED means "no frame selected" — collapse it to null so consumers + // (e.g. the SITL ) have a single sentinel to handle. + this.sitl_frame = sitl_frame === SITLFrame.UNDEFINED ? null : sitl_frame + } + @Mutation setAvailableEndpoints(available_endpoints: AutopilotEndpoint[]): void { this.available_endpoints = available_endpoints diff --git a/core/frontend/src/types/autopilot.ts b/core/frontend/src/types/autopilot.ts index feca849ab7..031494af34 100644 --- a/core/frontend/src/types/autopilot.ts +++ b/core/frontend/src/types/autopilot.ts @@ -30,6 +30,62 @@ export enum Platform { SITL_ARM = 'SITL_arm_linux_gnueabihf', } +// Mirrors the SITLFrame enum from +// core/services/ardupilot_manager/typedefs.py +export enum SITLFrame { + QUADPLANE = 'quadplane', + XPLANE = 'xplane', + FIREFLY = 'firefly', + PLUS_CONFIG = '+', + QUAD = 'quad', + COPTER = 'copter', + X_CONFIG = 'x', + BFXREV = 'bfxrev', + BFX = 'bfx', + DJIX = 'djix', + CWX = 'cwx', + HEXA = 'hexa', + HEXA_CWX = 'hexa-cwx', + HEXA_DJI = 'hexa-dji', + OCTA = 'octa', + OCTA_CWX = 'octa-cwx', + OCTA_DJI = 'octa-dji', + OCTA_QUAD_CWX = 'octa-quad-cwx', + DODECA_HEXA = 'dodeca-hexa', + TRI = 'tri', + Y_SIX = 'y6', + HELI = 'heli', + HELI_DUAL = 'heli-dual', + HELI_COMPOUND = 'heli-compound', + SINGLECOPTER = 'singlecopter', + COAXCOPTER = 'coaxcopter', + ROVER = 'rover', + ROVER_SKID = 'rover-skid', + ROVER_VECTORED = 'rover-vectored', + BALANCEBOT = 'balancebot', + SAILBOAT = 'sailboat', + MOTORBOAT = 'motorboat', + MOTORBOAT_SKID = 'motorboat-skid', + CRRCSIM = 'crrcsim', + JSBSIM = 'jsbsim', + FLIGHTAXIS = 'flightaxis', + GAZEBO = 'gazebo', + LAST_LETTER = 'last_letter', + TRACKER = 'tracker', + BALLOON = 'balloon', + PLANE = 'plane', + CALIBRATION = 'calibration', + VECTORED = 'vectored', + VECTORED_6DOF = 'vectored_6dof', + SILENTWINGS = 'silentwings', + MORSE = 'morse', + AIRSIM = 'airsim', + SCRIMMAGE = 'scrimmage', + WEBOTS = 'webots', + JSON = 'JSON', + UNDEFINED = 'undefined', +} + export enum EndpointType { udpin = 'udpin', udpout = 'udpout', diff --git a/core/frontend/src/views/Autopilot.vue b/core/frontend/src/views/Autopilot.vue index 343338e216..8cd4e5f238 100644 --- a/core/frontend/src/views/Autopilot.vue +++ b/core/frontend/src/views/Autopilot.vue @@ -64,6 +64,16 @@ + + + + SITL configuration + + + + + + @@ -139,6 +149,7 @@ import AutopilotSerialConfiguration from '@/components/autopilot/AutopilotSerial import BoardChangeDialog from '@/components/autopilot/BoardChangeDialog.vue' import FirmwareManager from '@/components/autopilot/FirmwareManager.vue' import MasterEndpointManager from '@/components/autopilot/MasterEndpointManager.vue' +import SitlConfiguration from '@/components/autopilot/SitlConfiguration.vue' import NotSafeOverlay from '@/components/common/NotSafeOverlay.vue' import { MavAutopilot } from '@/libs/MAVLink2Rest/mavlink2rest-ts/messages/mavlink2rest-enum' import Notifier from '@/libs/notifier' @@ -161,6 +172,7 @@ export default Vue.extend({ AutopilotSerialConfiguration, NotSafeOverlay, MasterEndpointManager, + SitlConfiguration, }, data() { return { @@ -221,6 +233,9 @@ export default Vue.extend({ is_external_board(): boolean { return autopilot.current_board?.name === 'Manual' }, + is_sitl(): boolean { + return autopilot.current_board?.name === 'SITL' + }, current_board(): FlightController | null { return autopilot.current_board }, diff --git a/core/services/ardupilot_manager/api/v1/routers/index.py b/core/services/ardupilot_manager/api/v1/routers/index.py index 30fbea116e..ea7566653e 100644 --- a/core/services/ardupilot_manager/api/v1/routers/index.py +++ b/core/services/ardupilot_manager/api/v1/routers/index.py @@ -136,6 +136,12 @@ async def set_sitl_frame(frame: SITLFrame) -> Any: return autopilot.set_sitl_frame(frame) +@index_router_v1.get("/sitl_frame", response_model=SITLFrame, summary="Get current SITL Frame type.") +@index_to_http_exception +async def get_sitl_frame() -> Any: + return autopilot.current_sitl_frame + + @index_router_v1.get("/firmware_vehicle_type", response_model=str, summary="Get firmware vehicle type.") @index_to_http_exception async def get_firmware_vehicle_type() -> Any: