img = self.vision.get_latest_valid_picture() if (img is not None): filename = "test_image_%06d.png" % self.index cv2.imwrite(filename, img) self.index += 1 #print(self.index) # you will need to change this to the address of YOUR mambo 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 to mambo now") success = mambo.connect(num_retries=3) print("connected: %s" % success) if (success): # get the state information print("sleeping") mambo.smart_sleep(1) mambo.ask_for_state_update() mambo.smart_sleep(1) print("Preparing to open vision") mamboVision = DroneVision(mambo, is_bebop=False, buffer_size=30) userVision = UserVision(mamboVision) mamboVision.set_user_callback_function(userVision.save_pictures,
''' Demo of the groundcam Mambo takes off, takes a picture and shows a RANDOM frame, not the last one Author: Valentin Benke, https://github.com/Vabe7 ''' from pyparrot.Mambo import Mambo import cv2 import time mambo = Mambo( None, use_wifi=True) #address is None since it only works with WiFi anyway print("trying to connect to mambo now") success = mambo.connect(num_retries=3) print("connected: %s" % success) if (success): # get the state information print("sleeping") mambo.smart_sleep(1) mambo.ask_for_state_update() mambo.smart_sleep(1) mambo.safe_takeoff(5) mambo.take_picture() list = mambo.groundcam.get_groundcam_pictures_names( ) #get list of availible files frame = mambo.groundcam.get_groundcam_picture( list[0], True) #get frame which is the first in the array if frame is not None: if frame is not False: cv2.imshow("Groundcam", frame) cv2.waitKey(100)
""" Demo the claw for the python interface """ from pyparrot.Mambo import Mambo # you will need to change this to the address of YOUR mambo mamboAddr = "e0:14:d0:63:3d:d0" # make my mambo object # remember you can't use the claw with the camera installed so this must be BLE connected to work mambo = Mambo(mamboAddr, use_wifi=False) print("trying to connect") success = mambo.connect(num_retries=3) print("connected: %s" % 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) print("open and close the claw") mambo.open_claw() # you have to sleep to let the claw open (it needs time to do it) mambo.smart_sleep(5)
print("Ending the sleep and vision") mamboVision.close_video() mambo.smart_sleep(5) print("disconnecting") mambo.disconnect() if __name__ == "__main__": # you will need to change this to the address of YOUR mambo 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 to mambo now") success = mambo.connect(num_retries=3) print("connected: %s" % success) if (success): # get the state information print("sleeping") mambo.smart_sleep(1) mambo.ask_for_state_update() mambo.smart_sleep(1) print("Preparing to open vision") mamboVision = DroneVisionGUI( mambo, is_bebop=False,
def launchMambo(): mambo = Mambo(mamboAddr, use_wifi=False) print("Connecting to mambo...") success = mambo.connect(num_retries=3) print("Connected: %s" % success) if (success): print("Initial Sleeping") mambo.smart_sleep(2) mambo.ask_for_state_update() mambo.smart_sleep(2) print("***Mission Started!*** \n") print("0. Close Claw") mambo.close_claw() mambo.smart_sleep(2) print("1. Taking off") mambo.safe_takeoff(2) mambo.smart_sleep(2) print("2. Rotating -45 degress anti-clock in-place") mambo.turn_degrees(-45) mambo.smart_sleep(2) print("3. Moving Forward 50") mambo.fly_direct(roll=0, pitch=100, yaw=0, vertical_movement=30, duration=1) mambo.smart_sleep(2) print("4. Open Claw") mambo.open_claw() mambo.smart_sleep(3) print("5. Close Claw") mambo.close_claw() mambo.smart_sleep(3) print("6. Rotating 180 degress anti-clock in-place") mambo.turn_degrees(180) mambo.smart_sleep(2) print("7. Moving Forward 50") mambo.fly_direct(roll=0, pitch=100, yaw=0, vertical_movement=-30, duration=1) mambo.smart_sleep(2) print("8. Rotating -135 degress anti-clock in-place") mambo.turn_degrees(-135) mambo.smart_sleep(2) print("9. Landing") mambo.safe_land(5) mambo.smart_sleep(3) print("***Mission Completed!***\n") print("Disconnecting mambo...") mambo.disconnect()
""" Demo the gun for the python interface """ from pyparrot.Mambo import Mambo # you will need to change this to the address of YOUR mambo mamboAddr = "e0:14:d0:63:3d:d0" # make my mambo object # remember you can't use the gun with the camera installed so this must be BLE connected to work mambo = Mambo(mamboAddr, use_wifi=False) print("trying to connect") success = mambo.connect(num_retries=3) print("connected: %s" % success) # get the state information print ("sleeping") mambo.smart_sleep(2) mambo.ask_for_state_update() mambo.smart_sleep(2) print("shoot the gun") mambo.fire_gun() # sleep to ensure it does the firing mambo.smart_sleep(15) print("disconnect") mambo.disconnect()
""" Demo the direct flying for the python interface """ from pyparrot.Mambo import Mambo # you will need to change this to the address of YOUR mambo 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) print("Flying direct: going forward (positive pitch)") mambo.fly_direct(roll=0, pitch=50, yaw=0, vertical_movement=0, duration=1) print("Showing turning (in place) using turn_degrees")