Exemplo n.º 1
0
 def land(self):
     print("I'm landing")
     global PERCHING_EVENT
     #print(PERCHING_EVENT)
     while not PERCHING_EVENT:
         if (gamepad.get())[6]:
             PERCHING_EVENT = True
         AX_L_H = (gamepad.get())[0]
         AX_L_V = (gamepad.get())[1]
         AX_R_H = (gamepad.get())[3]
         AX_R_V = (
             gamepad.get()
         )[4]  # need some way of updating these values outside the while loop
         #print(AX_R_V,AX_R_H,AX_L_V,AX_L_H)
         if (
                 AX_L_H + AX_L_V + AX_R_H + AX_R_V
         ) < 0.2:  #This allows for some accidental control touch. The smaller
             # the number, the more sensitive. Consider making just a sum of the ABSOLUTE values.
             self._cf.commander.send_setpoint(0, 0, 0, 0)  #sample code
         else:
             self.fly()  #If button pressed, go back to flying mode
     param_name = "pid_attitude.pitch_kd"
     param_value = "10000"
     self._cf.param.set_value(param_name, param_value)
     #self._cf.param.remove_update_callback(group = "pid_attitude", name = "pitch_kd", cb = self.perch)
     self._cf.param.add_update_callback(group="pid_attitude",
                                        name="pitch_kd",
                                        cb=self.param_updated_callback)
     self.perch()
Exemplo n.º 2
0
 def fly(self):
     print("I'm flying")
     # time.sleep(1)
     # THis is so that cf doesn't fly away at the beginning
     self._cf.commander.send_setpoint(0, 0, 0, 0)
     while (gamepad.get())[14] == 0:
         #Change maximum thrust here
         thrust = int(32000 * ((gamepad.get())[0]))
         #print(thrust)
         #print((gamepad.get())[14])
         self._cf.commander.send_setpoint(0, 0, 0, abs(thrust))
         #self._cf.commander.send_setpoint(0, 0, 0, 0)
     self.land()
Exemplo n.º 3
0
 def listen_disconnect(self):
     """Listen for disconnection"""
     while 1:
         if (gamepad.get())[13] != 0:  #Start button
             print("Disconnected from crazyflie")
             # self._cf.commander.send_setpoint(0, 0, 0, 0)
             self._cf.close_link()
Exemplo n.º 4
0
 def fly(self):
     print("I'm flying")
     time.sleep(3)
     self._cf.commander.send_setpoint(0, 0, 0, 0) #THis is so that cf doesn't fly away at the beginning
     the_time = time.time() + 5
     while time.time() < the_time:
         thrust = int(32000*(((gamepad.get())[0])))
         print(thrust)
         self._cf.commander.send_setpoint(0, 0, 0, abs(thrust))
     self._cf.commander.send_setpoint(0, 0, 0, 0)
Exemplo n.º 5
0
 def perch(self):
     print("I'm perching")
     global PERCHING_EVENT
     while PERCHING_EVENT:
         AX_L_H = (gamepad.get())[0]
         AX_L_V = (gamepad.get())[1]
         AX_R_H = (gamepad.get())[3]
         AX_R_V = (
             gamepad.get()
         )[4]  # need some way of updating these values outside the while loop
         #print(AX_R_V, AX_R_H, AX_L_V, AX_L_H)
         if (
                 AX_L_H + AX_L_V + AX_R_H + AX_R_V
         ) < 0.2:  # This allows for some accidental control touch. The smaller
             # the number, the more sensitive. Consider making just a sum of the ABSOLUTE values.
             self._cf.commander.send_setpoint(0, 0, 0, 1000)  # sample code
         else:
             PERCHING_EVENT = False
             self.fly()  # If button pressed, go back to flying mode
 def ClickedBtn(self):
     self.label_10.setText(gamepad.getname())
     print(self.radioButton_2.isChecked())
     b = 50
     d = 50
     while self.radioButton_2.isChecked():
         #Makes Slow motion if >1
         #time.sleep(0.5)
         self.x = gamepad.get()
         print(self.x)
         a = int(((float(self.x[0]) * 1000) + 1000) / 20)
         c = int(((float(self.x[2]) * 1000) + 1000) / 20)
         if (b < 0):
             b = 0
         if (b > 100):
             b = 100
         if (d < 0):
             d = 0
         if (d > 100):
             d = 100
         if (self.x[4] == 1):
             b += 3
         if (self.x[6] == 1):
             b -= 3
         if (self.x[5] == 1):
             d += 3
         if (self.x[7] == 1):
             d -= 3
         print("ajefvjsvfjvsj")
         self.progressBar.setValue(a)
         self.progressBar_2.setValue(b)
         self.progressBar_3.setValue(c)
         self.progressBar_4.setValue(d)
         self.lineEdit.setText(
             str(a) + "    " + str(b) + "    " + str(c) + "    " + str(d))
         print("going update")
         #firebase.put('/values','a',a)
         #firebase.put('/values','b',b)
         #firebase.put('/values','c',c)
         #firebase.put('/values','d',d)
         ref.update({'a': a, 'b': b, 'c': c, 'd': d})
         print("cpmplteupdate")
Exemplo n.º 7
0
import gamepad, socket, time

ip = "192.168.80.12"
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
old = []
gdata = []
while 1:
    while old == gdata:
        gdata = gamepad.get()
    old = gdata
    if gdata[0] > 5:
        s.sendto("R10255",(ip,7777))
    elif gdata[0] < -5:
        s.sendto("R01255",(ip,7777))
    elif gdata[1] < -5:
        s.sendto("R11255",(ip,7777))
    elif gdata[1] > 5:
        s.sendto("R00255",(ip,7777))
    else:
        s.sendto("R22255",(ip,7777))
Exemplo n.º 8
0
import gamepad, socket, time

ip = "192.168.80.12"
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
old = []
gdata = []
while 1:
    while old == gdata:
        gdata = gamepad.get()
    old = gdata
    if gdata[0] > 5:
        s.sendto("R10255", (ip, 7777))
    elif gdata[0] < -5:
        s.sendto("R01255", (ip, 7777))
    elif gdata[1] < -5:
        s.sendto("R11255", (ip, 7777))
    elif gdata[1] > 5:
        s.sendto("R00255", (ip, 7777))
    else:
        s.sendto("R22255", (ip, 7777))
UDP_IP = "255.255.255.255" #"10.23.46.31"
UDP_PORT = 4999
MESSAGE = "0 0"
print "UDP target IP:", UDP_IP
print "UDP target port:", UDP_PORT
print "message:", MESSAGE

axisX = 0
axisY = 0
left = 0
right = 0
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) 
while 1:
        MESSAGE = gamepad.get() #raw_input("Please, write speed for both motors\n")
        #sock.sendto(str(MESSAGE[0])+str(MESSAGE[1]), (UDP_IP, UDP_PORT))
        axisX = float(MESSAGE[0])
        axisY = float(MESSAGE[1])
        axisY = axisY * ( -1 )
	"""
        if  axisX <= 0 and axisY <= 0:
             left = 255 * axisY  *(-1)
             right =255 * sqrt (axisX * axisX + axisY * axisY)

        if  axisX <= 0 and axisY > 0:
             left = axisY  *(-255)
             right = sqrt (axisX * axisX + axisY * axisY) * (-255)

        if  axisX > 0 and axisY > 0:
             right = axisY  *(-255)
Exemplo n.º 10
0
import gamepad
import time

while 1:
    print((gamepad.get()[14]))
    time.sleep(0.5)
Exemplo n.º 11
0
UDP_IP = "255.255.255.255"  #"10.23.46.31"
UDP_PORT = 4999
MESSAGE = "0 0"
print "UDP target IP:", UDP_IP
print "UDP target port:", UDP_PORT
print "message:", MESSAGE

axisX = 0
axisY = 0
left = 0
right = 0
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
while 1:
    MESSAGE = gamepad.get(
    )  #raw_input("Please, write speed for both motors\n")
    #sock.sendto(str(MESSAGE[0])+str(MESSAGE[1]), (UDP_IP, UDP_PORT))
    axisX = float(MESSAGE[0])
    axisY = float(MESSAGE[1])
    axisY = axisY * (-1)
    """
        if  axisX <= 0 and axisY <= 0:
             left = 255 * axisY  *(-1)
             right =255 * sqrt (axisX * axisX + axisY * axisY)

        if  axisX <= 0 and axisY > 0:
             left = axisY  *(-255)
             right = sqrt (axisX * axisX + axisY * axisY) * (-255)

        if  axisX > 0 and axisY > 0:
             right = axisY  *(-255)