mirror of
https://bitbucket.org/myhomie/mycorerepository.git
synced 2025-12-06 09:41:19 +00:00
67 lines
2.0 KiB
Python
67 lines
2.0 KiB
Python
"""
|
|
Demo the trick flying for the python interface
|
|
|
|
Author: Amy McGovern
|
|
"""
|
|
|
|
from pyparrot.Minidrone import Mambo
|
|
|
|
# If you are using BLE: you will need to change this to the address of YOUR mambo
|
|
# if you are using Wifi, this can be ignored
|
|
mamboAddr = "e0:14:d0:63:3d:d0"
|
|
|
|
# make my mambo object
|
|
# remember to set True/False for the wifi depending on if you are using the wifi or the BLE to connect
|
|
mambo = Mambo(mamboAddr, use_wifi=True)
|
|
|
|
print("trying to connect")
|
|
success = mambo.connect(num_retries=3)
|
|
print("connected: %s" % success)
|
|
|
|
if (success):
|
|
# get the state information
|
|
print("sleeping")
|
|
mambo.smart_sleep(2)
|
|
mambo.ask_for_state_update()
|
|
mambo.smart_sleep(2)
|
|
|
|
print("taking off!")
|
|
mambo.safe_takeoff(5)
|
|
|
|
if (mambo.sensors.flying_state != "emergency"):
|
|
print("flying state is %s" % mambo.sensors.flying_state)
|
|
print("Flying direct: going up")
|
|
mambo.fly_direct(roll=0, pitch=0, yaw=0, vertical_movement=20, duration=1)
|
|
|
|
print("flip left")
|
|
print("flying state is %s" % mambo.sensors.flying_state)
|
|
success = mambo.flip(direction="left")
|
|
print("mambo flip result %s" % success)
|
|
mambo.smart_sleep(5)
|
|
|
|
print("flip right")
|
|
print("flying state is %s" % mambo.sensors.flying_state)
|
|
success = mambo.flip(direction="right")
|
|
print("mambo flip result %s" % success)
|
|
mambo.smart_sleep(5)
|
|
|
|
print("flip front")
|
|
print("flying state is %s" % mambo.sensors.flying_state)
|
|
success = mambo.flip(direction="front")
|
|
print("mambo flip result %s" % success)
|
|
mambo.smart_sleep(5)
|
|
|
|
print("flip back")
|
|
print("flying state is %s" % mambo.sensors.flying_state)
|
|
success = mambo.flip(direction="back")
|
|
print("mambo flip result %s" % success)
|
|
mambo.smart_sleep(5)
|
|
|
|
print("landing")
|
|
print("flying state is %s" % mambo.sensors.flying_state)
|
|
mambo.safe_land(5)
|
|
mambo.smart_sleep(5)
|
|
|
|
print("disconnect")
|
|
mambo.disconnect()
|