Source code for fluids.actions

import numpy as np

class Action(object):
    def get_action(self):
        raise NotImplementedError

    def get_array(self):
        raise NotImplementedError
[docs]class KeyboardAction(Action): """ This action passes control to keyboard input """ pass
[docs]class SteeringAccAction(Action): """ This action provides both steering and acceleration control. Parameters ---------- steer: float in range (-1, 1) acc: float in range (-1, 1) """ def __init__(self, steer, acc): self.steer = steer self.acc = acc def get_action(self): return self.steer, self.acc def get_array(self): return np.array([self.steer, self.acc]) def asSteeringAction(self): return SteeringAction(self.steer)
[docs]class SteeringAction(Action): """ This action provides a steering control. The supervisor will control the acceleration Parameters ---------- steer: float in range (-1, 1) """ def __init__(self, steer): self.steer = steer def get_action(self): return self.steer def get_array(self): return np.array([self.steer])
[docs]class VelocityAction(Action): """ This action provides a target velocity for the car to track Parameters ---------- vel: float in range (0, 1) """ def __init__(self, vel): self.vel = vel def get_action(self): return self.vel def get_array(self): return np.array([self.vel])
[docs]class LastValidAction(Action): """ This action causes car to replay its last valid action. This is useful when testing coarse planning methods. """ def __init__(self): pass