def __init__(self):
     self.fluidsim = fluids.FluidSim(**FLUIDS_ARGS)
     self.action_space = spaces.Box(np.array([-1, -1]), np.array([1, 1]))
     self.observation_space = spaces.Box(low=0,
                                         high=255,
                                         shape=(OBS_W, OBS_W, 3),
                                         dtype=np.uint8)
     self.fluids_action_type = fluids.SteeringAccAction
Esempio n. 2
0
 def __init__(self, fluids_args, obs_w, state_args, time_limit):
     self.fluidsim = fluids.FluidSim(**fluids_args)
     self.action_space = spaces.Box(np.array([-1, -1]), np.array([1, 1]))
     self.observation_space = spaces.Box(low=0,
                                         high=255,
                                         shape=(obs_w, obs_w, 3),
                                         dtype=np.uint8)
     self.fluids_action_type = fluids.SteeringAccAction
     self.state_args = state_args
     self.time_limit = time_limit
Esempio n. 3
0
    def __init__(self, obs_space):
        fluids_args = {
            "visualization_level": 1,
            "fps": 30,
            "obs_args": {
                "obs_dim": OBS_W
            },
            "obs_space": obs_space,
            "background_control": fluids.BACKGROUND_CSP
        }

        self.fluidsim = fluids.FluidSim(**fluids_args)
        self.action_space = spaces.Box(np.array([-1, -1]), np.array([1, 1]))
        self.observation_space = spaces.Box(low=0,
                                            high=255,
                                            shape=(OBS_W, OBS_W, 3),
                                            dtype=np.uint8)

        self.fluids_action_type = fluids.SteeringAccAction
import fluids
import pygame
import numpy as np

simulator = fluids.FluidSim(
    visualization_level=1,  # How much debug visualization you want to enable. Set to 0 for no vis
    fps=0,  # If set to non 0, caps the FPS. Target is 30
    obs_space=fluids.OBS_GRID,  # OBS_BIRDSEYE, OBS_GRID, or OBS_NONE
    background_control=fluids.BACKGROUND_CSP,
)  # BACKGROUND_CSP or BACKGROUND_NULL

state = fluids.State(
    layout=fluids.STATE_CITY,
    background_cars=10,  # How many background cars
    background_peds=10,
    controlled_cars=1,  # How many cars to control. Set to 0 for background cars only
)

simulator.set_state(state)

car_keys = simulator.get_control_keys()

while True:
    actions = {}

    # Uncomment any of these lines.
    # VelocityAction is vel for car to move along trajectory
    # SteeringAction is steer, acc control
    # KeyboardAction is use keyboard input
    # SteeringVelAction is steer, vel control
Esempio n. 5
0
fluids_print("            Num controlled peds : {}".format(args.p))
fluids_print("            Visualization level : {}".format(args.v))
fluids_print("            Observation type    : {}".format(args.o))
fluids_print("            Scene layout        : {}".format(args.state))
fluids_print("            Simulation time     : {}".format(
    "unlimited" if not args.time else args.time))
fluids_print("")

obs = {
    "none": fluids.OBS_NONE,
    "birdseye": fluids.OBS_BIRDSEYE,
    "grid": fluids.OBS_GRID
}[args.o]

simulator = fluids.FluidSim(visualization_level=args.v,
                            fps=0,
                            obs_space=obs,
                            background_control=fluids.BACKGROUND_CSP)

state = fluids.State(layout=args.state,
                     background_cars=args.b,
                     controlled_cars=args.c,
                     background_peds=args.p)

simulator.set_state(state)

t = 0
while not args.time or t < args.time:
    actions = {
        k: fluids.KeyboardAction()
        for k in simulator.get_control_keys()
    }
    "enabled" if args.trafficlights else "disabled"))
fluids_print("            Max FPS             : {}".format(
    "unbound" if not args.fps else args.fps))

fluids_print("")

obs = {
    "none": fluids.OBS_NONE,
    "birdseye": fluids.OBS_BIRDSEYE,
    "grid": fluids.OBS_GRID,
    "qlidar": fluids.OBS_QLIDAR
}[args.o]

simulator = fluids.FluidSim(visualization_level=args.v,
                            fps=args.fps,
                            obs_space=obs,
                            screen_dim=args.screen_dim,
                            background_control=fluids.BACKGROUND_CSP)

state = fluids.State(layout=args.state,
                     background_cars=args.b,
                     controlled_cars=args.c,
                     background_peds=args.p,
                     use_traffic_lights=args.trafficlights,
                     use_ped_lights=args.pedlights)

simulator.set_state(state)

if args.datasaver != "":
    data_saver = fluids.DataSaver(fluid_sim=simulator,
                                  file_path=args.datasaver,