Commit c556a713 authored by ml's avatar ml
Browse files

changed limits

parent 51976292
......@@ -18,7 +18,7 @@ register(
id='CartpoleStabRR-v0',
entry_point='quanser_robots.cartpole.cartpole_rr:Cartpole',
max_episode_steps=10000,
kwargs={'ip': '192.172.162.1', 'fs_ctrl': 500.0, 'stabilization':True}
kwargs={'ip': '192.168.2.17', 'fs_ctrl': 500.0, 'stabilization':True}
)
register(
id='CartpoleSwingShort-v0',
......@@ -36,7 +36,7 @@ register(
id='CartpoleSwingRR-v0',
entry_point='quanser_robots.cartpole.cartpole_rr:Cartpole',
max_episode_steps=10000,
kwargs={'ip': '192.172.162.1', 'fs_ctrl': 500.0, 'stabilization':False}
kwargs={'ip': '192.168.2.17', 'fs_ctrl': 500.0, 'stabilization':False}
)
......@@ -39,7 +39,9 @@ class Cartpole(Simulation, CartpoleBase):
pos = Simulation._sim_step(self, a)
# Normalize the angle from -pi to +pi:
pos[1] = np.mod(pos[1] + np.pi, 2. * np.pi) - np.pi
if np.abs(pos[1]) > np.pi + 7.5 * np.pi / 180.:
pos[1] = np.mod(pos[1] + np.pi, 2. * np.pi) - np.pi
return pos
def render(self, mode='human'):
......
......@@ -17,6 +17,7 @@ class Cartpole(CartpoleBase):
self._calibrated = False
self.c_lim = 0.075
self._norm_x_lim = np.zeros(2, dtype=np.float32)
self._prev_angle = 0.0
def __del__(self):
if self._qsoc.is_open():
......@@ -153,6 +154,12 @@ class Cartpole(CartpoleBase):
# Normalize the angle from -pi to +pi:
pos[1] = np.mod(pos[1] + np.pi, 2. * np.pi) - np.pi
if pos[1] * self._prev_angle < 0 and np.pi - np.abs(pos[1]) < 7.5 * np.pi / 180.:
pos[1] = np.sign(self._prev_angle) * (2. * np.pi - np.abs(pos[1]))
self._prev_angle = pos[1]
return np.concatenate([pos, x_dot, th_dot])
def reset(self, verbose=True):
......
......@@ -110,7 +110,7 @@ def main():
plot = PlotSignal(window=window)
# Initialize Controller & Environment:
env, ctrl = get_env_and_controller(long_pendulum=False, simulation=True, swinging=True, mouse_control=False)
env, ctrl = get_env_and_controller(long_pendulum=False, simulation=False, swinging=True, mouse_control=False)
n_episodes = 5
time_steps = int(15. * 500.)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment