예제 #1
0
class StopLines:
    def __init__(self, waypoint_positions, stopline_positions):
        self.waypoints = Waypoints(waypoint_positions)
        self.stopline_waypoints = self._calc_stopline_waypoints(
            stopline_positions)

    def _calc_stopline_waypoints(self, stopline_positions):
        return [
            self.waypoints.find_closest(x, y) for x, y in stopline_positions
        ]

    def find_nearest_stopline(self, my_position):
        my_waypoint = self.waypoints.find_closest(my_position.x, my_position.y)
        min_distance = len(self.waypoints.waypoints)
        nearest_so_far = None

        for light_index, stopline_waypoint in enumerate(
                self.stopline_waypoints):
            distance = stopline_waypoint - my_waypoint
            if (distance >= 0) and (distance < min_distance):
                min_distance = distance
                nearest_so_far = (light_index, stopline_waypoint)

        return nearest_so_far
예제 #2
0
 def update_base_waypoints(self, lane):
     self.waypoints = Waypoints(lane.waypoints)
예제 #3
0
 def update_base_waypoints(self, lane):
     self.waypoints = Waypoints(lane.waypoints)
     self.stoplines = StopLines(lane.waypoints,
                                self.config['stop_line_positions'])
예제 #4
0
 def __init__(self, waypoint_positions, stopline_positions):
     self.waypoints = Waypoints(waypoint_positions)
     self.stopline_waypoints = self._calc_stopline_waypoints(
         stopline_positions)