Husky camera live driving mode
This commit is contained in:
parent
1572bd7365
commit
67046d81b0
|
@ -0,0 +1,9 @@
|
|||
from realenv.envs.husky_env import HuskyCameraEnv
|
||||
from realenv.utils.play import play
|
||||
|
||||
timestep = 1.0/(4 * 18)
|
||||
frame_skip = 4
|
||||
|
||||
if __name__ == '__main__':
|
||||
env = HuskyCameraEnv(human=True, timestep=timestep, frame_skip=frame_skip, enable_sensors=False, is_discrete = True)
|
||||
play(env, zoom=4, fps=int( 1.0/(timestep * frame_skip)))
|
|
@ -237,7 +237,7 @@ class Husky(WalkerBase):
|
|||
self.eye_offset_orn = euler2quat(np.pi/2, 0, np.pi/2, axes='sxyz')
|
||||
|
||||
self.torque = 0.1
|
||||
self.action_list = [[0, 0,self.torque,self.torque], [0,0,-self.torque,-self.torque], [self.torque,-self.torque,self.torque,-self.torque],[-self.torque,self.torque,-self.torque,self.torque], [0, 0, 0, 0]]
|
||||
self.action_list = [[0, 0, 0.9 *self.torque, 0.9*self.torque], [- 1.5* self.torque,- 1.5* self.torque, 0, 0], [self.torque,-self.torque,self.torque,-self.torque],[-self.torque,self.torque,-self.torque,self.torque], [0, 0, 0, 0]]
|
||||
self.setup_keys_to_action()
|
||||
|
||||
def apply_action(self, action):
|
||||
|
|
|
@ -19,6 +19,7 @@ import pickle
|
|||
|
||||
HIGH_RES_MONITOR = False
|
||||
MAKE_VIDEO = False
|
||||
LIVE_DEMO = True
|
||||
|
||||
## Small model: 11HB6XZSh1Q
|
||||
## Gates Huang: BbxejD15Etk
|
||||
|
|
|
@ -27,15 +27,16 @@ class HuskyCameraEnv(HuskyEnv, CameraRobotEnv):
|
|||
HuskyEnv.__init__(self, is_discrete)
|
||||
CameraRobotEnv.__init__(self)
|
||||
|
||||
self.tracking_camera['pitch'] = -45 ## stairs
|
||||
#self.tracking_camera['pitch'] = -45 ## stairs
|
||||
#yaw = 0 ## demo: living room
|
||||
#yaw = 30 ## demo: kitchen
|
||||
self.tracking_camera['yaw'] = 90 ## demo: stairs
|
||||
|
||||
#self.tracking_camera['yaw'] = 90 ## demo: stairs
|
||||
|
||||
'''
|
||||
self.tracking_camera['yaw'] = 80
|
||||
|
||||
self.tracking_camera['yaw'] = 90 ## living roon
|
||||
self.tracking_camera['pitch'] = -10
|
||||
'''
|
||||
|
||||
self.tracking_camera['distance'] = 1.2
|
||||
self.tracking_camera['z_offset'] = 0.5
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ def play(env, transpose=True, fps=30, zoom=None, callback=None, keys_to_action=N
|
|||
# assert False, env.spec.id + " does not have explicit key to action mapping, " + \
|
||||
# "please specify one manually"
|
||||
relevant_keys = set(sum(map(list, keys_to_action.keys()),[]))
|
||||
|
||||
relevant_keys.add(ord('r'))
|
||||
'''
|
||||
if transpose:
|
||||
video_size = env.observation_space.shape[1], env.observation_space.shape[0]
|
||||
|
@ -116,11 +116,13 @@ def play(env, transpose=True, fps=30, zoom=None, callback=None, keys_to_action=N
|
|||
print("keys to actions", keys_to_action)
|
||||
|
||||
obs = env.reset()
|
||||
|
||||
do_restart = False
|
||||
while running:
|
||||
#if env_done:
|
||||
# env_done = False
|
||||
# obs = env.reset()
|
||||
#else:
|
||||
if do_restart:
|
||||
do_restart = False
|
||||
env.reset()
|
||||
continue
|
||||
if len(pressed_keys) == 0:
|
||||
action = keys_to_action[()]
|
||||
obs, rew, env_done, info = env.step(action)
|
||||
|
@ -145,7 +147,6 @@ def play(env, transpose=True, fps=30, zoom=None, callback=None, keys_to_action=N
|
|||
print(events)
|
||||
key_codes = events.keys()
|
||||
for key in key_codes:
|
||||
print(key, events[key], p.KEY_IS_DOWN, p.KEY_WAS_RELEASED)
|
||||
if key not in relevant_keys:
|
||||
continue
|
||||
# test events, set key states
|
||||
|
@ -158,6 +159,11 @@ def play(env, transpose=True, fps=30, zoom=None, callback=None, keys_to_action=N
|
|||
#if event.key in relevant_keys:
|
||||
if key in pressed_keys:
|
||||
pressed_keys.remove(key)
|
||||
|
||||
print(ord('r') in key_codes)
|
||||
if ord('r') in key_codes and events[ord('r')] == p.KEY_IS_DOWN:
|
||||
do_restart = True
|
||||
pressed_keys = []
|
||||
#print(pressed_keys)
|
||||
'''
|
||||
elif event.type == pygame.QUIT:
|
||||
|
|
Loading…
Reference in New Issue