コード例 #1
0
 def data_received(self, msg):
     # print('data received', repr(msg))
     try:
         if(msg==b'.'):
         # heartbeat(drone)
             async for pos_vel in drone.conn.telemetry.position_velocity_ned():
                 s[0] = pos_vel.position.north_m
                 s[1] = pos_vel.position.east_m
                 s[2] = -pos_vel.position.down_m
                 s[3] = pos_vel.velocity.north_m_s
                 s[4] = pos_vel.velocity.east_m_s
                 s[5] = -pos_vel.velocity.down_m_s     
             
         if(((msg)[:2])==(b'OA')):
         # print((msg)[2])
             if(((msg)[2])==49):#1
                 drone.add_action(Arm())
                 print('arm')
             if(((msg)[2])==50):#2
                 drone.add_action(Disarm())
                 print('disarm')
             if(((msg)[2])==51):#3
                 drone.add_action(FlyToPoint(np.array([0, 0, -1]), tolerance=2.5))
                 print('ftp0,0,-1')
             if(((msg)[2])==52):#4
                 drone.add_action(land())
                 print('land')
             if(((msg)[2])==53):#5
                 drone.add_action( PercisionLand( 1.0,   np.array([1, 1])   )  )
                 print('percision_land')
             if(((msg)[2])==54):#6
                 drone.add_action(FlyToPoint(np.array([0,0,-10]),tolerance =1))
                 print('FlyToPoint0,0,-10')
             if(((msg)[2])==55):#7
                 drone.add_action(Circle(velocity=2.0,radius=8.0,angle=0.0))
                 print('circle')
             if(((msg)[2])==56):#8
                 drone.add_action(Spin())
                 print('Spin')
             if(((msg)[2])==57):#9
                 drone.override_action(Killing())
                 print('Killing!')
     except Exception as E:
         print(E)
コード例 #2
0
def status(drone):
    print('s')
    drone.add_action(FlyToPoint(np.array([0, 0, -5]), tolerance=1))
    drone.add_action(land)
コード例 #3
0
def actions(drone):

    drone.add_action(FlyToPoint(np.array([0, 0, -10]), tolerance=1))
    drone.add_action(land)
from mavfleetcontrol.craft import Craft
from mavfleetcontrol.actions.point import FlyToPoint
from mavfleetcontrol.actions.land import land

if __name__ == "__main__":



	drone1 = Craft("drone1", "udp://:14540")
	drone2 = Craft("drone2", "udp://:14541")


	drone1.start()
	drone2.start()

	drone1.add_action(FlyToPoint(np.array([0,0,-2]),tolerance = 0.25))
	drone1.add_action(FlyToPoint(np.array([2,0,-2]),tolerance = 0.25))

	drone2.add_action(FlyToPoint(np.array([0,0,-2]),tolerance = 0.25))
	drone2.add_action(FlyToPoint(np.array([2,0,-2]),tolerance = 0.25))

	drone1.add_action(land)
	drone2.add_action(land)


	# drone.override_action(land)


	drone1.close_conn()#will run after FLYTOPOINT IS DONE)
	drone2.close_conn()#will run after FLYTOPOINT IS DONE)
コード例 #5
0
async def actions(drone, session):
    while True:
        os.system('clear')
        print("1: Arm")
        print("2: Disarm")
        print("3: Take off")
        print("4: Land")
        print("5: Precision Land [1,1,0] NED")
        print("6: Go to [0,0,10] NED")
        print("7: Circle")
        print("8: Spin")
        print("9: Emergency Cut Off")
        print("0: Back to Main")
        print()
        if drone == 'serial':
            serial = 0
        else:
            serial = 0
        # session = PromptSession()
        with patch_stdout():
            text = await session.prompt_async('actions> ')
        # text = await prompt_async('actions> ', key_bindings=bindings)
        if text == '1':
            if serial:
                drone.add_action(Arm())
            else:
                send_message('1')
        if text == '2':
            if serial:
                drone.add_action(Disarm())
            else:
                send_message('2')
        if text == '3':
            if serial:
                drone.add_action(FlyToPoint(np.array([0, 0, -1]), tolerance=1))
            else:
                send_message('3')

        if text == '4':
            if serial:
                dront.add_action(land())
            else:
                send_message('4')
        if text == '5':
            if serial:
                drone.add_action(PercisionLand(1.0, np.array([1, 1])))
            else:
                send_message('5')
        if text == '6':
            if serial:
                drone.add_action(FlyToPoint(np.array([0, 0, -10]),
                                            tolerance=1))
            else:
                send_message('6')
        if text == '7':
            if serial:
                drone.add_action(Circle(velocity=5.0, radius=8.0, angle=0.0))
                # pass
            else:
                send_message('7')
        if text == '8':
            if serial:
                drone.override_action(spin())
            else:
                send_message('8')
        if text == '9':
            if serial:
                drone.override_action(Killing())
            else:
                send_message('9')
        if text == '0':
            break
コード例 #6
0
import asyncio
import time
import numpy as np

from mavfleetcontrol.craft import Craft
from mavfleetcontrol.actions.point import FlyToPoint
from mavfleetcontrol.actions.position_velocity_control import PositionVelocityControl

from mavfleetcontrol.actions.land import land

if __name__ == "__main__":

    # loop = asyncio.get_event_loop()

    drone = Craft("drone1", "udp://:14540")
    # loop.run_until_complete(drone.arm(coordinate=[0.0,0.0,0.0],attitude=[0.0,0.0,0.0]))
    drone.start()
    drone.add_action(FlyToPoint(np.array([0, 0, -5]), tolerance=1))
    drone.add_action(
        PositionVelocityControl(1,
                                [np.array([0.0, 0.0]),
                                 np.array([0.0, 100.0])],
                                tolerance=10))
    drone.add_action(land)
    # drone.override_action(land)
    drone.close_conn()  # will run after FLYTOPOINT IS DONE)
    drone.join()
コード例 #7
0
import asyncio
import time
import numpy as np

from mavfleetcontrol.craft import Craft
from mavfleetcontrol.actions.point import FlyToPoint
from mavfleetcontrol.actions.percision_land import PercisionLand
from mavfleetcontrol.actions.land import land

if __name__ == "__main__":

    # loop = asyncio.get_event_loop()

    drone = Craft("drone1", "udp://:14540")
    # loop.run_until_complete(drone.arm(coordinate=[0.0,0.0,0.0],attitude=[0.0,0.0,0.0]))
    drone.start()
    drone.add_action(FlyToPoint(np.array([1, 1, -20]), tolerance=0.5))
    drone.add_action( PercisionLand( 1.0,   np.array([1, 1])   )  )
    drone.add_action(land)
    # drone.override_action(land)
    drone.close_conn()  # will run after FLYTOPOINT IS DONE)
    drone.join()
コード例 #8
0
    # loop = asyncio.get_event_loop()

    drone0 = Craft('drone0', "udp://:14540")
    drone1 = Craft('drone1', "udp://:14541")
    drone2 = Craft('drone1', "udp://:14542")
    drone3 = Craft('drone1', "udp://:14543")
    drone4 = Craft('drone1', "udp://:14544")
    # loop.run_until_complete(drone.arm(coordinate=[0.0,0.0,0.0],attitude=[0.0,0.0,0.0]))
    drone0.start()
    drone1.start()
    drone2.start()
    drone3.start()
    drone4.start()

    drone0.add_action(FlyToPoint(np.array([0, 0, -15]), tolerance=1))
    drone1.add_action(FlyToPoint(np.array([0, 0, -15]), tolerance=1))
    drone2.add_action(FlyToPoint(np.array([0, 0, -15]), tolerance=1))
    drone3.add_action(FlyToPoint(np.array([0, 0, -15]), tolerance=1))
    drone4.add_action(FlyToPoint(np.array([0, 0, -15]), tolerance=1))

    drone0.add_action(Flip(tolerance=10))
    drone1.add_action(Flip(tolerance=10))
    drone2.add_action(Flip(tolerance=10))
    drone3.add_action(Flip(tolerance=10))
    drone4.add_action(Flip(tolerance=10))

    drone0.add_action(land)
    drone1.add_action(land)
    drone2.add_action(land)
    drone3.add_action(land)