I am trying to make a program that will use the robot’s current gps and an input gps position to figure out the turn angle and distance needed to travel from the current position and the input position I am having trouble with the turning part though I cant figure out a good way to tell when it needs to turn right or left based which way is shorter
heres the code:
def Gps(x,y):
xleg=x-gps.x_position(MM) #two legs of the "triangle"
yleg=y-gps.y_position(MM)
angle=math.degrees(math.atan2(yleg,xleg)) #angle needed to turn
if angle < 0:#make angle positive
angle += 360
hypotonuse=math.sqrt(xleg\*xleg+yleg\*yleg) #calculate distance neededd
drivetrain.turn_for(LEFT,angle+35,DEGREES,wait=True)#turn to angle
drivetrain.drive_for(FORWARD,hypotonuse,MM,wait=True)
brain.screen.next_row()
brain.screen.print(gps.x_position(MM))
brain.screen.next_row()
brain.screen.print(gps.y_position(MM))