mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-14 05:40:05 +00:00
fix new minitaur envs for newer Gym (_step -> step etc),
add extra sleep to sync Minitaur walk with RTC clock
This commit is contained in:
parent
ac945df07a
commit
ad75ea35b3
@ -17,6 +17,7 @@ import minitaur_logging
|
||||
import minitaur_logging_pb2
|
||||
import minitaur_rainbow_dash
|
||||
import motor
|
||||
from pkg_resources import parse_version
|
||||
|
||||
NUM_MOTORS = 8
|
||||
MOTOR_ANGLE_OBSERVATION_INDEX = 0
|
||||
@ -563,6 +564,13 @@ class MinitaurGymEnv(gym.Env):
|
||||
"""
|
||||
return len(self._get_observation())
|
||||
|
||||
if parse_version(gym.__version__)>=parse_version('0.9.6'):
|
||||
close = _close
|
||||
render = _render
|
||||
reset = _reset
|
||||
seed = _seed
|
||||
step = _step
|
||||
|
||||
def set_time_step(self, control_step, simulation_step=0.001):
|
||||
"""Sets the time step of the environment.
|
||||
|
||||
@ -604,3 +612,5 @@ class MinitaurGymEnv(gym.Env):
|
||||
@property
|
||||
def env_step_counter(self):
|
||||
return self._env_step_counter
|
||||
|
||||
|
||||
|
@ -9,6 +9,7 @@ import argparse
|
||||
import numpy as np
|
||||
import tensorflow as tf
|
||||
import minitaur_gym_env
|
||||
import time
|
||||
|
||||
|
||||
#FLAGS = flags.FLAGS
|
||||
@ -53,6 +54,7 @@ def ResetPoseExample(log_path=None):
|
||||
action = [math.pi / 2] * 8
|
||||
for _ in range(steps):
|
||||
_, _, done, _ = environment.step(action)
|
||||
time.sleep(1./100.)
|
||||
if done:
|
||||
break
|
||||
|
||||
@ -96,6 +98,7 @@ def MotorOverheatExample(log_path=None):
|
||||
observation, _, _, _ = environment.step(action)
|
||||
current_row.extend(observation.tolist())
|
||||
actions_and_observations.append(current_row)
|
||||
time.sleep(1./100.)
|
||||
|
||||
if FLAGS.output_filename is not None:
|
||||
WriteToCSV(FLAGS.output_filename, actions_and_observations)
|
||||
@ -142,6 +145,7 @@ def SineStandExample(log_path=None):
|
||||
observation, _, _, _ = environment.step(action)
|
||||
current_row.extend(observation.tolist())
|
||||
actions_and_observations.append(current_row)
|
||||
time.sleep(1./100.)
|
||||
|
||||
if FLAGS.output_filename is not None:
|
||||
WriteToCSV(FLAGS.output_filename, actions_and_observations)
|
||||
@ -189,6 +193,8 @@ def SinePolicyExample(log_path=None):
|
||||
a4 = math.sin(t * speed + math.pi) * amplitude2
|
||||
action = [a1, a2, a2, a1, a3, a4, a4, a3]
|
||||
_, reward, done, _ = environment.step(action)
|
||||
time.sleep(1./100.)
|
||||
|
||||
sum_reward += reward
|
||||
if done:
|
||||
tf.logging.info("Return is {}".format(sum_reward))
|
||||
|
Loading…
Reference in New Issue
Block a user