Exemple #1
0
 def __init__(self, host, port):
     self.driving_env = DrivingSimulatorEnv(
         address=host,
         port=port,
         backend_cmds=gen_backend_cmds(),
         defs_obs=[('/training/image/compressed',
                    'sensor_msgs.msg.CompressedImage'),
                   ('/decision_result', 'std_msgs.msg.Int16')],
         defs_reward=[
             ('/rl/current_road_validity', 'std_msgs.msg.Int16'),
             ('/rl/entering_intersection', 'std_msgs.msg.Bool'),
             ('/rl/car_velocity_front', 'std_msgs.msg.Float32'),
             ('/rl/last_on_opposite_path', 'std_msgs.msg.Int16'),
             ('/rl/on_biking_lane', 'std_msgs.msg.Bool'),
             ('/rl/obs_factor', 'std_msgs.msg.Float32'),
             ('/rl/distance_to_longestpath', 'std_msgs.msg.Float32'),
         ],
         defs_action=[('/autoDrive_KeyboardMode', 'std_msgs.msg.Char')],
         rate_action=10.0,
         window_sizes={
             'obs': 3,
             'reward': 3
         },
         buffer_sizes={
             'obs': 3,
             'reward': 3
         },
         # should be wrapped
         func_compile_obs=func_compile_obs,
         func_compile_reward=func_compile_reward,
         func_compile_action=func_compile_action,
         step_delay_target=0.5)
env = DrivingSimulatorEnv(
    address="10.31.40.197",
    port='10024',
    # address='localhost', port='22224',
    backend_cmds=gen_backend_cmds(),
    defs_obs=[('/training/image/compressed',
               'sensor_msgs.msg.CompressedImage'),
              ('/decision_result', 'std_msgs.msg.Int16')],
    defs_reward=[
        ('/rl/has_obstacle_nearby', 'std_msgs.msg.Bool'),
        ('/rl/distance_to_longestpath', 'std_msgs.msg.Float32'),
        ('/rl/car_velocity', 'std_msgs.msg.Float32'),
        ('/rl/last_on_opposite_path', 'std_msgs.msg.Int16'),
        ('/rl/on_pedestrian', 'std_msgs.msg.Bool'),
        ('/rl/obs_factor', 'std_msgs.msg.Float32'),
    ],
    defs_action=[('/autoDrive_KeyboardMode', 'std_msgs.msg.Char')],
    rate_action=10.0,
    window_sizes={
        'obs': 2,
        'reward': 3
    },
    buffer_sizes={
        'obs': 2,
        'reward': 3
    },
    func_compile_obs=func_compile_obs,
    func_compile_reward=func_compile_reward,
    func_compile_action=func_compile_action,
    step_delay_target=0.5,
    is_dummy_action=False)
    ]
    return backend_cmds

env = DrivingSimulatorEnv(
    address="10.31.40.197", port='9004',
    # address='localhost', port='22224',
    backend_cmds=gen_backend_cmds(),
    defs_obs=[
        ('/training/image/compressed', 'sensor_msgs.msg.CompressedImage'),
        ('/decision_result', 'std_msgs.msg.Int16')
    ],
    defs_reward=[
        ('/rl/has_obstacle_nearby', 'std_msgs.msg.Bool'),
        ('/rl/distance_to_longestpath', 'std_msgs.msg.Float32'),
        ('/rl/car_velocity', 'std_msgs.msg.Float32'),
        ('/rl/last_on_opposite_path', 'std_msgs.msg.Int16'),
        ('/rl/on_pedestrian', 'std_msgs.msg.Bool'),
        ('/rl/obs_factor', 'std_msgs.msg.Float32'),
    ],
    defs_action=[('/autoDrive_KeyboardMode', 'std_msgs.msg.Char')],
    rate_action=10.0,
    window_sizes={'obs': 2, 'reward': 3},
    buffer_sizes={'obs': 2, 'reward': 3},
    func_compile_obs=func_compile_obs,
    func_compile_reward=func_compile_reward,
    func_compile_action=func_compile_action,
    step_delay_target=0.5,
    is_dummy_action=True)
# TODO: define these Gym related params insode DrivingSimulatorEnv
env.observation_space = Box(low=0, high=255, shape=(350, 350, 3))
env.reward_range = (-np.inf, np.inf)