Exemplo n.º 1
0
	def fly_arm_mosquito(self, sender):
		"""
		Arm the Mosquito via Wifi and loop ad infinitum sending RC commands
		until disarmed
		"""
		self._disarm_clicked = False
		first_iter = True
		# until disarmed send joystick data to the Mosquito
		last = time.time()
		while not self._disarm_clicked:
			aux_2 = 1.0
			if first_iter:
				aux_2 = -1.0
				first_iter = False
			aux_1 = -1.0
			if sender.superview['aux_1_switch'].value:
				aux_1 = 1.0
			yaw, throttle = sender.superview['left_stick'].get_rc_values()
			roll, pitch = sender.superview['right_stick'].get_rc_values()
			data = msppg.serialize_SET_RC_NORMAL(throttle, roll, pitch, yaw, aux_1, aux_2)
			# see if min time has elapsed and, if so, send RC commands
			if time.time() >= (last + self._interval):
				self._send_data(data, sender)
				last = time.time()

		data = msppg.serialize_SET_RC_NORMAL(-1.0, 0.0, 0.0, 0.0, 0.0, -1.0)
		self._send_data(data, sender)
Exemplo n.º 2
0
	def arm_mosquito(self, sender):
		"""
		Arm the Mosquito via Wifi by sending appropriate RC commands.
		For Hackflight to consider a safe arming the arming switch has to
		be low on startup. To achieve so, two RC packets are send. In the
		first one, the arming switch is set to low and then the second one
		sets it to high thus arming the drone
		"""
		data = msppg.serialize_SET_RC_NORMAL(-1.0, 0.0, 0.0, 0.0, 0.0, -1.0)
		data_2 = msppg.serialize_SET_RC_NORMAL(-1.0, 0.0, 0.0, 0.0, 0.0, 1.0)
		self._send_multiple_data([data, data_2], sender)
Exemplo n.º 3
0
	def disarm_mosquito(self, sender):
		"""
		Diasrm Mosquito via Wifi by sending a set of RC values that
		disarm the drone
		"""
		if sender.superview.name == 'transmitter':
			self._disarm_clicked = True
		else:
			data = msppg.serialize_SET_RC_NORMAL(-1.0, 0.0, 0.0, 0.0, 0.0, -1.0)
			self._send_data(data, sender)
Exemplo n.º 4
0
SUPERFLY_PORT = 80
TIMEOUT_SEC   = 4

from socket import socket
from pysticks import get_controller
from msppg import serialize_SET_RC_NORMAL

# Start the controller
con = get_controller()

# Set up socket connection to SuperFly
sock = socket()
sock.settimeout(TIMEOUT_SEC)
sock.connect((SUPERFLY_ADDR, SUPERFLY_PORT))    
    
while True:

    # Make the controller acquire the next event
    con.update()

    # Put stick demands and aux switch value into a single array,
    # with zero for Aux1 and aux switch for Aux2
    cmds = (con.getThrottle(), con.getRoll(), con.getPitch(), con.getYaw(), 0, con.getAux())

    # Report commands for debugging
    print('Throttle:%+2.2f Roll:%+2.2f Pitch:%+2.2f Yaw:%+2.2f Aux1:%+2.2f Aux2:%+2.2f' % cmds)

    # Send the array of commands to SuperFly
    sock.send(serialize_SET_RC_NORMAL(*cmds))