Ejemplo n.º 1
0
(height, width, depth) = obs.shape
at_Stop_Line = False
time_after_stop = 20
lower_red = np.array([140, 20, 20])
upper_red = np.array([255, 120, 140])
turn_right = False
turn_left = False
time_at_curve = 0
while True:

    k_p = 40  #Default=40                          60
    k_d = 10  #Defautl=10                          30
    speed = 0.3  #Default=0.3                   max = 1

    if turn_right:
        i, j = env.get_grid_coords(env.cur_pos)
        x, _, z = env.get_dir_vec()
        x = round(x)
        z = round(z)
        j_rounded = j + z
        i_rounded = i + x
        direction2 = None
        print(x, z, 'Direzione presa')
        if x == 0 and z == 1:
            direction2 = 'S'
        elif x == 0 and z == -1:
            direction2 = 'N'
        elif x == 1 and z == 0:
            direction2 = 'E'
        elif x == -1 and z == 0:
            direction2 = 'O'
Ejemplo n.º 2
0
    env = gym.make(args.env_name)

obs = env.reset()
env.render()

total_reward = 0

while True:

    lane_pose = env.get_lane_pos2(env.cur_pos, env.cur_angle)
    distance_to_road_center = lane_pose.dist
    angle_from_straight_in_rads = lane_pose.angle_rad

#####
    info = env.get_agent_info()
    i, j = env.get_grid_coords(info['Simulator']['cur_pos'])
    print((i,j))
    print(env._get_tile(i,j))
#####

    ###### Start changing the code here.
    # TODO: Decide how to calculate the speed and direction.

    k_p = 5#10
    k_d = 2#1
    
    # The speed is a value between [0, 1] (which corresponds to a real speed between 0m/s and 1.2m/s)
    
    speed = 0.2 # TODO: You should overwrite this value
    
    # angle of the steering wheel, which corresponds to the angular velocity in rad/s