Esempio n. 1
0
    def __init__(self,
                 test_flying,
                 mambo_addr,
                 use_wifi=True,
                 use_vision=True):
        """
        Constructor for the Drone Superclass.
        When writing your code, you may redefine __init__() to have additional
        attributes for use in processing elsewhere. If you do this, be sure to
        call super().__init__() with relevant args in order properly
        initialize all mambo-related things.

        test_flying:    bool : run flight code if True
        mambo_addr:     str  : BLE address of drone
        use_wifi:       bool : connect with WiFi instead of BLE if True
        use_vision:     bool : turn on DroneVisionGUI module if True
        """
        self.test_flying = test_flying
        self.use_wifi = use_wifi
        self.use_vision = use_vision
        self.mamboAddr = mambo_addr
        self.mambo = Mambo(self.mamboAddr, use_wifi=self.use_wifi)

        self.mambo.set_user_sensor_callback(self.sensor_cb, args=None)
        if self.use_vision:
            self.mamboVision = DroneVisionGUI(
                self.mambo,
                is_bebop=False,
                buffer_size=200,
                user_code_to_run=self.flight_func,
                user_args=None)
            self.mamboVision.set_user_callback_function(
                self.vision_cb, user_callback_args=None)
    def __init__(self, mac_address, debug=False, mock=False):
        self.flying = False
        self.commands = Queue()
        if not mock:
            self.drone = Mambo(mac_address)
        self.debug = debug
        self.mock = mock

        def done():
            self.drone.safe_land(5)
            self.flying = False

        self.code_to_command = {
            0: (lambda: done()),
            1: (lambda: self.drone.safe_takeoff(5)),  # takeoff
            2: (lambda: self.drone.safe_land(5)),  # land
            3: (lambda: self.drone.fly_direct(0, 10, 0, 0, 1)),  # forward
            4: (lambda: self.drone.fly_direct(0, -10, 0, 0, 1)),  # backward
            5: (lambda: self.drone.fly_direct(-10, 0, 0, 0, 1)),  # left
            6: (lambda: self.drone.fly_direct(10, 0, 0, 0, 1)),  # right
            7: (lambda: self.drone.fly_direct(0, 0, 0, 10, 1)),  # up
            8: (lambda: self.drone.fly_direct(0, 0, 0, -10, 1)),  # down
            9: (lambda: self.drone.turn_degrees(-45)),  # turn left
            10: (lambda: self.drone.turn_degrees(45)),  # turn right
            11: (lambda: self.drone.flip("front")),  # flip forward
            12: (lambda: self.drone.flip("back")),  # flip backward
            13: (lambda: self.drone.flip("right")),  # flip right
            14: (lambda: self.drone.flip("left")),  # flip left
        }
        if mock:
            self.process_command = lambda c: print(F"Mock execute: {c}")
        else:
            self.process_command = lambda c: self.code_to_command[
                c.command_code]()
Esempio n. 3
0
 def droneConnect(self):
     self.mamboAddr, self.mamboName = findMinidrone.getMamboAddr()
     self.mambo = Mambo(self.mamboAddr, use_wifi=False)
     self.droneCheck = self.mambo.connect(num_retries=3)
     print("Drone Connect: ", self.droneCheck)
     self.mambo.smart_sleep(2)
     self.mambo.ask_for_state_update()
     self.mambo.set_max_tilt(1)
Esempio n. 4
0
 def droneConnect(self):
     # 일반 패키지의 경우에만 사용하며, 블루투스를 통해 드론을 찾는다
     self.mamboAddr, self.mamboName = findMinidrone.getMamboAddr()
     # FPV의 경우 use_wifi=True, 일반 패키지의 경우 use_wifi=False
     self.mambo = Mambo(self.mamboAddr, use_wifi=False)
     self.droneCheck = self.mambo.connect(num_retries=3)
     print("Drone Connect: ", self.droneCheck)
     self.mambo.smart_sleep(2)
     # 드론의 상태를 받아온다 최초 1회만 하면 됨
     self.mambo.ask_for_state_update()
     self.mambo.set_max_tilt(1)
Esempio n. 5
0
    def __init__(self, command_queue, **kwargs):
        self.queue = command_queue
        self.is_flying = False
        self.connected = False

        self.droneAddr = kwargs.get('droneAddr', None)
        self.maxPitch = int(kwargs.get('maxPitch') or 50)
        self.maxVertical = int(kwargs.get('maxVertical') or 50)

        if self.droneAddr is None:
            sys.exit()

        # always connect with BT
        self.client = Mambo(self.droneAddr, use_wifi=False)
Esempio n. 6
0
def swarmAssemble():
    global droneList
    fh = open("drones.txt")
    mamboAddr = fh.readlines()

    # CONNECT TO ALL DRONES
    for droneAddr in mamboAddr:
        mambo = Mambo(droneAddr.strip(), use_wifi=False)
        print("trying to connect 1")
        success = mambo.connect(num_retries=3)
        droneList.append(mambo)
        print("connected: %s" % success)

    fh.close()
    def __init__(self, testFlying, mamboAddr, use_wifi):
        self.bb = [0, 0, 0, 0]
        self.bb_threshold = 4000
        self.bb_trigger = False

        self.testFlying = testFlying
        self.mamboAddr = mamboAddr
        self.use_wifi = use_wifi
        self.mambo = Mambo(self.mamboAddr, self.use_wifi)
        self.mamboVision = DroneVisionGUI(
            self.mambo,
            is_bebop=False,
            buffer_size=200,
            user_code_to_run=self.mambo_fly_function,
            user_args=None)
Esempio n. 8
0
    def __init__(self, mac_addr, rs):
        self.mambo = Mambo(mac_addr, use_wifi=False)
        self.requirements = rs

        # positive is east
        self.x = 0
        # positive is up
        self.y = 0
        # positive is south
        self.z = 0
        # Angle of drone from the x axis, so starts north
        self.theta = 90

        info("Trying to connect")
        success = self.mambo.connect(num_retries=3)
        info("Connected: %s" % success)
    def setUp(self):
        # 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:B1:35:3D:CB"  # "E0:14:F1:84:3D:CA"

        # 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)
        # dronestates = MamboStateOne(mamboAddr, use_wifi=True)

        print("trying to connect")
        success = mambo.connect(num_retries=3)
        print("connected: %s" % success)

        self.mambo = mambo

        self.state_estimator = NewStateEstimator(mambo)
Esempio n. 10
0
    def __init__(self):
        self.host_name = rospy.get_param('~name')
        self.host_mac = rospy.get_param('~mac')
        self.service_connect = rospy.Service(
            '/mambo_srv/' + self.host_name + '/connect', Connect,
            self.handle_connect)
        self.service_take_off = rospy.Service(
            '/mambo_srv/' + self.host_name + '/takeoff', Connect,
            self.handle_takeoff)
        self.service_land = rospy.Service(
            '/mambo_srv/' + self.host_name + '/land', Connect,
            self.handle_land)
        self.sub_disconnect = rospy.Subscriber(
            '/mambo_srv/' + self.host_name + '/disconnect', String,
            self.callback_disconnect)
        self.sub_fly_command = rospy.Subscriber(
            '/mambo_srv/' + self.host_name + '/fly_command', AttitudeTarget,
            self.callback_fly_command)

        self.mambo = Mambo(self.host_mac, use_wifi=False)
Esempio n. 11
0
def talker():
    # Start node
    rospy.init_node('mambo_central', anonymous=True)

    # Publishers
    pub_mambo_01 = rospy.Publisher('/mambo_01/odom', nav_msgs.msg.Odometry, queue_size=1)
    pub_mambo_02 = rospy.Publisher('/mambo_02/odom', nav_msgs.msg.Odometry, queue_size=1)

    # 20Hz
    rate = rospy.Rate(20)

    # Enderecos MAC dos Mambos
    bt_mac_01 = "d0:3a:de:8a:e6:37"
    bt_mac_02 = "d0:3a:82:0a:e6:21"

    # Objetos dos drones
    drone_01 = Mambo(address=bt_mac_01, use_wifi=False)
    drone_02 = Mambo(address=bt_mac_02, use_wifi=False)

    # Conectar aos drones
    success_01 = drone_01.connect(num_retries=3)
    success_02 = drone_02.connect(num_retries=3)

    if success_01 & success_02:
        # Objetos para publicar nos topicos
        data_mano_01 = nav_msgs.msg.Odometry()
        data_mano_02 = nav_msgs.msg.Odometry()

        # Main loop
        while not rospy.is_shutdown() :
            data_mano_01.twist.twist.linear.x = drone_01.sensors.speed_x
            data_mano_01.twist.twist.linear.y = drone_01.sensors.speed_y
            data_mano_01.twist.twist.linear.z = drone_01.sensors.speed_z
            # data_mano_01.pose.pose.orientation.w = drone_01.sensors.get_estimated_z_orientation()
            data_mano_01.pose.pose.position.x = drone_01.sensors.position_x
            data_mano_01.pose.pose.position.y = drone_01.sensors.position_y
            data_mano_01.pose.pose.position.z = drone_01.sensors.position_z
            data_mano_01.pose.pose.orientation.w = drone_01.sensors.position_psi
            # data_mano_01.pose.pose.position.z = drone_01.sensors.altitude
            data_mano_02.twist.twist.linear.x = drone_02.sensors.speed_x
            data_mano_02.twist.twist.linear.y = drone_02.sensors.speed_y
            data_mano_02.twist.twist.linear.z = drone_02.sensors.speed_z
            # data_mano_02.pose.pose.orientation.w = drone_02.sensors.get_estimated_z_orientation()
            data_mano_02.pose.pose.position.x = drone_02.sensors.position_x
            data_mano_02.pose.pose.position.y = drone_02.sensors.position_y
            data_mano_02.pose.pose.position.z = drone_02.sensors.position_z
            data_mano_02.pose.pose.orientation.w = drone_02.sensors.position_psi
            # data_mano_02.pose.pose.position.z = drone_02.sensors.altitude
            rospy.loginfo(data_mano_01)
            rospy.loginfo(data_mano_02)
            pub_mambo_01.publish(data_mano_01)
            pub_mambo_02.publish(data_mano_02)
            rate.sleep()
def main():
    bebop2 = Bebop()
    bebop1 = Bebop(drone_type="Bebop")
    mac = None  # ToDo
    mambo = Mambo(mac, use_wifi=True)
    #swing = Swing(mac)
    drone_list = [bebop2, bebop1, mambo]
    for drone in drone_list:
        print("Trying to connect to %s drone..." % 'TODO')
        success = drone.connect(
            10)  # attempts to connect to the drone, success is Boolean
        if success:
            print("Successfully Connected to drone!")
            print("Sleeping")
            drone.smart_sleep(3)
            print("Ready!")
            drone.ask_for_state_update()

            controller(drone)

    print("Could not connect to a drone.")
Esempio n. 13
0
# this is the page for experimenting with various takeoff methods.

from pyparrot.Minidrone import Mambo

mamboAddr = "e0:14:bc:c5:3d:cb"

mambo = Mambo(mamboAddr, use_wifi=False)

print("attempting connection")
success = mambo.connect(num_retries=3)
print("connected: %s" % success)

if (success):
    print("sleeping")
    mambo.smart_sleep(2)
    mambo.ask_for_state_update()
    mambo.smart_sleep(2)

    print("taking off")
    mambo.safe_takeoff(5)
    mambo.smart_sleep(5)

    print("hovering")
    mambo.hover()
    mambo.smart_sleep(5)

    print("landing")
    mambo.safe_land(5)
    mambo.smart_sleep(5)

    print("disconnecting")
Esempio n. 14
0
#init
from pyparrot.Minidrone import Mambo
import cv2
# 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 = "d0:3a:d1:dc:e6:20"

# 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=False)

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(1)
    mambo.ask_for_state_update()
    mambo.smart_sleep(1)
    mambo.safe_takeoff(5)
    # take the photo
    pic_success = mambo.take_picture()
    # need to wait a bit for the photo to show up
    mambo.smart_sleep(0.5)
    picture_names = mambo.groundcam.get_groundcam_pictures_names(
    )  #get list of

    print(picture_names)
    frame = mambo.groundcam.get_groundcam_picture(picture_names[0],
Esempio n. 15
0
"""
Demo the trick flying for the python interface

Author: Amy McGovern
"""

from pyparrot.Minidrone import Mambo
from pyparrot.networking.bleConnection import BLEConnection
BLEAvailable = True
# 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=False)

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)
Esempio n. 16
0
"""
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
Author: Amy McGovern
"""

from pyparrot.Minidrone import Mambo
import cv2

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)

    # take the photo
    pic_success = mambo.take_picture()

    # need to wait a bit for the photo to show up
    mambo.smart_sleep(0.5)

    picture_names = mambo.groundcam.get_groundcam_pictures_names() #get list of availible files
    print(picture_names)
Esempio n. 17
0
from sense_hat import SenseHat
from pyparrot.Minidrone import Mambo
import sys

sense = SenseHat()
# Change this to the address of the mambo
mamboAddr = ""
# Set True/False for the wifi depending on if you are using the wifi or the BLE to

mambo = Mambo(mamboAddr, use_wifi=False)
print("trying to connect")
success = mambo.connect(num_retries=3)
print("connected: %s" % success)

try:
    if (success):
         # get the state information
     print("sleeping")
     def takeoff():
         mambo.smart_sleep(2)
         print("taking off!")
         mambo.safe_takeoff(5)

     def land():
         mambo.safe_land(5)
         mambo.smart_sleep(5)
         print("disconnect")
         mambo.disconnect()

    while True:
            for event in sense.stick.get_events():
Esempio n. 18
0
    rospy.loginfo(rospy.get_caller_id() + ' flight command: %f' % data.thrust +
                  'successful.')
    success = mambo.fly_direct(roll=data.orientation.x,
                               pitch=data.orientation.y,
                               yaw=0,
                               vertical_movement=data.thrust,
                               duration=0.2)


def mambo_host():
    # Subscribe to the mamboHost<MAC> message.
    name = rospy.get_param('~name')
    s1 = rospy.Service('/mambo_srv/' + name + '/connect', Connect,
                       handle_connect)
    s2 = rospy.Subscriber('/mambo_srv/' + name + '/disconnect', String,
                          disconnectcb)
    s3 = rospy.Service('/mambo_srv/' + name + '/takeoff', Connect,
                       handle_takeoff)
    s4 = rospy.Service('/mambo_srv/' + name + '/land', Connect, handle_land)
    s5 = rospy.Subscriber('/mambo_srv/' + name + '/fly_command',
                          AttitudeTarget, flycb)
    rospy.spin()


if __name__ == '__main__':
    # Initialise the node.
    rospy.init_node('mambo_host', anonymous=True)

    mamboAddr = rospy.get_param('~mac')
    mambo = Mambo(mamboAddr, use_wifi=False)
    mambo_host()
Esempio n. 19
0
from pyparrot.Minidrone import Mambo
from pprint import pprint

bt_mac_01 = "d0:3a:de:8a:e6:37"  #"90:3a:e6:21:82:0a"
bt_mac_02 = "d0:3a:82:0a:e6:21"  #"90:3a:e6:21:82:0a"

drone_01 = Mambo(address=bt_mac_01, use_wifi=False)
drone_02 = Mambo(address=bt_mac_02, use_wifi=False)

print("trying to connect")
success_01 = drone_01.connect(num_retries=3)
success_02 = drone_02.connect(num_retries=3)
print("drone_01 connected: %s " % success_01)
print("drone_02 connected: %s " % success_02)

if (success_01) & success_02:
    # get the state information
    print("test stats")
    drone_01.ask_for_state_update()
    drone_02.ask_for_state_update()
    pprint(vars(drone_01.sensors))
    pprint(vars(drone_02.sensors))

    drone_01.disconnect()
    drone_02.disconnect()

    # print("taking off!")
    # drone.safe_takeoff(5)
    # for i in range(1000) :
    #     drone.ask_for_state_update()
    #     pprint(vars(drone.sensors))
Esempio n. 20
0
class Drone:
    def __init__(self,
                 test_flying,
                 mambo_addr,
                 use_wifi=True,
                 use_vision=True):
        """
        Constructor for the Drone Superclass.
        When writing your code, you may redefine __init__() to have additional
        attributes for use in processing elsewhere. If you do this, be sure to
        call super().__init__() with relevant args in order properly
        initialize all mambo-related things.

        test_flying:    bool : run flight code if True
        mambo_addr:     str  : BLE address of drone
        use_wifi:       bool : connect with WiFi instead of BLE if True
        use_vision:     bool : turn on DroneVisionGUI module if True
        """
        self.test_flying = test_flying
        self.use_wifi = use_wifi
        self.use_vision = use_vision
        self.mamboAddr = mambo_addr
        self.mambo = Mambo(self.mamboAddr, use_wifi=self.use_wifi)

        self.mambo.set_user_sensor_callback(self.sensor_cb, args=None)
        if self.use_vision:
            self.mamboVision = DroneVisionGUI(
                self.mambo,
                is_bebop=False,
                buffer_size=200,
                user_code_to_run=self.flight_func,
                user_args=None)
            self.mamboVision.set_user_callback_function(
                self.vision_cb, user_callback_args=None)

    def execute(self):
        """
        Connects to drone and executes flight_func as well as any vision
        handling when needed.
        Run this after initializing your subclass in your main method to
        start the test/script.
        """
        print("trying to connect to self.mambo now")
        success = self.mambo.connect(num_retries=3)
        print("connected: %s" % success)

        if (success):
            self.mambo.smart_sleep(1)
            self.mambo.ask_for_state_update()
            self.mambo.smart_sleep(1)

            if self.use_vision:
                print("starting vision")
                self.mamboVision.open_video()
            else:
                print("starting flight without vision")
                self.flight_func(None, None)

            if self.use_vision:
                print("ending vision")
                self.mamboVision.close_video()
            self.mambo.smart_sleep(3)
            self.mambo.disconnect()

    def flight_func(self, mamboVision, args):
        """
        Method to me run for flight. This is defined by the user outside of this
        class.
        When writing your code, define a new class for each test that inherits
        this class. Redefine your flight_func in your subclass to match
        your flight plan.
        your redefinition of flight_func must include the mamboVision and args
        arguments to properly work.
        NOTE: after takeoff it is smart to do the following:
            print("sensor calib")
            while self.mambo.sensors.speed_ts == 0:
                continue
        This gives the sensors time to fully initialize and send back proper
        readings for use in your sensor callback method.
        Cannot be done before takeoff; sensors send nothing at this time.
        """
        pass

    def vision_cb(self, args):
        """
        Callback function for every vision-handle update Again, defined by the
        user outside of the class in a specific subclass for every test script.
        Your vision_cb must include the self and args arguments to work.
        """
        pass

    def sensor_cb(self, args):
        """
        Callback function for every sensor update. Again, defined by the
        user outside of the class in a specific subclass for every test script.
        Your sensor_cb must include the self and args arguments to work.
        """
        pass
class DroneController():
    def __init__(self, mac_address, debug=False, mock=False):
        self.flying = False
        self.commands = Queue()
        if not mock:
            self.drone = Mambo(mac_address)
        self.debug = debug
        self.mock = mock

        def done():
            self.drone.safe_land(5)
            self.flying = False

        self.code_to_command = {
            0: (lambda: done()),
            1: (lambda: self.drone.safe_takeoff(5)),  # takeoff
            2: (lambda: self.drone.safe_land(5)),  # land
            3: (lambda: self.drone.fly_direct(0, 10, 0, 0, 1)),  # forward
            4: (lambda: self.drone.fly_direct(0, -10, 0, 0, 1)),  # backward
            5: (lambda: self.drone.fly_direct(-10, 0, 0, 0, 1)),  # left
            6: (lambda: self.drone.fly_direct(10, 0, 0, 0, 1)),  # right
            7: (lambda: self.drone.fly_direct(0, 0, 0, 10, 1)),  # up
            8: (lambda: self.drone.fly_direct(0, 0, 0, -10, 1)),  # down
            9: (lambda: self.drone.turn_degrees(-45)),  # turn left
            10: (lambda: self.drone.turn_degrees(45)),  # turn right
            11: (lambda: self.drone.flip("front")),  # flip forward
            12: (lambda: self.drone.flip("back")),  # flip backward
            13: (lambda: self.drone.flip("right")),  # flip right
            14: (lambda: self.drone.flip("left")),  # flip left
        }
        if mock:
            self.process_command = lambda c: print(F"Mock execute: {c}")
        else:
            self.process_command = lambda c: self.code_to_command[
                c.command_code]()

    def start_flight(self):
        self.flying = True

        def fly():
            self.flying = True
            if not self.mock:
                self.drone.connect(5)
                self.drone.smart_sleep(5)

            while self.flying:
                try:
                    c = self.commands.get(block=False)
                except:
                    if not self.mock:
                        #self.drone.hover()
                        self.drone.smart_sleep(2)
                    continue

                if self.debug:
                    print(F"Debug: {c}")

                self.process_command(c)
                if not self.mock:
                    self.drone.smart_sleep(3)

            if not self.mock:
                self.drone.disconnect()

        t = Thread(target=fly)
        t.start()

    def send_command(self, command):
        if not self.flying:
            return False

        self.commands.put(command)
        return True

    def stop_flight(self):
        # self.send_command(<STOP COMMAND>)
        pass
Esempio n. 22
0
args = vars(ap.parse_args())

CLASSES = [
    "background", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus",
    "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike",
    "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"
]
COLORS = np.random.uniform(0, 255, size=(len(CLASSES), 3))

os.environ[
    "OPENCV_FFMPEG_CAPTURE_OPTIONS"] = 'protocol_whitelist;file,tcp,rtp,udp | fflags;nobuffer | flag;low_delay'
mamboAddr = "DC-71-96-21-9C-E7"

# 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)
time.sleep(2)
mambo.fps = 30

print("[INFO] loading model...")
net = cv2.dnn.readNetFromCaffe(args["prototxt"], args["model"])
# initialize the video stream, allow the cammera sensor to warmup,
# and initialize the FPS counter
print("[INFO] starting video stream...")
cap = cv2.VideoCapture("rtsp://192.168.99.1/media/stream2", cv2.CAP_FFMPEG)
time.sleep(2.0)
fps = FPS().start()
Esempio n. 23
0
"""
Demo the direct flying for the python interface
Author: Amy McGovern
"""

from pyparrot.Minidrone import Mambo

# you will need to change this to the address of YOUR mambo
mamboAddr = os.environ.get(DRONE_ADDRESS)

# 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=False)

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=100, yaw=0, vertical_movement=0, duration=2)
Esempio n. 24
0
from pyparrot.Minidrone import Mambo

mamboAddr = "e0:14:c1:6c:3d:cf"

mambo = Mambo(mamboAddr, use_wifi=False)

print("trying to connect")
success = mambo.connect(num_retries=5)
print("connected: %s" % success)

if (success):
    # get the state information
    print("sleeping")
    mambo.smart_sleep(5)

    print("taking off!")
    mambo.safe_takeoff(5)

    print("Flying direct: going forward (positive pitch)")
    mambo.fly_direct(roll=0, pitch=0, yaw=0, vertical_movement=-10, duration=2)
    mambo.smart_sleep(0)

    print("Flying direct: going forward (positive pitch)")
    mambo.fly_direct(roll=0, pitch=20, yaw=0, vertical_movement=0, duration=4)
    mambo.smart_sleep(0)

    print("Showing turning (in place) using turn_degrees")
    mambo.turn_degrees(-45)
    mambo.smart_sleep(0)

    print("Showing turning (in place) using turn_degrees")
Esempio n. 25
0
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:3f:cd:3d:fc"

# 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=False)

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)

        #insert movement code here
        #pitch=forward backward movement
        #roll=left right tilt
        #yaw= left right turn
Esempio n. 26
0
from pyparrot.Minidrone import Mambo
from pprint import pprint

bt_mac_01 = "d0:3a:de:8a:e6:37"
# bt_mac_01 = "d0:3a:82:0a:e6:21"

drone_01 = Mambo(address=bt_mac_01, use_wifi=False)

print("trying to connect")
success_01 = drone_01.connect(num_retries=3)
print("drone_01 connected: %s " % success_01)

if (success_01):  #& success_02:
    # get the state information
    print("test stats")
    print("taking off!")
    drone_01.safe_takeoff(5)
    for i in range(10):
        drone_01.ask_for_state_update()
        pprint(vars(drone_01.sensors))
        drone_01.smart_sleep(0.1)
    drone_01.safe_land(5)
    drone_01.disconnect()
Esempio n. 27
0
Demo the direct flying for the python interface

Author: Amy McGovern
"""

from pyparrot.Minidrone import Mambo
import sys

import atexit

# you will need to change this to the address of YOUR mambo
mamboAddrs = ["d0:3a:2f:c6:e6:3b", "d0:3a:b1:8c:e6:21"]

# 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
mambos = [Mambo(x, use_wifi=False) for x in mamboAddrs]


def callback(mambo):
    print(
        f"Battery: {mambo.sensors.battery} SpeedXYZTs: {mambo.sensors.speed_x:0.2f},{mambo.sensors.speed_y:0.2f},{mambo.sensors.speed_z:0.2f},{mambo.sensors.speed_ts:0.2f} Flying State: {mambo.sensors.flying_state}"
    )


for mambo in mambos:
    print("trying to connect")
    success = mambo.connect(num_retries=3)
    print("connected: %s" % success)
    if not success:
        sys.exit(1)
Esempio n. 28
0
import RPi.GPIO as GPIO
import time
import cv2

GPIO.setmode(GPIO.BCM)
GPIO.setup(14, GPIO.OUT)

from pyparrot.Minidrone import Mambo

mamboAddr = "D0:3A:CD:C4:E6:21"
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(1)
    mambo.ask_for_state_update()
    mambo.smart_sleep(1)
    import beep
    mambo.safe_takeoff(3)

    print("up")
    mambo.fly_direct(roll=0, pitch=0, yaw=0, vertical_movement=20, duration=1)
    mambo.smart_sleep(3)

    print("down")
    mambo.fly_direct(roll=0, pitch=0, yaw=0, vertical_movement=-20, duration=1)
Esempio n. 29
0
i = 0
longtitude = []
latitude = []
for i in range(len(locations)):
    if i % 2 == 0:
        longtitude.append(locations[i])
    else:
        latitude.append(locations[i])

arduino = serial.Serial('COM10', 9600)

#   Start to connect Mambo
#    mamboAddr = "6C:29:95:08:40:3A"
#    mamboAddr = "D0:3A:15:7D:E6:3B"
mamboAddr = "D0:3A:08:89:E6:37"
mambo = Mambo(mamboAddr, use_wifi=True)
print("[*] Trying to connect")
success = mambo.connect(num_retries=3)
print("[!] Connected : %s" % success)


def taking_off_N_con(froll=0, fpitch=0, fyaw=0, fver=0):
    print("taking off")
    mambo.safe_takeoff(2)
    mambo.smart_sleep(2)

    count = ['froll', 'fpitch', 'fyaw', 'fver']
    param = [froll, fpitch, fyaw, fver]
    for i in range(1, 2):
        mambo.fly_direct(roll=froll, pitch=fpitch,
                         yaw=fyaw, vertical_movement=fver)
Esempio n. 30
0
        print("pritnving valsd")
        print(self.highh)
        print(self.highs)
        print(self.highv)
        print(self.lowh)
        print(self.lows)
        print(self.lowv)

    def save_frame(self):
        # Save obtained frame into video output file
        self.output_video.write(self.frame)


if __name__ == '__main__':
    mambo = Mambo(mamboAddr, use_wifi=True)
    print("trying to connect to mambo now")
    success = mambo.connect(num_retries=3)
    print("connected: %s" % success)
    # mambo.SetResolution()

    time.sleep(2)

    rtsp_stream_link = 'rtsp://192.168.99.1/media/stream2'
    video_stream_widget = RTSPVideoWriterObject(rtsp_stream_link, mambo)
    #video_stream_widget = RTSPVideoWriterObject(0, mambo)

    while True:
        try:
            video_stream_widget.show_frame()
            video_stream_widget.save_frame()