Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while visitable_coordinates.isNotEmpty():# Megnézzük, van-e még érintendő pont
- actual_position = PositioningService.getActualPosition()
- closest_visitable = DescartesService.getNearestPositionToActual(actual_position, visitable_coordinates)
- distance_to_goal = DescartesService.getDistanceInMeters(actual_position, closest_visitable)
- if distance_to_goal < 5.0 :
- visitable_coordinates.remove(closest_visitable) # Elértük a célt, ezért ezt töröljük
- else:# Kiszámoljuk, hogy a jelenlegi irány jó-e, ha nem, korrigálunk
- actual_direction_vector = PositioningService.getActualDirection()
- desired_direction_vector = DescartesService.getVectorBetweenTwoPoints(actual_position, closest_visitable)
- angle_difference = DescartesService.getAngleBetweenTwoVectors(actual_direction_vector, desired_direction_vector)
- if abs(angle_difference) > 5: # Elég nagy-e az eltérés?
- # Ha igen, negatív szögnél balra, pozitívnál jobbra korrigálunk
- if angle_difference < 0:
- MotorFunctions.TurnLeft()
- else:
- MotorFunctions.TurnRight()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement