Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
seann999 committed Mar 21, 2017
0 parents commit 4c81de8
Show file tree
Hide file tree
Showing 37 changed files with 22,296 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
setup:
1. install lis
2. replace lis/gym_client/gym/envs/unity folder with unity folder included here

for manual play:
$> ./test.x86_64 5000 1 0 0

6 changes: 6 additions & 0 deletions README.txt~
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
setup:
replace lis/gym_client/gym/envs/unity folder with unity folder included here

for manual play:
$> ./test.x86_64 5000 1 0 0

52 changes: 52 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import subprocess
import os
import gym
import cv2
import time
import numpy as np
import json

rand = False

game_processes = []

# port render_freq msg_freq server
game_processes.append(subprocess.Popen("./test.x86_64 5000 50 10 1", shell=True, stdout=subprocess.PIPE, preexec_fn=os.setsid))

time.sleep(7)

game = gym.make('Lis-v2')
game.configure("5000")

def get_extra(obs):
data = str(bytearray(obs["extra"]))
obj = json.loads(data)

return obj

for i in range(1000):
# prepare
observation, _, _, _ = game.step("-1 -1 -1")

obj = get_extra(observation)
loc = np.array(obj["coords"]).flatten()

print("true initial coordinates: %s" % loc)

cv2.imshow("frame", np.array(observation["image"][0])[:,:,[2,1,0]])
cv2.waitKey(1)

# act
if rand:
x = np.random.uniform(-5, 5, 2)
else:
x = [loc[0], loc[2]]

new_observation, reward, end_episode, _ = game.step("%s %s 1" % (x[0], x[1]))

# results
new_obj = get_extra(new_observation)
print("touch sensor: %s" % new_obj["touch"])
print("reward: %s" % reward)

print("-"*10)
Binary file added test.x86_64
Binary file not shown.
Binary file not shown.
Binary file added test_Data/Managed/Assembly-CSharp.dll
Binary file not shown.
Binary file added test_Data/Managed/Mono.Security.dll
Binary file not shown.
Binary file added test_Data/Managed/System.Core.dll
Binary file not shown.
Binary file added test_Data/Managed/System.dll
Binary file not shown.
Binary file added test_Data/Managed/UnityEngine.Networking.dll
Binary file not shown.
Binary file added test_Data/Managed/UnityEngine.UI.dll
Binary file not shown.
Binary file added test_Data/Managed/UnityEngine.dll
Binary file not shown.
Binary file added test_Data/Managed/UnityEngine.dll.mdb
Binary file not shown.
Binary file added test_Data/Managed/mscorlib.dll
Binary file not shown.
Loading

0 comments on commit 4c81de8

Please sign in to comment.