-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4c81de8
Showing
37 changed files
with
22,296 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.