drone.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import request, { IWorkspaceResponse } from '/@/api/http/request';
  2. const API_PREFIX = '/control/api/v1'
  3. // 获取飞行控制权
  4. export async function postFlightAuth(sn: string): Promise<IWorkspaceResponse<null>> {
  5. const resp = await request.post(`${API_PREFIX}/devices/${sn}/authority/flight`)
  6. return resp.data
  7. }
  8. export enum WaylineLostControlActionInCommandFlight {
  9. CONTINUE = 0,
  10. EXEC_LOST_ACTION = 1
  11. }
  12. export enum LostControlActionInCommandFLight {
  13. HOVER = 0, // 悬停
  14. Land = 1, // 着陆
  15. RETURN_HOME = 2, // 返航
  16. }
  17. export enum ERthMode {
  18. SMART = 0,
  19. SETTING = 1
  20. }
  21. export enum ECommanderModeLostAction {
  22. CONTINUE = 0,
  23. EXEC_LOST_ACTION = 1
  24. }
  25. export enum ECommanderFlightMode {
  26. SMART = 0,
  27. SETTING = 1
  28. }
  29. export interface PointBody {
  30. latitude: number;
  31. longitude: number;
  32. height: number;
  33. }
  34. export interface PostFlyToPointBody {
  35. max_speed: number,
  36. points: PointBody[]
  37. }
  38. // 飞向目标点
  39. export async function postFlyToPoint(sn: string, body: PostFlyToPointBody): Promise<IWorkspaceResponse<null>> {
  40. const resp = await request.post(`${API_PREFIX}/devices/${sn}/jobs/fly-to-point`, body)
  41. return resp.data
  42. }
  43. // 停止飞向目标点
  44. export async function deleteFlyToPoint(sn: string): Promise<IWorkspaceResponse<null>> {
  45. const resp = await request.delete(`${API_PREFIX}/devices/${sn}/jobs/fly-to-point`)
  46. return resp.data
  47. }
  48. export interface PostTakeoffToPointBody {
  49. target_height: number;
  50. target_latitude: number;
  51. target_longitude: number;
  52. security_takeoff_height: number; // 安全起飞高
  53. max_speed: number; // flyto过程中能达到的最大速度, 单位m/s 跟飞机档位有关
  54. rc_lost_action: LostControlActionInCommandFLight; // 失控行为
  55. rth_altitude: number; // 返航高度
  56. exit_wayline_when_rc_lost: WaylineLostControlActionInCommandFlight;
  57. rth_mode: ERthMode;
  58. commander_mode_lost_action: ECommanderModeLostAction;
  59. commander_flight_mode: ECommanderFlightMode;
  60. commander_flight_height: number;
  61. }
  62. // 一键起飞
  63. export async function postTakeoffToPoint(sn: string, body: PostTakeoffToPointBody): Promise<IWorkspaceResponse<null>> {
  64. const resp = await request.post(`${API_PREFIX}/devices/${sn}/jobs/takeoff-to-point`, body)
  65. return resp.data
  66. }