Intro to Python SDK

Now let’s look at some code scripts to learn from and test your X-Fly Drone.

Development Environment

  • All SDK files can be edited using any text editor, such as Microsoft Notepad. However, using advanced editors like VS Code or PyCharm is preferred and will make the development process easier.
  • The main.py module serves as the entry point for controlling the drone through various high-level functions.
  • Although all .py files are editable, it is recommended to focus only on the main.py file for customizations, while leaving other files unchanged. All functions from the other files can still be accessed through main.py.

Main Commands

commander.py contains all the commands to require to control the drone. Inside the main function of the main.py file, you can execute any of the below command. Before each command, add commander. part to indicate that these commands belong to the commander class.

  • altitudeHoldFlying(set_height, roll, pitch, yaw_rate): Activates altitude hold mode, allowing the drone to maintain a specified altitude while responding to roll, pitch, and yaw rate commands.
    • set_height (float): The desired altitude for the drone to hold, between 0.0 to 2.0 meters.
    • roll (int): The roll angle input as described above.
    • pitch (int): The pitch angle input as described above.
    • yaw_rate (int): The yaw rate input as described above.

 

  • takeoff(set_height): Initiates the drone’s takeoff sequence, automatically ascending to a specified height.
    • set_height (float, optional): The target altitude for takeoff, defaulting to 0.5 meters if not specified.

 

  • land(): Commands the drone to initiate the landing sequence and safely descend to the ground.

 

  • setHeight(set_height): Sets the drone’s flight height to a specified value. It uses the same altitude hold principles.
    • set_height (float): The desired altitude for the drone to reach, which must be between 0.0 to 2.0 meters.
 
  • goForward(set_vel, set_time)
  • goBackward(set_vel, set_time)
  • goLeft(set_vel, set_time)
  • goRight(set_vel, set_time): Directs the drone to move linearly in the specified direction using the given velocity and for the specified time.
    • set_vel (float|int): The velocity at which the drone should move.
    • set_time (float): The duration for which the movement should be maintained.

QubeBots Pvt Ltd is a startup that focuses on developing Edutech products to support the global STEM Education system.

Contact us

hello@qubebots.com

+94 77 069 5151

Colombo, Sri Lanka

Shopping Cart
Scroll to Top