Exemplo n.º 1
0
    def __init__(self, start_wp=None, end_wp=None, wp_width=5, **kwargs):
        # FCF59B
        Shape.__init__(self, color=(0xFF, 0xFF, 0xFF), **kwargs)

        if start_wp is not None and end_wp is not None:
            self.start_waypoint = start_wp
            self.end_waypoint = end_wp
        else:
            self.start_waypoint = (self.points[2] + self.points[3]) / 2
            self.end_waypoint = (self.points[0] + self.points[1]) / 2

            self.start_waypoint = Waypoint(
                self.start_waypoint[0],
                self.start_waypoint[1],
                ydim=wp_width,
                owner=self,
                angle=self.angle,
            )
            self.end_waypoint = Waypoint(
                self.end_waypoint[0],
                self.end_waypoint[1],
                ydim=wp_width,
                owner=self,
                angle=self.angle,
            )

            self.start_waypoint.nxt = [self.end_waypoint]
 def __init__(self, max_vel=2, vel=0, planning_depth=2, **kwargs):
     Shape.__init__(self, color=(255, 250, 150), xdim=20, ydim=20, **kwargs)
     self.max_vel = max_vel
     self.vel = vel
     self.waypoints = []
     self.trajectory = []
     self.planning_depth = planning_depth
Exemplo n.º 3
0
    def __init__(self, vel=0, mass=400, max_vel=5,
                 planning_depth=20, **kwargs):
        from fluids.assets import Lane, Car, Pedestrian, TrafficLight, Terrain, Sidewalk, PedCrossing
        collideables = [Lane,
                        Car,
                        Pedestrian,
                        TrafficLight,
                        Terrain,
                        Sidewalk,
                        PedCrossing]
        Shape.__init__(self,
                       collideables=collideables,
                       color=(20, 150, 250),
                       xdim=70,
                       ydim=35,
                       **kwargs)

        self.l_r            = self.l_f = self.ydim / 2
        self.mass           = mass
        self.max_vel        = max_vel
        self.vel            = vel
        self.waypoints      = []
        self.trajectory     = []
        self.planning_depth = planning_depth
        self.PID_acc        = PIDController(1.0, 0, 0)
        self.PID_steer      = PIDController(2.0, 0, 0)
        self.last_action    = SteeringAction(0, 0)
        self.last_obs       = None
        self.last_distance  = 0
        self.last_to_goal   = 0
        self.stopped_time   = 0
        self.running_time   = 0

        self.last_blob_time = -1
        self.cached_blob    = self.get_future_shape()
Exemplo n.º 4
0
 def __init__(self, max_vel=2, vel=0, planning_depth=2, dim=25, **kwargs):
     Shape.__init__(self, color=(0xF4, 0x80, 0x04), xdim=dim, ydim=dim, **kwargs)
     self.max_vel = max_vel
     self.vel = vel
     self.waypoints = []
     self.trajectory = []
     self.planning_depth = planning_depth
    def __init__(self, start_wps=[], end_wps=[], **kwargs):
        Shape.__init__(self, color=(0xf1, 0xf4, 0xf5), **kwargs)
        point0 = (self.points[2] + self.points[3]) / 2
        point1 = (self.points[0] + self.points[1]) / 2

        if len(start_wps) and len(end_wps):
            self.start_waypoints = start_wps
            self.end_waypoints = end_wps
        else:
            self.start_waypoints = [
                Waypoint(point0[0],
                         point0[1],
                         owner=self,
                         ydim=5,
                         angle=self.angle),
                Waypoint(point1[0],
                         point1[1],
                         owner=self,
                         ydim=5,
                         angle=self.angle + np.pi)
            ]
            self.end_waypoints = [
                Waypoint(point1[0],
                         point1[1],
                         owner=self,
                         ydim=5,
                         angle=self.angle),
                Waypoint(point0[0],
                         point0[1],
                         owner=self,
                         ydim=5,
                         angle=self.angle + np.pi)
            ]
            self.start_waypoints[0].nxt = [self.end_waypoints[0]]
            self.start_waypoints[1].nxt = [self.end_waypoints[1]]
Exemplo n.º 6
0
    def __init__(self, vel=0, mass=400, max_vel=5,
                 planning_depth=13, path=-1, **kwargs):
        from fluids.assets import Lane, Car, Pedestrian, TrafficLight, Terrain, Sidewalk, PedCrossing
        collideables = [Car,
                        Pedestrian]
        infractables = [Lane,
                        TrafficLight,
                        Terrain,
                        Sidewalk,
                        PedCrossing]
        Shape.__init__(self,
                       collideables=collideables,
                       infractables=infractables,
                       color=(0x1d, 0xb1, 0xb0),  # 769BB0
                       xdim=70,
                       ydim=35,
                       **kwargs)

        self.l_r = self.l_f = self.ydim / 2
        self.mass = mass
        self.max_vel = max_vel
        self.vel = vel
        self.waypoints = []
        self.trajectory = []
        self.planning_depth = planning_depth
        self.PID_acc = PIDController(1.0, 0, 0)
        self.PID_steer = PIDController(2.0, 0, 0)
        self.last_action = SteeringAccAction(0, 0)
        self.last_obs = None
        self.last_distance = 0
        self.last_to_goal = 0
        self.stopped_time = 0
        self.running_time = 0

        # Rewards metrics
        self.last_four_positions = [np.asarray((self.x, self.y)),
                                    np.asarray((self.x, self.y)),
                                    np.asarray((self.x, self.y)),
                                    np.asarray((self.x, self.y))]

        self.jerk = calc_jerk(self.last_four_positions)

        # Current reward
        self.current_reward = 0.0

        # Total reward
        self.total_collisions = 0.0
        self.total_infractions = 0.0
        self.total_time = 0.0
        self.total_liveliness = self.vel/self.max_vel
        self.total_jerk = self.jerk
        self.total_traj_follow = self.last_to_goal
        self.total_reward = 0.0

        self.last_blob_time = -1
        self.cached_blob = self.get_future_shape()
        self.path = path
        self.keep_random = False
        self.generated_first_traj = False
Exemplo n.º 7
0
    def __init__(self, **kwargs):
        Shape.__init__(self, color=(50, 50, 50), **kwargs)

        self.start_waypoint = (self.points[2] + self.points[3]) / 2
        self.end_waypoint = (self.points[0] + self.points[1]) / 2

        self.start_waypoint = Waypoint(self.start_waypoint[0],
                                       self.start_waypoint[1], self.angle)
        self.end_waypoint = Waypoint(self.end_waypoint[0],
                                     self.end_waypoint[1], self.angle)

        self.start_waypoint.nxt = [self.end_waypoint]
Exemplo n.º 8
0
    def __init__(self, **kwargs):
        Shape.__init__(self, color=(120, 150, 20), **kwargs)
        point0 = (self.points[2] + self.points[3]) / 2
        point1 = (self.points[0] + self.points[1]) / 2

        self.start_waypoints = [
            Waypoint(point0[0], point0[1], self.angle),
            Waypoint(point1[0], point1[1], self.angle + np.pi)
        ]
        self.end_waypoints = [
            Waypoint(point1[0], point1[1], self.angle),
            Waypoint(point0[0], point0[1], self.angle + np.pi)
        ]
        self.start_waypoints[0].nxt = [self.end_waypoints[0]]
        self.start_waypoints[1].nxt = [self.end_waypoints[1]]
    def __init__(self, init_color="red", **kwargs):
        color = {"red": RED, "green": GREEN, "yellow": YELLOW}[init_color]
        self.timer = {"red": 0, "green": 200, "yellow": 350}[init_color]

        Shape.__init__(self, xdim=20, ydim=60, color=color, **kwargs)
 def __init__(self, **kwargs):
     Shape.__init__(self, color=(0xff, 0xff, 0xff), **kwargs)
     self.in_waypoints = []
     self.out_waypoints = []
     self.intersection_waypoints = []
Exemplo n.º 11
0
 def __init__(self, **kwargs):
     Shape.__init__(self, color=(30, 30, 30), **kwargs)
     self.in_waypoints = []
     self.out_waypoints = []
Exemplo n.º 12
0
 def __init__(self, **kwargs):
     Shape.__init__(self, color=(150, 200, 150), **kwargs)
Exemplo n.º 13
0
 def __init__(self, **kwargs):
     Shape.__init__(self, color=(0xFD, 0xF8, 0xEF), **kwargs)
 def __init__(self, init_color="red", **kwargs):
     color = {"red": RED, "green": GREEN}[init_color]
     self.timer = {"red": 0, "green": 200}[init_color]
     Shape.__init__(self, xdim=10, ydim=30, color=color, **kwargs)
 def __init__(self, **kwargs):
     Shape.__init__(self, color=(0xfd,0xF8,0xef), **kwargs)