Drone Control API Documentation
This documentation provides detailed information about the functions available in the Pyfylo Fylo EDU+ Drone Control API, designed for controlling drones in coordinated dance or flight performances. Each function includes descriptions, parameters, return values, and relevant notes or warnings.
System Configuration
change_language(message)
Change the system language.
更改系统语言。
Parameters:
- message: Language to set (Chg, Eng, TChn)
change_plane_mode(flags=1)
Change the plane mode.
更改飞机模式。
Parameters:
- flags: 0 for B02 mode, 1 for B02s mode
change_station_num(num=4)
Change the number of stations.
更改基站数量。
Parameters:
- num: Number of stations (4, 6, 8)
check_firmware_version(plane_id)
Check the plane's firmware version. If an update is needed, use the mobile app to update.
检查飞机固件版本是否需要升级。如果需要升级,请使用手机APP进行升级。
Parameters:
- plane_id: Plane ID to check. If -1, checks all connected planes.
Returns:
- plane_id: Corresponding plane needs firmware update
- -2: Plane does not need update
- -3: Parameter error
- -4: Plane not connected
- -5: Network error
connect(connect_type)
Connect to stations using WiFi or Repeater.
通过网络或者中继器连接到基站。
Parameters:
- connect_type: Connection type (ConnectType.Network or ConnectType.Serial)
Returns:
- True: Success
- False: Failure
disconnect()
Disconnect from WiFi or Repeater.
断开网络或者中继器连接。
Dance Programming
dance_create_start()
Start creating dance programs.
开始编辑舞步。
Warning:
- Should be called before dance_create_end().
- Should be called only once for multiple drones.
- Total program duration should be less than 10 minutes.
警告:
- 生成舞步前必须调用,调用完该函数后才可为每台飞机添加舞步。
- 多台飞机只需调用一次。
- 舞步总时长最长为10分钟。
dance_create_end()
Stop creating dance programs and generate programs; should be called only once for multiple drones.
结束编辑舞步,并生成舞步。多台飞机只需调用一次。
Returns:
- 0: Generating programs successful
- -1: The length of programs is out of limits (10 minutes)
- -2: The program is empty
dance_fly_takeoff(plane_id, mode, r, g, b)
Add takeoff movement to program.
添加舞步起飞。
Parameters:
- plane_id: Plane ID (0-39)
- mode: Flash mode of lights (0 for breathing light, 1 for colorful light, 2 for steady light, 3 for off)
- r: Red channel (0-255)
- g: Green channel (0-255)
- b: Blue channel (0-255)
Returns:
- -1: Adding takeoff movement to program failed
- positive integer: The number of frames from takeoff to the end of current movement
dance_fly_touchdown(plane_id, mode, r, g, b)
Add touchdown movement to program.
添加舞步降落。
Parameters:
- plane_id: Plane ID (0-39)
- mode: Flash mode of lights (0 for breathing light, 1 for colorful light, 2 for steady light, 3 for off)
- r: Red channel (0-255)
- g: Green channel (0-255)
- b: Blue channel (0-255)
Returns:
- -1: Adding touchdown movement to program failed
- positive integer: The number of frames from takeoff to the end of current movement
dance_fly_forward(plane_id, distance, mode, r, g, b)
Add flying forward movement to program.
添加舞步向前飞。
Parameters:
- plane_id: Plane ID (0-39)
- distance: Movement distance (cm)
- mode: Flash mode of lights (0 for breathing light, 1 for colorful light, 2 for steady light, 3 for off)
- r: Red channel (0-255)
- g: Green channel (0-255)
- b: Blue channel (0-255)
Returns:
- -1: Adding flying forward movement to program failed
- positive integer: The number of frames from takeoff to the end of current movement
dance_fly_diy(plane_id, x, y, z, r, g, b)
Add DIY dance programs; trajectory and lights pattern should be adjusted to 30 fps; every list of x, y, z, r, g, and b should have the same size.
添加自定义舞步,飞行轨迹与灯光配置由用户以每秒30帧填入,x,y,z,r,g,b的长度必须统一。
Parameters:
- plane_id: Plane ID (0-39)
- x: List/tuple of coordinate x (cm) in trajectory
- y: List/tuple of coordinate y (cm) in trajectory
- z: List/tuple of coordinate z (cm) in trajectory
- r: List/tuple of red light pattern in trajectory
- g: List/tuple of green light pattern in trajectory
- b: List/tuple of blue light pattern in trajectory
Returns:
- -1: Adding DIY dance programs failed
- positive integer: The number of frames from takeoff to the end of current movement
dance_set_coordinate(plane_id, x, y)
Set one drone's initial coordinates (x, y) on ground, and the No. 0 plane's default is (0, 0).
设置飞机起飞坐标(x,y),零号飞机默认(0,0)坐标。
Parameters:
- plane_id: Plane ID (0-39)
- x: Specific coordinate x (cm)
- y: Specific coordinate y (cm)
Warning:
- For each drone, must be called as the first step when creating dance programs.
警告:
- 每台飞机的开始添加舞步前必须设置飞机坐标。
Status and Monitoring
get_battery(plane_id)
Get one drone's battery level.
获取飞机电量百分比。
Parameters:
- plane_id: Plane ID
Returns:
- integer: Battery level
get_connect_status()
Get connection status.
获取网络链接状态。
Returns:
- 1: Connected
- 0: Disconnected
Flight Control
single_fly_takeoff(plane_id, height, magnetism)
Ask one drone to take off.
实时控制飞机起飞。
Parameters:
- plane_id: Plane ID
- height: Target height (cm)
- magnetism: Use compass or not (1 for yes, other for no)
multi_fly_takeoff(plane_id_list, magnetism, delay=0)
Ask drones in list to perform dance programs.
飞机开始执行舞步。
Parameters:
- plane_id_list: List of specific drones
- magnetism: Use compass or not (1 for yes, others for no)
- delay: Time (ms) to delay before takeoff
Note:
- Use compass when dance duration longer than 150 seconds.
注意:
- 当舞步时间大于150秒时,会需要使用磁场进行飞行。
System Management
plane_sys_init(yaw=-1)
Synchronize positions, establish coordinate system based on No. 0 plane, and update all connected drones' coordinates.
定桩,以当前0号飞机坐标为(0,0,0)建立坐标系,并为所有飞机设置当前坐标。
Parameters:
- yaw: No. 0 drone's yaw angle (°)
Warning:
- Must be called before takeoff, meanwhile, make sure get_aux_setup and get_range_safe return true.
警告:
- 飞机起飞前必须进行,并且要求get_aux_setup、get_range_safe返回true时方可起飞。