Esempio n. 1
0
__author__ = "Aldo Vargas"
__copyright__ = "Copyright 2016 Altax.net"

__license__ = "GPL"
__version__ = "1"
__maintainer__ = "Aldo Vargas"
__email__ = "*****@*****.**"
__status__ = "Development"

from pymultiwii import MultiWii

if __name__ == "__main__":

    #board = MultiWii("/dev/ttyUSB0")
    board = MultiWii("/dev/tty.usbserial-A801WZA1")
    try:
        while True:
        	#example of 8 RC channels to be send
            data = [1500,1550,1600,1560,1000,1040,1000,1000]
            
            # Old function 
            #board.sendCMD(16,MultiWii.SET_RAW_RC,data)

            #New function that will receive attitude after setting the rc commands
            board.sendCMDreceiveATT(16,MultiWii.SET_RAW_RC,data)
            
            print (board.attitude)
    except Exception,error:
        print ("Error on Main: "+str(error))
        
Esempio n. 2
0
            aux2 = board.rcChannels['aux2']
            aux3 = board.rcChannels['aux3']
            aux4 = board.rcChannels['aux4']
            data = [r,p,y,t,aux1,aux2,aux3,aux4]
            print "DATA:",data
            print "\r",v,"\r"
            print "----<--->----"
            altitude = board.getData(MultiWii.ALTITUDE)
            box = board.getData(MultiWii.BOX)
            print "Altitude:",altitude," - box:",box
            if(i%2==1):
                print "--------"
                print "\r\r\r Dans test RAW RC"
            	data2 = [r,p,1200,y,1800,1800,1800,1800]
            	#board.arm()
            	board.sendCMDreceiveATT(16,MultiWii.SET_RAW_RC,data2)
                #data3 = [990,990,1200,990]
                #board.sendCMDreceiveATT(8,MultiWii.SET_RAW_RC,data3)
            	v = board.getData(MultiWii.RC)
            	print "\r -------> RC -->:",v,"\r"
            	print "----fin raw rc----\r\r"
                time.sleep(0.2)
                #data = [r,p,y,990,990,990,990,990]
            	#board.arm()
            	#print board.sendCMDreceiveATT(16,MultiWii.SET_RAW_RC,data)'''


            #board.sendCMDreceiveATT(16,MultiWii.BOX,data)
            #print(board.getData(MultiWii.ATTITUDE))
            #print "----<--gg->----"
            i = i+1
Esempio n. 3
0
boton_up = mando[5]
boton_down = mando[4]

print 'Iniciando bucle principal'
while Done == False:
	
	bat = ina.read()
	if boton_up == 12 and arm == 0:
		placa.arm()
		arm = 1
	elif boton_up == 12 and arm ==1:
		placa.disarm()
		arm = 0
	if arm ==1:
		data =[roll,pitch,yaw,trothle,1000,1000,1000,1000]
		placa.sendCMDreceiveATT(16,MultiWii.SET_RAW_RC,data)
		x = int(placa.attitude['angx'])
		y = int(placa.attitude['angy'])
		z = int(placa.attitude['heading'])
		array = [x,y,z,bat]
		msg = pickle.dumps(array)
		sock.sendto(msg, (UDP_HOST,UDP_PORT))
	elif arm ==0:
		placa.getData(MultiWii.ATTITUDE)
		x = int(placa.attitude['angx'])
		y = int(placa.attitude['angy'])
		z = int(placa.attitude['heading'])
		array = [x,y,z,bat]
		msg = pickle.dumps(array)
		sock.sendto(msg, (UDP_HOST,UDP_PORT))
	HayDatosSocket = select.select([sock],[],[],0.5)