Пример #1
0
    def __init__(self, init_state, constants):
        super().__init__(init_state, constants)

        self.indicators_shape = geometry.make_rectangle(
            self.constants.length * 0.8, self.constants.width)
        self.longitudinal_lights_shape = geometry.make_rectangle(
            self.constants.length, self.constants.width * 0.6)
Пример #2
0
    def __init__(self, init_state, constants):
        super().__init__(init_state, constants)

        position = Point(self.constants.x_position, 0.0).transform(
            self.constants.road.constants.orientation,
            self.constants.road.constants.position)

        self.static_bounding_box = geometry.make_rectangle(
            self.constants.width, self.constants.road.width).transform(
                self.constants.road.constants.orientation, position)

        self.outbound_intersection_bounding_box = geometry.make_rectangle(
            self.constants.width,
            self.constants.road.outbound.width).transform(
                self.constants.road.constants.orientation,
                Point(0, (self.constants.road.inbound.width - position.y) *
                      0.5).translate(position))
        self.inbound_intersection_bounding_box = geometry.make_rectangle(
            self.constants.width, self.constants.road.inbound.width).transform(
                self.constants.road.constants.orientation,
                Point(0, -(self.constants.road.outbound.width - position.y) *
                      0.5).translate(position))

        outbound_traffic_light_position = geometry.Point(
            self.static_bounding_box.rear_left.x,
            self.static_bounding_box.rear_left.y + 20.0)
        inbound_traffic_light_position = geometry.Point(
            self.static_bounding_box.front_right.x,
            self.static_bounding_box.front_right.y - 20.0)

        outbound_traffic_light_constants = TrafficLightConstants(
            width=10,
            height=20,
            position=outbound_traffic_light_position,
            orientation=self.constants.road.constants.orientation)
        inbound_traffic_light_constants = TrafficLightConstants(
            width=10,
            height=20,
            position=inbound_traffic_light_position,
            orientation=self.constants.road.constants.orientation)
        self.outbound_traffic_light = TrafficLight(
            init_state, outbound_traffic_light_constants)
        self.inbound_traffic_light = TrafficLight(
            init_state, inbound_traffic_light_constants)

        self.outbound_spawn = Point(
            self.constants.x_position + (self.constants.width * 0.15),
            (self.constants.road.width / 2.0) +
            (self.constants.road.constants.lane_width / 2.0)).transform(
                self.constants.road.constants.orientation,
                self.constants.road.constants.position)
        self.inbound_spawn = Point(
            self.constants.x_position - (self.constants.width * 0.15),
            -(self.constants.road.width / 2.0) -
            (self.constants.road.constants.lane_width / 2.0)).transform(
                self.constants.road.constants.orientation,
                self.constants.road.constants.position)
Пример #3
0
    def __init__(self, constants, **kwargs):
        super().__init__(**kwargs)

        self.constants = constants

        self.static_bounding_box = geometry.make_rectangle(
            self.constants.width,
            self.constants.height).transform(self.constants.orientation,
                                             self.constants.position)
Пример #4
0
    def __init__(self, constants):
        self.constants = constants

        self.static_bounding_box = geometry.make_rectangle(
            self.constants.length,
            self.constants.road_direction.lane_width * 0.75,
            left_offset=0).translate(
                Point(self.constants.x_position,
                      0).translate(self.constants.road_direction.
                                   static_bounding_box.rear_left))
Пример #5
0
    def __init__(self, init_state, constants):
        super().__init__(init_state=init_state, constants=constants)

        self.shape = geometry.make_rectangle(self.constants.length,
                                             self.constants.width)

        self.wheelbase_offset = self.constants.wheelbase / 2.0

        self.wheels = geometry.make_rectangle(self.constants.wheelbase,
                                              self.constants.track)

        self.noop_action = [0.0, 0.0]
        self.throttle, self.steering_angle = self.noop_action

        self.target_velocity = None
        self.target_orientation = None

        self.target_spline = None
        self.planner_spline = None
Пример #6
0
    def __init__(self, init_state, constants):
        super().__init__(init_state=init_state, constants=constants)

        self.static_bounding_box = geometry.make_rectangle(
            self.constants.width,
            self.constants.height).transform(self.constants.orientation,
                                             self.constants.position)

        def make_light(y):
            return Point(0.0, y).transform(self.constants.orientation,
                                           self.constants.position)

        self.red_light = make_light(self.constants.height * 0.25)
        self.amber_light = make_light(0.0)
        self.green_light = make_light(-self.constants.height * 0.25)
Пример #7
0
    def __init__(self, constants):
        self.constants = constants

        self.num_lanes = self.constants.num_outbound_lanes + self.constants.num_inbound_lanes
        self.width = self.num_lanes * self.constants.lane_width

        self.static_bounding_box = geometry.make_rectangle(
            self.constants.length, self.width,
            rear_offset=0).transform(self.constants.orientation,
                                     self.constants.position)

        left, right = self.static_bounding_box.split_laterally(
            left_percentage=self.constants.num_outbound_lanes / self.num_lanes)
        self.outbound = Direction(left, self.constants.num_outbound_lanes,
                                  self.constants.lane_width,
                                  self.constants.orientation)
        self.inbound = Direction(
            right.flip(), self.constants.num_inbound_lanes,
            self.constants.lane_width,
            self.constants.orientation + (math.radians(180.0)))
Пример #8
0
    def stopping_zones(self):
        braking_distance = (self.state.velocity**
                            2) / (2 * -self.constants.min_throttle)
        reaction_distance = self.state.velocity * REACTION_TIME
        total_distance = braking_distance + reaction_distance

        if total_distance == 0:
            return None, None

        if self.steering_angle == 0:
            zone = geometry.make_rectangle(
                total_distance, self.constants.width, rear_offset=0).transform(
                    self.state.orientation,
                    Point(self.constants.length * 0.5,
                          0).transform(self.state.orientation,
                                       self.state.position))
            braking_zone, reaction_zone = zone.split_longitudinally(
                braking_distance / total_distance)
            return braking_zone, reaction_zone

        return None, None
Пример #9
0
    def __init__(self, init_state, constants):
        super().__init__(init_state, constants)

        self.roof_shape = geometry.make_rectangle(self.constants.length * 0.5,
                                                  self.constants.width)
Пример #10
0
                            num_inbound_lanes=1,
                            lane_width=M2PX * 3.65,
                            position=geometry.Point(0.0, 0.0),
                            orientation=0.0)))

pavement_width = (M2PX * 3)

env_constants = CAVEnvConstants(
    viewer_width=int(road_map.major_road.constants.length),
    viewer_height=int(road_map.major_road.width + (pavement_width * 2)),
    road_map=road_map)

bounding_box = road_map.major_road.bounding_box()
outbound_pavement = geometry.make_rectangle(
    road_map.major_road.constants.length, pavement_width,
    rear_offset=0).transform(
        road_map.major_road.constants.orientation,
        geometry.Point(0,
                       pavement_width / 2).translate(bounding_box.rear_left))
inbound_pavement = geometry.make_rectangle(
    road_map.major_road.constants.length, pavement_width,
    rear_offset=0).transform(
        road_map.major_road.constants.orientation,
        geometry.Point(0, -(pavement_width / 2)).translate(
            bounding_box.rear_right))
pedestrian_diameter = math.sqrt(pedestrian_constants.length**2 +
                                pedestrian_constants.width**2)
x_scale = 1 - (pedestrian_diameter / road_map.major_road.constants.length)
y_scale = 1 - (pedestrian_diameter / pavement_width)
# spawn_position_boxes = [
#     outbound_pavement.rescale(x_scale=x_scale, y_scale=y_scale),
#     inbound_pavement.rescale(x_scale=x_scale, y_scale=y_scale)