def __init__(self, cost, x0, dt): super(Car, self).__init__(self.ode, cost, x0, 2, dt) self.xIsAngle = [False, False, True, False] self.o = observation(self.x, self.xIsAngle) self.o_ = self.o self.oDim = len(self.o) # observation dimensions self.uMax = np.array([.5, 2.])
def __init__(self, cost, x0, dt): super(MarBot, self).__init__(self.ode, cost, x0, 1, dt) self.xIsAngle = [False, True, False, False] self.o = observation(self.x, self.xIsAngle) self.oDim = len(self.o) # observation dimensions self.o_ = self.o self.uMax = 2 * np.ones(1)
def ode(self, x, u): self.eval() o = observation(x, self.xIsAngle) o = torch.Tensor(o).reshape(1, self.oDim) o = (o - self.oMean) / self.oVar u = torch.Tensor(u).reshape(1, self.uDim) u = (u - self.uMean) / self.uVar dxdt = self.forward(o, u).detach() dxdt = (dxdt * self.dxVar + self.dxMean).numpy() return dxdt[0]
def __init__(self, cost, x0, dt, linearized=True): self.ode, self.A, self.B = acrobot_ode(linearized=linearized) super(Acrobot, self).__init__(self.ode, cost, x0, 1, dt) self.xIsAngle = [True, True, False, False] self.o = observation(self.x, self.xIsAngle) self.oDim = len(self.o) # observation dimensions self.o_ = self.o if linearized: self.uMax = 50 * np.ones(1) else: self.uMax = 5 * np.ones(1)
def __init__(self, cost, x0, dt, linearized=True): self.ode, self.A, self.B = cart_pole_triple_ode(linearized=linearized) super(CartPoleTriple, self).__init__(self.ode, cost, x0, 1, dt) self.xIsAngle = [False, True, True, True, False, False, False, False] self.o = observation(self.x, self.xIsAngle) self.oDim = len(self.o) #observation dimensions self.o_ = self.o if linearized: self.uMax = 20 * np.ones(1) else: self.uMax = 100 * np.ones(1) self.x1Max = 1.5
def __init__(self, cost, x0, dt, linearized=True, task='swing_up'): self.ode, self.A, self.B = cart_pole_double_serial_ode( linearized=linearized) super(CartPoleDoubleSerial, self).__init__(self.ode, cost, x0, 1, dt) self.xIsAngle = [False, True, True, False, False, False] self.o = observation(self.x, self.xIsAngle) self.oDim = len(self.o) #observation dimensions self.o_ = self.o if linearized: self.uMax = 15 * np.ones(1) else: self.uMax = 100 * np.ones(1) self.task = task self.x1Max = 1.5
def observe(self, x): obsv = observation(x, self.xIsAngle) return obsv