Function Documentation
version 1.1.3 (Changelog)
Connection
pair()
Description
This function connects your controller with the program. You can set debug equal to True if you want to see helpful print statements that can help you debug your code. We recommend setting this to True to check if commands are being skipped. You can also set the specific USB port name.
Syntax
pair()
pair(port_name)
pair(debug=False)
pair(debug=False, port_name)
Parameters
string port_name: the port name or number.
boolean debug: Defaults to False. True to see helpful print statements for debugging
Returns
None
Example Code
Python
#Python code
import CoDrone_mini
drone = CoDrone_mini.CoDrone()
drone.pair() # pair automatically, may not always work
# drone.pair(debug=True) # sets the debug statements to True
# drone.pair(port_name = 'COM3') # pair with a specific port
drone.takeoff()
drone.hover(3)
drone.land()
drone.close()
Flight Commands (Start/Stop)
emergency_stop()
Description
This function immediately stops all commands and motors, so the drone will stop flying immediately. The function will also reset the flight motion variables to 0. NOTE: If you want to take off and emergency stop, it is recommended to run a hover() or time.sleep() in between the takeoff() and emergency_stop(), because the CoDrone Mini might miss the emergency_stop() command.
Syntax
emergency_stop()
Parameters
None
Returns
None
Example Code
Python
#Python code
import CoDrone_mini
import time
drone = CoDrone_mini.CoDrone()
drone.pair()
drone.takeoff()
drone.hover(3) #Recommended to have a hover() or time.sleep(1) before landing
drone.emergency_stop()
drone.close()
headless_off()
Description
This function turns off headless mode. In this mode, the drone is keeping track of which direction it's facing and will fly relative to which direction it is facing. Remember that the "front" is denoted by the red line on the shell.
Syntax
headless_off()
Parameters
None
Returns
None
Example Code
Python
#Python code
import CoDrone_mini
import time
drone = CoDrone_mini.CoDrone()
drone.pair()
drone.headless_on() # Run the code once, then switch to headless_off() and run again to see the difference.
drone.takeoff()
drone.set_yaw(20)
drone.move(1)
drone.set_yaw(0)
drone.set_pitch(40)
drone.move(1)
drone.land()
drone.close()
headless_on()
Description
This function turns on headless mode, meaning that no matter in which direction the drone is facing, it will fly in the directions relative to you. This is ideal for long range drones.
Syntax
headless_on()
Parameters
None
Returns
None
Example Code
Python
#Python code
import CoDrone_mini
import time
drone = CoDrone_mini.CoDrone()
drone.pair()
drone.headless_on() # Run the code once, then switch to headless_off() and run again to see the difference.
drone.takeoff()
drone.set_yaw(20)
drone.move(1)
drone.set_yaw(0)
drone.set_pitch(40)
drone.move(1)
drone.land()
drone.close()
land()
Description
This function makes the drone stop all commands, hover, and make a soft landing where it is. The function will also reset the flight motion variables to 0. NOTE: If you want to take off and immediately land, it is recommended to run a hover() or time.sleep() in between the takeoff() and land(), because the CoDrone Mini will often miss the land command otherwise.
Syntax
land()
Parameters
None
Returns
None