Difference between revisions of "Codes Explanation of LiteBee Go"

From Makerfire
Jump to: navigation, search
(Created page with "Python tutorial Contents 一、 Brief Intro 3 二、 Basic operation and example 3 1. Basic Operation 3 2. Examples 3 Import time 3 Conditional and loop statement 4 Formation...")
 
 
(14 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
Contents
 
Contents
  
一、 Brief Intro 3
+
'''I、 Brief Intro'''
二、 Basic operation and example 3
 
1. Basic Operation 3
 
2. Examples 3
 
Import time 3
 
Conditional and loop statement 4
 
Formation example 4
 
三、 Instruction explanation 5
 
1. LiteBee Wing 5
 
litebeeWing_calibration()  calibrate 5
 
litebeeWing_autoLand() land 5
 
litebeeWing_getAnglePitch()  the angle of pitch is 5
 
litebeeWing_getAngleRoll()  the angle of roll is 5
 
litebeeWing_getAngleYaw()  the angle of yaw is 5
 
litebeeWing_getHigh()  the height is 5
 
litebeeWing_getVol()  the voltage is 5
 
litebeeWing_setBuzzer(['E4', 0.5])  set the buzzer 5
 
litebeeWing_setDir([0, 0, 0, 10])  set the drone to fly horizontally 5
 
litebeeWing_setHigh([110])  set the flight height as 5
 
litebeeWing_setMotor([1, 50])  test the rotor 5
 
litebeeWing_setYaw([1, 90])  yaw the drone 6
 
litebeeWing_takeOff()  take off 6
 
2. litebeeWingAvoidance  With the obstacle avoiding module 6
 
litebeeWingAvoidance_autoLand()  land 6
 
litebeeWingAvoidance_backward()  sense the obstacle behind 6
 
litebeeWingAvoidance_calibration()  calibrate 6
 
litebeeWingAvoidance_center()  sense the obstacle below 6
 
litebeeWingAvoidance_forward()  sense the obstacle ahead 6
 
litebeeWingAvoidance_left()  sense the obstacle on the left 6
 
litebeeWingAvoidance_right()  sense the obstacle on the right 6
 
litebeeWingAvoidance_setDir([0, 0, 0, 10])  set the drone to fly horizontally 6
 
litebeeWingAvoidance_setHigh([110])  set the flight height 6
 
litebeeWingAvoidance_setVXYZ([0, 0, 0, 10, 0, 0])  set the drone fly 6
 
litebeeWingAvoidance_setYaw([1, 90])  Yaw the drone 6
 
litebeeWingAvoidance_takeOff()  take off 6
 
3. litebeeWingFormation  Formation mode 6
 
litebeeWingFormation_allLand()  crash-land 6
 
litebeeWingFormation_autoLand()  land 6
 
litebeeWingFormation_calibration([5])  calibrate 7
 
litebeeWingFormation_circle([66, 77, 0, 2, 15])  circle 7
 
litebeeWingFormation_circleZ([66, 77, 0, 150, 15])  ircle and adjust drone's height 7
 
litebeeWingFormation_clear()  clear all setting 7
 
litebeeWingFormation_code([66, 10])  fly to the given QR code 7
 
litebeeWingFormation_codeS(['12 23 27', 15])  fly multiple QR codes in order 7
 
litebeeWingFormation_codeZ([66, 120, 10])  fly to the given QR code and adjust drone's height 7
 
litebeeWingFormation_flightNum([1])  set for the given drone 7
 
litebeeWingFormation_missionSend()  send the mission to drones 7
 
litebeeWingFormation_missionStart()  start the mission 7
 
litebeeWingFormation_RGB([1]) turn the LED on 7
 
litebeeWingFormation_setZ([100, 3])  set the flight height 7
 
litebeeWingFormation_takeOff([100, 5])  take off 7
 
4. litebeeWingLine  with line tracking module 7
 
litebeeWingLine_autoLand()  land 7
 
litebeeWingLine_calibration()  calibrate 7
 
litebeeWingLine_color()  the color of tracking line 8
 
litebeeWingLine_control([1, 15])  Line tracking setting 8
 
litebeeWingLine_crossDetrct()  at the crossroads 8
 
litebeeWingLine_crossX()  Distance from the cross-point in X-axis 8
 
litebeeWingLine_crossY()  Distance from the cross-point in Y-axis 8
 
litebeeWingLine_open()  start line tracking module 8
 
litebeeWingLine_setRGBLed([1, 255, 255, 255])  LED module setting 8
 
litebeeWingLine_takeOff()  take off 8
 
litebeeWingLine_type()  the mode of line tracking 8
 
5. ghost2 8
 
ghost2_autoLand()  land 8
 
ghost2_calibration()  calibration 8
 
ghost2_getAnglePitch()  the angle of pitch is 8
 
ghost2_getAngleRoll()  the angle of roll is 8
 
ghost2_getAngleYaw()  the angle of yaw is 8
 
ghost2_getHigh()  the height is 8
 
ghost2_getVol()  the voltage is 8
 
ghost2_setDir([1, 1])  set the drone to fly 8
 
ghost2_setHigh([110])  set the flight height as 8
 
ghost2_setMotor([1, 50])  test the rotor 8
 
ghost2_setYaw([1, 90])  yaw the drone 9
 
ghost2_takeOff()  take off 9
 
6. ghost2Avoidance  with the obstacle avoiding module 9
 
ghost2Avoidance_autoLand()  land 9
 
ghost2Avoidance_backward()  sense the obstacle behind 9
 
ghost2Avoidance_calibration()  calibrate 9
 
ghost2Avoidance_center()  sense the obstacle above 9
 
ghost2Avoidance_forward()  sense the obstacle ahead 9
 
ghost2Avoidance_setDir([0, 0, 0, 10])  set thedrone fly horizontally 9
 
ghost2Avoidance_setHigh([110])  set the flight height as 9
 
ghost2Avoidance_setVXYZ([0, 0, 0, 10, 0, 0])  set the drone to fly 9
 
ghost2Avoidance_setYaw([1, 90])  yaw the drone 9
 
ghost2Avoidance_takeOff()  take off 9
 
  
一、Brief Intro
+
'''II、 Basic operation and example'''
 +
*1. Basic Operation
 +
*2. Examples
 +
#Import time
 +
#Conditional and loop statement
 +
#Formation example
 +
 
 +
'''III、 Instruction explanation'''
 +
*1. LiteBee Wing
 +
#litebeeWing_calibration()  calibrate
 +
#litebeeWing_autoLand() land
 +
#litebeeWing_getAnglePitch()  the angle of pitch is
 +
#litebeeWing_getAngleRoll()  the angle of roll is
 +
#litebeeWing_getAngleYaw()  the angle of yaw is
 +
#litebeeWing_getHigh()  the height is
 +
#litebeeWing_getVol()  the voltage is
 +
#litebeeWing_setBuzzer(['E4', 0.5])  set the buzzer
 +
#litebeeWing_setDir([0, 0, 0, 10])  set the drone to fly horizontally
 +
#litebeeWing_setHigh([110])  set the flight height as
 +
#litebeeWing_setMotor([1, 50])  test the rotor
 +
#litebeeWing_setYaw([1, 90])  yaw the drone
 +
#litebeeWing_takeOff()  take off
 +
*2. litebeeWingAvoidance  With the obstacle avoiding module
 +
#litebeeWingAvoidance_autoLand()  land
 +
#litebeeWingAvoidance_backward()  sense the obstacle behind
 +
#litebeeWingAvoidance_calibration()  calibrate
 +
#litebeeWingAvoidance_center()  sense the obstacle below
 +
#litebeeWingAvoidance_forward()  sense the obstacle ahead
 +
#litebeeWingAvoidance_left()  sense the obstacle on the left
 +
#litebeeWingAvoidance_right()  sense the obstacle on the right
 +
#litebeeWingAvoidance_setDir([0, 0, 0, 10])  set the drone to fly horizontally
 +
#litebeeWingAvoidance_setHigh([110])  set the flight height
 +
#litebeeWingAvoidance_setVXYZ([0, 0, 0, 10, 0, 0])  set the drone fly
 +
#litebeeWingAvoidance_setYaw([1, 90])  Yaw the drone
 +
#litebeeWingAvoidance_takeOff()  take off
 +
*3. litebeeWingFormation  Formation mode
 +
#litebeeWingFormation_allLand()  crash-land
 +
#litebeeWingFormation_autoLand()  land
 +
#litebeeWingFormation_calibration([5])  calibrate
 +
#litebeeWingFormation_circle([66, 77, 0, 2, 15])  circle
 +
#litebeeWingFormation_circleZ([66, 77, 0, 150, 15])  ircle and adjust drone's height
 +
#litebeeWingFormation_clear()  clear all setting
 +
#litebeeWingFormation_code([66, 10])  fly to the given QR code
 +
#litebeeWingFormation_codeS(['12 23 27', 15])  fly multiple QR codes in order
 +
#litebeeWingFormation_codeZ([66, 120, 10])  fly to the given QR code and adjust drone's height
 +
#litebeeWingFormation_flightNum([1])  set for the given drone
 +
#litebeeWingFormation_missionSend()  send the mission to drones
 +
#litebeeWingFormation_missionStart()  start the mission
 +
#litebeeWingFormation_RGB([1]) turn the LED on
 +
#litebeeWingFormation_setZ([100, 3])  set the flight height
 +
#litebeeWingFormation_takeOff([100, 5])  take off
 +
*4. litebeeWingLine  with line tracking module
 +
#litebeeWingLine_autoLand()  land
 +
#litebeeWingLine_calibration()  calibrate
 +
#litebeeWingLine_color()  the color of tracking line
 +
#litebeeWingLine_control([1, 15])  Line tracking setting
 +
#litebeeWingLine_crossDetrct()  at the crossroads
 +
#litebeeWingLine_crossX()  Distance from the cross-point in X-axis
 +
#litebeeWingLine_crossY()  Distance from the cross-point in Y-axis
 +
#litebeeWingLine_open()  start line tracking module
 +
#litebeeWingLine_setRGBLed([1, 255, 255, 255])  LED module setting
 +
#litebeeWingLine_takeOff()  take off
 +
#litebeeWingLine_type()  the mode of line tracking
 +
*5. ghost2
 +
#ghost2_autoLand()  land
 +
#ghost2_calibration()  calibration
 +
#ghost2_getAnglePitch()  the angle of pitch is
 +
#ghost2_getAngleRoll()  the angle of roll is
 +
#ghost2_getAngleYaw()  the angle of yaw is
 +
#ghost2_getHigh()  the height is
 +
#ghost2_getVol()  the voltage is
 +
#ghost2_setDir([1, 1])  set the drone to fly
 +
#ghost2_setHigh([110])  set the flight height as
 +
#ghost2_setMotor([1, 50])  test the rotor
 +
#ghost2_setYaw([1, 90])  yaw the drone
 +
#ghost2_takeOff()  take off
 +
*6. ghost2Avoidance  with the obstacle avoiding module
 +
#ghost2Avoidance_autoLand()  land
 +
#ghost2Avoidance_backward()  sense the obstacle behind
 +
#ghost2Avoidance_calibration()  calibrate
 +
#ghost2Avoidance_center()  sense the obstacle above
 +
#ghost2Avoidance_forward()  sense the obstacle ahead
 +
#ghost2Avoidance_setDir([0, 0, 0, 10])  set thedrone fly horizontally
 +
#ghost2Avoidance_setHigh([110])  set the flight height as
 +
#ghost2Avoidance_setVXYZ([0, 0, 0, 10, 0, 0])  set the drone to fly
 +
#ghost2Avoidance_setYaw([1, 90])  yaw the drone
 +
#ghost2Avoidance_takeOff()  take off
 +
 
 +
 
 +
'''I. Brief Intro'''
 
The python programming in LiteBeeGo can be applied for both LiteBee Wing and Ghost II, and it works with different modes such as drone only, obstacle avoiding, formation, and line tracking. Each Python instruction corresponds to the graphic code of scratch mode, and there will be an explanation when you input the relevant instructions. Details will be list in Chapter 3.  
 
The python programming in LiteBeeGo can be applied for both LiteBee Wing and Ghost II, and it works with different modes such as drone only, obstacle avoiding, formation, and line tracking. Each Python instruction corresponds to the graphic code of scratch mode, and there will be an explanation when you input the relevant instructions. Details will be list in Chapter 3.  
  
1.Basic operation and examples
+
'''II. Basic operation and examples'''
Basic operation
+
<br />1.Basic operation
Just as the picture shows, we can start LiteBeeGo and click “python” to enter the interface of Python. Connect the drone with the computer, then click "run" to execute the Python program
+
: Just as the picture shows, we can start LiteBeeGo and click “python” to enter the interface of Python. Connect the drone with the computer, then click "run" to execute the Python program
  
  
 
Hover the mouse on the “run” button to choose other operations such as Open, Save, and Stop. Attention, for easy to find and open, suffix it as “.py” when saving the file.  
 
Hover the mouse on the “run” button to choose other operations such as Open, Save, and Stop. Attention, for easy to find and open, suffix it as “.py” when saving the file.  
2.Example
+
<br />2.Example
 
import time
 
import time
Excepting formation, all the programming mode have to apply the “import time” to give a time for executing the mission.  
+
: Excepting formation, all the programming mode have to apply the “import time” to give a time for executing the mission.  
 
For example:  
 
For example:  
import time  //Write “import time” in the first line
+
  import time  //Write “import time” in the first line
litebeeWing_calibration() //calibrate
+
  litebeeWing_calibration() //calibrate
litebeeWing_takeOff()  take off
+
  litebeeWing_takeOff()  take off
time.sleep(10)  //wait 10s
+
  time.sleep(10)  //wait 10s
litebeeWing_autoland() //land
+
  litebeeWing_autoland() //land
  
 
Conditional and loop statement
 
Conditional and loop statement
Conditional and loop statement is needed when using these instructions, such as “if-elif-else”, “for”, “while”, here is an example:
+
<br />Conditional and loop statement is needed when using these instructions, such as “if-elif-else”, “for”, “while”, here is an example:
import time //import execution time
+
import time //import execution time
litebeeWing_calibration() //calibration
+
  litebeeWing_calibration() //calibration
time.sleep(5) //wait 5s
+
  time.sleep(5) //wait 5s
litebeeWing_takeOff() //take off
+
  litebeeWing_takeOff() //take off
time.sleep(5) //wait 5s
+
  time.sleep(5) //wait 5s
if litebeeWing_getVol() > 7.5: //if litebee’s voltage >7.5v
+
if litebeeWing_getVol() > 7.5: //if litebee’s voltage >7.5v
 
     litebeeWing_setHigh([50]) //set the flight height as 50cm
 
     litebeeWing_setHigh([50]) //set the flight height as 50cm
while True: //execute “while” loop
+
while True: //execute “while” loop
 
     if litebeeWing_getVol() < 7.2: //if litebee’s voltage < 7.2v
 
     if litebeeWing_getVol() < 7.2: //if litebee’s voltage < 7.2v
 
         litebeeWing_autoLand() //land
 
         litebeeWing_autoLand() //land
Line 124: Line 127:
  
 
Formation example
 
Formation example
When we program for a formation, we need to program for each drone; take a 2 drones formation as an example:
+
:When we program for a formation, we need to program for each drone; take a 2 drones formation as an example:
  
litebeeWingFormation_flightnum([1]) //program for drone No. 1
+
litebeeWingFormation_flightnum([1]) //program for drone No. 1
litebeeWingFormation_calibration([5]) //calibrate for 5s
+
litebeeWingFormation_calibration([5]) //calibrate for 5s
litebeeWingFormation_takeOff([100,5]) //fly to the height 100cm in 5s
+
litebeeWingFormation_takeOff([100,5])         //fly to the height 100cm in 5s
litebeeWingFormation_code([10,5]) //move to QR code No.10 in 5s
+
litebeeWingFormation_code([10,5]) //move to QR code No.10 in 5s
litebeeWingFormation_RGB([1]) //red light on
+
litebeeWingFormation_RGB([1]) //red light on
litebeeWingFormation_autoLand() //land
+
litebeeWingFormation_autoLand() //land
  
litebeeWingFormation_flightnum([2]) //program for drone No.2
+
litebeeWingFormation_flightnum([2]) //program for drone No.2
litebeeWingFormation_calibration([5]) //calibrate for 5s
+
litebeeWingFormation_calibration([5]) //calibrate for 5s
litebeeWingFormation_takeOff([100,5]) //fly to the height 100cm in 5s
+
litebeeWingFormation_takeOff([100,5])         //fly to the height 100cm in 5s
litebeeWingFormation_code([20,5]) //move to the QR code No. 20 in 5s
+
litebeeWingFormation_code([20,5]) //move to the QR code No. 20 in 5s
litebeeWingFormation_RGB([2]) //green light on
+
litebeeWingFormation_RGB([2]) //green light on
litebeeWingFormation_autoLand() //land
+
litebeeWingFormation_autoLand() //land
  
litebeeWingFormation_missionSend()  //send these mission to drones
+
litebeeWingFormation_missionSend()  //send these mission to drones
time.sleep(3) //wait 3 s
+
time.sleep(3) //wait 3 s
litebeeWingFormation_missionStart() //start the mission
+
litebeeWingFormation_missionStart() //start the mission
  
二、Instruction explanation
+
III. Instruction explanation
 
Note: p1, p2, p3, p4 are the parameter after the instruction (from left to right). And those instructions without parameter can be use directly.
 
Note: p1, p2, p3, p4 are the parameter after the instruction (from left to right). And those instructions without parameter can be use directly.
 
litebeeWing_setDir([0, 10, 1, 20])  Set the drone to fly horizontally
 
litebeeWing_setDir([0, 10, 1, 20])  Set the drone to fly horizontally
Line 157: Line 160:
 
1.litebeeWing   
 
1.litebeeWing   
  
litebeeWing_calibration()  calibrate
+
litebeeWing_calibration()  calibrate
litebeeWing_autoLand()   land
+
litebeeWing_autoLand()   land
litebeeWing_getAnglePitch()  the angle of pitch is
+
litebeeWing_getAnglePitch()  the angle of pitch is
litebeeWing_getAngleRoll()  the angle of roll is
+
litebeeWing_getAngleRoll()  the angle of roll is
litebeeWing_getAngleYaw() the angle of yaw is
+
litebeeWing_getAngleYaw() the angle of yaw is
litebeeWing_getHigh()  the flight height is
+
litebeeWing_getHigh()  the flight height is
litebeeWing_getVol() the voltage is
+
litebeeWing_getVol() the voltage is
litebeeWing_setBuzzer(['E4', 0.5])  set for the buzzer
+
litebeeWing_setBuzzer(['E4', 0.5])  set for the buzzer
  
 
#p1: scale
 
#p1: scale
 
It can be:
 
It can be:
#'B0', 'C1', 'CS1', 'D1','DS1', 'E1', 'F1', 'FS1','G1', 'GS1', 'A1', 'AS1','B1', 'C2', 'CS2', 'D2',
+
['B0', 'C1', 'CS1', 'D1','DS1', 'E1', 'F1', 'FS1','G1', 'GS1', 'A1', 'AS1','B1', 'C2', 'CS2', 'D2',
 
'DS2', 'E2', 'F2', 'FS2','G2', 'GS2', 'A2', 'AS2','B2', 'C3', 'CS3', 'D3','DS3', 'E3', 'F3', 'FS3',
 
'DS2', 'E2', 'F2', 'FS2','G2', 'GS2', 'A2', 'AS2','B2', 'C3', 'CS3', 'D3','DS3', 'E3', 'F3', 'FS3',
 
'G3', 'GS3', 'A3', 'AS3','B3', 'C4', 'CS4', 'D4','DS4', 'E4', 'F4', 'FS4','G4', 'GS4', 'A4', 'AS4',
 
'G3', 'GS3', 'A3', 'AS3','B3', 'C4', 'CS4', 'D4','DS4', 'E4', 'F4', 'FS4','G4', 'GS4', 'A4', 'AS4',

Latest revision as of 09:38, 10 September 2021

Python tutorial Contents

I、 Brief Intro

II、 Basic operation and example

  • 1. Basic Operation
  • 2. Examples
  1. Import time
  2. Conditional and loop statement
  3. Formation example

III、 Instruction explanation

  • 1. LiteBee Wing
  1. litebeeWing_calibration() calibrate
  2. litebeeWing_autoLand() land
  3. litebeeWing_getAnglePitch() the angle of pitch is
  4. litebeeWing_getAngleRoll() the angle of roll is
  5. litebeeWing_getAngleYaw() the angle of yaw is
  6. litebeeWing_getHigh() the height is
  7. litebeeWing_getVol() the voltage is
  8. litebeeWing_setBuzzer(['E4', 0.5]) set the buzzer
  9. litebeeWing_setDir([0, 0, 0, 10]) set the drone to fly horizontally
  10. litebeeWing_setHigh([110]) set the flight height as
  11. litebeeWing_setMotor([1, 50]) test the rotor
  12. litebeeWing_setYaw([1, 90]) yaw the drone
  13. litebeeWing_takeOff() take off
  • 2. litebeeWingAvoidance With the obstacle avoiding module
  1. litebeeWingAvoidance_autoLand() land
  2. litebeeWingAvoidance_backward() sense the obstacle behind
  3. litebeeWingAvoidance_calibration() calibrate
  4. litebeeWingAvoidance_center() sense the obstacle below
  5. litebeeWingAvoidance_forward() sense the obstacle ahead
  6. litebeeWingAvoidance_left() sense the obstacle on the left
  7. litebeeWingAvoidance_right() sense the obstacle on the right
  8. litebeeWingAvoidance_setDir([0, 0, 0, 10]) set the drone to fly horizontally
  9. litebeeWingAvoidance_setHigh([110]) set the flight height
  10. litebeeWingAvoidance_setVXYZ([0, 0, 0, 10, 0, 0]) set the drone fly
  11. litebeeWingAvoidance_setYaw([1, 90]) Yaw the drone
  12. litebeeWingAvoidance_takeOff() take off
  • 3. litebeeWingFormation Formation mode
  1. litebeeWingFormation_allLand() crash-land
  2. litebeeWingFormation_autoLand() land
  3. litebeeWingFormation_calibration([5]) calibrate
  4. litebeeWingFormation_circle([66, 77, 0, 2, 15]) circle
  5. litebeeWingFormation_circleZ([66, 77, 0, 150, 15]) ircle and adjust drone's height
  6. litebeeWingFormation_clear() clear all setting
  7. litebeeWingFormation_code([66, 10]) fly to the given QR code
  8. litebeeWingFormation_codeS(['12 23 27', 15]) fly multiple QR codes in order
  9. litebeeWingFormation_codeZ([66, 120, 10]) fly to the given QR code and adjust drone's height
  10. litebeeWingFormation_flightNum([1]) set for the given drone
  11. litebeeWingFormation_missionSend() send the mission to drones
  12. litebeeWingFormation_missionStart() start the mission
  13. litebeeWingFormation_RGB([1]) turn the LED on
  14. litebeeWingFormation_setZ([100, 3]) set the flight height
  15. litebeeWingFormation_takeOff([100, 5]) take off
  • 4. litebeeWingLine with line tracking module
  1. litebeeWingLine_autoLand() land
  2. litebeeWingLine_calibration() calibrate
  3. litebeeWingLine_color() the color of tracking line
  4. litebeeWingLine_control([1, 15]) Line tracking setting
  5. litebeeWingLine_crossDetrct() at the crossroads
  6. litebeeWingLine_crossX() Distance from the cross-point in X-axis
  7. litebeeWingLine_crossY() Distance from the cross-point in Y-axis
  8. litebeeWingLine_open() start line tracking module
  9. litebeeWingLine_setRGBLed([1, 255, 255, 255]) LED module setting
  10. litebeeWingLine_takeOff() take off
  11. litebeeWingLine_type() the mode of line tracking
  • 5. ghost2
  1. ghost2_autoLand() land
  2. ghost2_calibration() calibration
  3. ghost2_getAnglePitch() the angle of pitch is
  4. ghost2_getAngleRoll() the angle of roll is
  5. ghost2_getAngleYaw() the angle of yaw is
  6. ghost2_getHigh() the height is
  7. ghost2_getVol() the voltage is
  8. ghost2_setDir([1, 1]) set the drone to fly
  9. ghost2_setHigh([110]) set the flight height as
  10. ghost2_setMotor([1, 50]) test the rotor
  11. ghost2_setYaw([1, 90]) yaw the drone
  12. ghost2_takeOff() take off
  • 6. ghost2Avoidance with the obstacle avoiding module
  1. ghost2Avoidance_autoLand() land
  2. ghost2Avoidance_backward() sense the obstacle behind
  3. ghost2Avoidance_calibration() calibrate
  4. ghost2Avoidance_center() sense the obstacle above
  5. ghost2Avoidance_forward() sense the obstacle ahead
  6. ghost2Avoidance_setDir([0, 0, 0, 10]) set thedrone fly horizontally
  7. ghost2Avoidance_setHigh([110]) set the flight height as
  8. ghost2Avoidance_setVXYZ([0, 0, 0, 10, 0, 0]) set the drone to fly
  9. ghost2Avoidance_setYaw([1, 90]) yaw the drone
  10. ghost2Avoidance_takeOff() take off


I. Brief Intro The python programming in LiteBeeGo can be applied for both LiteBee Wing and Ghost II, and it works with different modes such as drone only, obstacle avoiding, formation, and line tracking. Each Python instruction corresponds to the graphic code of scratch mode, and there will be an explanation when you input the relevant instructions. Details will be list in Chapter 3.

II. Basic operation and examples
1.Basic operation

Just as the picture shows, we can start LiteBeeGo and click “python” to enter the interface of Python. Connect the drone with the computer, then click "run" to execute the Python program


Hover the mouse on the “run” button to choose other operations such as Open, Save, and Stop. Attention, for easy to find and open, suffix it as “.py” when saving the file.
2.Example import time

Excepting formation, all the programming mode have to apply the “import time” to give a time for executing the mission.

For example:

 import time  				//Write “import time” in the first line
 litebeeWing_calibration()	//calibrate
 litebeeWing_takeOff()  	take off
 time.sleep(10)  			//wait 10s
 litebeeWing_autoland()		//land

Conditional and loop statement
Conditional and loop statement is needed when using these instructions, such as “if-elif-else”, “for”, “while”, here is an example:

import time							//import execution time
 litebeeWing_calibration()				//calibration
 time.sleep(5)							//wait 5s
 litebeeWing_takeOff()					//take off
 time.sleep(5)							//wait 5s
if litebeeWing_getVol() > 7.5:				//if litebee’s voltage >7.5v
   litebeeWing_setHigh([50])			//set the flight height as 50cm
while True:							//execute “while” loop
   if litebeeWing_getVol() < 7.2:			//if litebee’s voltage < 7.2v
       litebeeWing_autoLand()			//land
       break;						//break the loop

Formation example

When we program for a formation, we need to program for each drone; take a 2 drones formation as an example:
litebeeWingFormation_flightnum([1])		//program for drone No. 1
litebeeWingFormation_calibration([5])		//calibrate for 5s
litebeeWingFormation_takeOff([100,5])	        //fly to the height 100cm in 5s
litebeeWingFormation_code([10,5])		//move to QR code No.10 in 5s
litebeeWingFormation_RGB([1])			//red light on
litebeeWingFormation_autoLand()		//land
litebeeWingFormation_flightnum([2])		//program for drone No.2
litebeeWingFormation_calibration([5])		//calibrate for 5s
litebeeWingFormation_takeOff([100,5])	        //fly to the height 100cm in 5s
litebeeWingFormation_code([20,5])		//move to the QR code No. 20 in 5s
litebeeWingFormation_RGB([2])			//green light on
litebeeWingFormation_autoLand()		//land
litebeeWingFormation_missionSend()  	//send these mission to drones
time.sleep(3)							//wait 3 s
litebeeWingFormation_missionStart()		//start the mission

III. Instruction explanation Note: p1, p2, p3, p4 are the parameter after the instruction (from left to right). And those instructions without parameter can be use directly. litebeeWing_setDir([0, 10, 1, 20]) Set the drone to fly horizontally

  1. p1: 0 - left; 1 - right
  2. p2: 0 ~ 100 cm/s for left/right
  3. p3: 0 - forward; 1 - backward
  4. p4: 0 ~ 100 cm/s for forward/backward

The following are relevant instructions and their explanation

1.litebeeWing

litebeeWing_calibration()  calibrate
litebeeWing_autoLand()	  land
litebeeWing_getAnglePitch()  the angle of pitch is
litebeeWing_getAngleRoll()  the angle of roll is
litebeeWing_getAngleYaw() the angle of yaw is
litebeeWing_getHigh()  the flight height is
litebeeWing_getVol() the voltage is
litebeeWing_setBuzzer(['E4', 0.5])  set for the buzzer
  1. p1: scale

It can be:

['B0', 'C1', 'CS1', 'D1','DS1', 'E1', 'F1', 'FS1','G1', 'GS1', 'A1', 'AS1','B1', 'C2', 'CS2', 'D2',

'DS2', 'E2', 'F2', 'FS2','G2', 'GS2', 'A2', 'AS2','B2', 'C3', 'CS3', 'D3','DS3', 'E3', 'F3', 'FS3', 'G3', 'GS3', 'A3', 'AS3','B3', 'C4', 'CS4', 'D4','DS4', 'E4', 'F4', 'FS4','G4', 'GS4', 'A4', 'AS4', 'B4', 'C5', 'CS5', 'D5','DS5', 'E5', 'F5', 'FS5','G5', 'GS5', 'A5', 'AS5','B5', 'C6', 'CS6', 'D6', 'DS6', 'E6', 'F6', 'FS6','G6', 'GS6', 'A6', 'AS6','B6', 'C7', 'CS7', 'D7','DS7', 'E7', 'F7', 'FS7', 'G7', 'GS7', 'A7', 'AS7','B7', 'C8', 'CS8', 'D8', 'DS8']

  1. p2: metre

It can be:

  1. 0.5 ,1 ,1.5 ,2 ,2.5

litebeeWing_setDir([0, 0, 0, 10]) set the drone to fly horizontally

  1. p1: 0 - left; 1 - right
  2. p2: speed 0-100 cm/s for left/right
  3. p3: 0 - forward; 1 - backward
  4. p4: speed 0-100 cm/s for forward/backward

litebeeWing_setHigh([110]) Set flight height: #cm litebeeWing_setMotor([1, 50]) rotor test It’s invalid to test the rotor when drone is flying; the advised rev is 5~50rpm for the test

  1. p1: which rotor
  2. p2: rev

litebeeWing_setRGBLed([1, 255, 255, 255]) Set for the LED module

  1. p1: which LED
  2. p2: value of red 0~255
  3. p3: value of green 0~255
  4. p4: value of blue 0~255

litebeeWing_setYaw([1, 90]) Yaw the drone

  1. p1: 1 - cw: 2 - ccw
  2. p2: angle for rotation

litebeeWing_takeOff() take off

2.litebeeWingAvoidance With obstacle avoiding mode litebeeWingAvoidance_autoLand() land litebeeWingAvoidance_backward() Sense the obstacle behind

  1. it is invalid when the value is 0(max sense range:240cm)

litebeeWingAvoidance_calibration() calibrate litebeeWingAvoidance_center() Sense the obstacle below

  1. it is invalid when the value is 0(max sense range:240cm)

litebeeWingAvoidance_forward() Sense the obstacle ahead

  1. it is invalid when the value is 0(max sense range:240cm)

litebeeWingAvoidance_left() Sense the obstacle on the left

  1. it is invalid when the value is 0(max sense range:240cm)

litebeeWingAvoidance_right() Sense the obstacle on the right

  1. it is invalid when the value is 0(max sense range:240cm)

litebeeWingAvoidance_setDir([0, 0, 0, 10]) Set the drone to fly horizontally

  1. p1: 0 - left; 1 - right
  2. p2: 0 ~ 100 cm/s for left/right
  3. p3: 0 - forward; 1 - backward
  4. p4: 0 ~ 100 cm/s for forward/backward

litebeeWingAvoidance_setHigh([110]) Set the flight height litebeeWingAvoidance_setVXYZ([0, 0, 0, 10, 0, 0]) Set the drone to fly freely

  1. p1: 0 - left; 1 - right
  2. p2: 0 ~ 100 cm/s for left/right
  3. p3: 0 - forward; 1 - backward
  4. p4: 0 ~ 100 cm/s for forward/backward
  5. p5: 0 - up; 1 - down
  6. p6: 0~100 cm/s for up/down

litebeeWingAvoidance_setYaw([1, 90]) Yaw the drone

  1. p1: 1 - cw; 2 - ccw
  2. p2: degree of yaw

litebeeWingAvoidance_takeOff() take off

3.litebeeWingFormation formation litebeeWingFormation_allLand() crash-land

  1. crash-land can be used for every drone, and it prior to other instruction

litebeeWingFormation_autoLand() land litebeeWingFormation_calibration([5]) calibrate

  1. p1: # s for execution time

litebeeWingFormation_circle([66, 77, 0, 2, 15]) circle

  1. p1: QR code No. #
  2. p2: QR code No. #
  3. p3: 0 - cw; 1 - ccw
  4. p4: # half-circle
  5. the drone circle around the point between #p1 and #p2, circle 2 semicircle, the drone will fly back to the origin

litebeeWingFormation_circleZ([66, 77, 0, 150, 15]) half-circle and adjust its height

  1. p1: QR code No. #
  2. p2: QR code No. #
  3. p3: 0 - cw; 1 - ccw
  4. p4: fly up for # cm
  5. p5: in # seconds
  6. the drone will take the mid-point between #p1 and #p2 as the center and circle #p5 half-circle, meanwhile fly up for #p4 cm

litebeeWingFormation_clear() reset all setting litebeeWingFormation_code([66, 10]) move to QR code

  1. p1: move to QR code No. #p1
  2. p2: in #p2 seconds

litebeeWingFormation_codeS(['12 23 27', 15]) move in order

  1. p1: move to QR code No.#, No.#, No.#, No.#, No.#, one by one
  2. p2: execution time #s

litebeeWingFormation_codeZ([66, 120, 10]) Move to QR code No. #p1 and adjust its height to #p2 in #p3 seconds litebeeWingFormation_flightNum([1]) Set for drone No.# litebeeWingFormation_missionSend() Send the mission to drone

  1. wait a few seconds after the mission sent

litebeeWingFormation_missionStart() Mission start litebeeWingFormation_RGB([1]) Set the color of the LED module

  1. p1: set the LED light as #p1: 0 - black; 1 - red; 2 - green; 3 - yellow; 4 - blue; 5 - purple; 6 - cyan; 7 - white

litebeeWingFormation_setZ([100, 3]) Set the flight height

  1. p1: height #p1 cm
  2. p2: execution time #p2 second

litebeeWingFormation_takeOff([100, 5]) Take off

  1. p1: height of take-off #p1 cm
  2. p2: execution time #p2 seconds


4.litebeeWingLine Line tracking litebeeWingLine_autoLand() land litebeeWingLine_calibration() calibrate litebeeWingLine_color() The color of the line

  1. the value can be: R: red; G: green; B: blue
  2. for example: if litebeewingline_color() == ‘R’

litebeeWingLine_control([1, 15]) Line tracking control

  1. p1: it can be: 0 - yaw; 1 - speed; 2 - height
  2. p2: corresponding value # degree; #cm/s; #cm

litebeeWingLine_crossDetrct() At the crossroad litebeeWingLine_crossX() Distance from the cross-point in X-axis litebeeWingLine_crossY() Distance from the cross-point in Y-axis litebeeWingLine_open() Open the line tracking mode

litebeeWingLine_setRGBLed([1, 255, 255, 255]) Set for the LED module

  1. p1: LED No. #p1
  2. p2: value of R 0~255
  3. p3: value of G 0~255
  4. p4: value of B 0~255

litebeeWingLine_takeOff() Take off

litebeeWingLine_type() The type of line tracking is

  1. the value and its corresponding type of line tracking

FRLR //route of tracking is ┼ FBL //route of tracking is ┤ FBR //route of tracking is ├ BL //route of tracking is ┃ BR //route of tracking is ┐ B //route of tracking is ┌

  1. 如: if litebeeWingLine_type() == “FBLR”

5.ghost2 Drone only ghost2_autoLand() land ghost2_calibration() calibrate ghost2_getAnglePitch() the angle of pitch is ghost2_getAngleRoll() the angle of roll is ghost2_getAngleYaw() the angle of yaw is ghost2_getHigh() The flight height is ghost2_getVol() the voltage is ghost2_setDir([1, 1]) set the drone to fly

  1. p1: 1- forward; 2- backward; 3- right; 4- right; 5- up; 5:down: 7- stop
  2. p2: speed 1 - slow; 2 - normal; 3 - fast

ghost2_setHigh([110]) Set flight height as # cm ghost2_setMotor([1, 50]) test the rotor

  1. it’s invalid to test the rotor when the drone is flying. Recommended test rev: 5~50
  2. p1: which rotor
  3. p2: rev

ghost2_setYaw([1, 90]) yaw the drone

  1. p1: yaw 1 - cw; 2 - ccw
  2. p2: degree of yaw

ghost2_takeOff() take off

6.ghost2Avoidance Obstacle avoiding mode ghost2Avoidance_autoLand() land ghost2Avoidance_backward() Sense the obstacle behind

  1. it is invalid when the value is 0(max sense range:240cm)

ghost2Avoidance_calibration() calibration ghost2Avoidance_center() Sense the distance from the obstacle above

  1. it is invalid when the value is 0(max sense range:240cm)

ghost2Avoidance_forward() Sense the distance from the obstacle ahead

  1. it is invalid when the value is 0(max sense range:240cm

ghost2Avoidance_left() Sense the distance from the obstacle on the left

  1. it is invalid when the value is 0(max sense range:240cm)

ghost2Avoidance_right() Sense the distance from the obstacle on the left

  1. it is invalid when the value is 0(max sense range:240cm)

ghost2Avoidance_setDir([0, 0, 0, 10]) Set the drone fly horizontally

  1. p1: 0 - left; 1 - right
  2. p2: 0 ~ 100 cm/s for left/right
  3. p3: 0 - forward; 1 - backward
  4. p4: 0 ~ 100 cm/s for forward/backward

ghost2Avoidance_setHigh([110]) Set the flight height ghost2Avoidance_setVXYZ([0, 0, 0, 10, 0, 0]) Set the drone to fly freely

  1. p1: 0 - left; 1 - right
  2. p2: 0 ~ 100 cm/s for left/right
  3. p3: 0 - forward; 1 - backward
  4. p4: 0 ~ 100 cm/s for forward/backward
  5. p5: 0 - up; 1 - down
  6. p6: 0~100 cm/s for up/down

ghost2Avoidance_setYaw([1, 90]) Yaw the drone

  1. p1: yaw 1- cw; 2 - ccw
  2. p2: degree of yaw

ghost2Avoidance_takeOff() Take off