Esempio n. 1
0
def start_autnonmous():
	s = '123412341234123412341234123412341234123412341234123412'
	global dock
	global info2Boat
	global currCourse
	global data
	global currChallenge
	###Read HeartBeat Untill End 
	select_course()

	#Init the process to wait for the autodocking position
	wait_for_docking();
	print("Wait For Docking")
	x.clean_buffer()
	#Ask for the current challenge to submit to the server
	set_challenge(data)
	#Send the heart_beat with the current information
	auvsi.send_http_heartbeat(currCourse,int(data[timePos]),currChallenge,float(data[latPos]),float(data[longPos]));


	#Ask the dock from drone by BT
	d = read_dock_from_drone()
	print("read_dock_from_drone")
	dock = d
	
	send_dock();
	print("send_dock")

	x.clean_buffer()
	#Wait for the end of the run
	wait_for_end();
Esempio n. 2
0
def send_course():
	for i in range(1,5):
		enable = 1;
		dock = 2;
		#Send the info to the boat
		info2Boat = [enable,R_KillSwitch,Status,course,challenge,dock];
		x.send2boat(info2Boat);
		time.sleep(1.05 )
		#Send the last heart_beat sended with the last info of docking
		auvsi.send_http_heartbeat(currCourse,t,currChallenge,la,lo);
Esempio n. 3
0
def wait_for_docking():
	global data
	global currCourse
	global currChallenge

	#Wait for boat to arrive to the docking challenge
	while data[challPos] != 'd':
		#Wait for the incomming data
		try:
			s = x.receive_from_boat();

			data = s.split(',');
			if(data[0].find('2') > 0):
				data[0] = data[0][data[0].find('2') : ]

			print(data)
			#Ask for the current challenge to submit to the server
			set_challenge(data)
			#Cast the values of the # values
			print(currChallenge)
			#Hearbeat speed, docking, path, follow, return
			if( currChallenge == 'speed' or currChallenge == 'return' or currChallenge == 'follow' or currChallenge == 'path'):
				t  = int(data[timePos])
				la = float(data[latPos])
				lo = float(data[longPos])
				#Send the heart_beat with the current information
				auvsi.send_http_heartbeat(currCourse,t,currChallenge,la,lo);
			elif(currChallenge == 'start'):
				auvsi.send_http_start(currCourse)
				t  = int(data[timePos])
				la = float(data[latPos])
				lo = float(data[longPos])
				#Send the heart_beat with the current information
				auvsi.send_http_heartbeat(currCourse,t,currChallenge,la,lo);
			elif(currChallenge == 'end'):
				auvsi.send_http_end(currCourse)
				t  = int(data[timePos])
				la = float(data[latPos])
				lo = float(data[longPos])
				#Send the heart_beat with the current information
				auvsi.send_http_heartbeat(currCourse,t,currChallenge,la,lo);
			elif(currChallenge == 'docking'):
				t  = int(data[timePos])
				la = float(data[latPos])
				lo = float(data[longPos])
				#Send the heart_beat with the current information
				auvsi.send_http_heartbeat(currCourse,t,currChallenge,la,lo);
				auvsi.send_http_docking(currCourse, "DronePhoto1.jpg");

		except ValueError:
			print("Error en la rececpción XBee")
Esempio n. 4
0
def wait_for_end():
	global data
	global currCourse
	global currChallenge
	while data[challPos] != 'e':
		s = x.receive_from_boat();
		time.sleep(.1)
		x.clean_buffer()
		data = s.split(',');

		if(data[0].find('2') > 0):
				data[0] = data[0][data[0].find('2') : ]

		print(data)

		set_challenge(data)
		#Cast the values of the # values
		t  = int(data[timePos])
		la = float(data[latPos])
		lo = float(data[longPos])
		#Send the heart_beat with the current information
		auvsi.send_http_heartbeat(currCourse,t,currChallenge,la,lo);	
Esempio n. 5
0
def send_dock():
	#Send the information of the dock to the boat
	#Send several messages to be sure that message arrived.
	global data
	global currChallenge
	print(data)
	for i in range(1,6):
		enable = 1;
		dock = 2;

		#Send the info to the boat
		info2Boat = [enable,R_KillSwitch,Status,course,challenge,dock];
		x.send2boat(info2Boat);
		x.clean_buffer()
		time.sleep(1.05 )
		#Cast the values of the # values
		t  = int(data[timePos])
		la = float(data[latPos])
		lo = float(data[longPos])
		#Send the last heart_beat sended with the last info of docking()
		auvsi.send_http_heartbeat(currCourse,t,currChallenge,la,lo);
	
	x.clean_buffer()