Beispiel #1
0
def turnLeft():
    #call api provided by drive system
    #print('turn left')
    
    x ,y,heading = gpsxy.gps_mag_data()
    if heading > 270:
    	final_angle = heading + 90 - 360
    	print('final angle',final_angle)
    	while(heading < 360 and heading > 270):
    		print('left')
    		num = [12,13,14]
    		#bus.write_block_data(addr,6,num)
    		x ,y,heading = gpsxy.gps_mag_data()
    	while(heading <=final_angle ):
    		print('left')
    		num = [12,13,14]
    		#bus.write_block_data(addr,6,num)
    		x ,y,heading = gpsxy.gps_mag_data()
    		if heading > final_angle:
    			break
    		
    else:
    	final_angle = heading+90
    	print('final angle',final_angle)
    	while(heading < final_angle):
    		print('left')
    		num = [12,13,14]
    		#bus.write_block_data(addr,6,num)
    		x ,y,heading = gpsxy.gps_mag_data()
    		if heading > final_angle:
    			break
    return
Beispiel #2
0
def turnRight():
    #call api provided by drive system
    #print('turn right')
    x ,y,heading = gpsxy.gps_mag_data()
    if heading < 90:
    	final_angle = heading - 90 + 360
    	print('final angle',final_angle)
    	while(heading > 0 and heading < 90):
    		print('right')
    		num = [12,13,14]
    		#bus.write_block_data(addr,6,num)
    		x ,y,heading = gpsxy.gps_mag_data()
    	heading = 360
    	while(heading > final_angle ):
    		print('right')
    		num = [12,13,14]
    		#bus.write_block_data(addr,6,num)
    		x ,y,heading = gpsxy.gps_mag_data()
    		if(heading < final_angle):
    			break
    else:
    	final_angle = heading-90
    print('final angle',final_angle)
    while(heading >= final_angle):
    	print('right')
    	num = [12,13,14]
    	#bus.write_block_data(addr,6,num)
    	x ,y,heading = gpsxy.gps_mag_data()
    	if heading < final_angle:
    		break
    		
    return
Beispiel #3
0
def findPosition():

    #get latitude and longitude from arduino
    a1, b1, c = gpsxy.gps_mag_data()
    pos = np.array([a1, b1])
    print(pos.latitude, '  ', pos.longitude)
    return pos
Beispiel #4
0
def findPosition():
    #get latitude and longitude from arduino
    a1 , b1 , c = gpsxy.gps_mag_data()
    a1 = conv.convert_gps(a1)
    b1 = conv.convert_gps(b1)
    pos = Location(a1 , b1)
    print (pos.latitude ,'  ', pos.longitude)
    return pos
Beispiel #5
0
def findHeading():
    a, b , heading = gpsxy.gps_mag_data()
    print (heading)
    return heading