diff --git a/build.sh b/build.sh deleted file mode 100755 index 16c97dd94..000000000 --- a/build.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -g++ -std=c++11 render.cpp -o render.so -shared -fPIC -O2 -D_GLIBCXX_USE_CXX11_ABI=0 - - diff --git a/init.sh b/init.sh index 79e03d3cb..3783af1cf 100755 --- a/init.sh +++ b/init.sh @@ -1,3 +1,5 @@ +./realenv/envs/build.sh + x_display=1 Xvnc4 :$x_display -PasswordFile pw -Zliblevel 0 -depth 24 -geometry 512x256 2>&1 & echo "Using display: x_display=$x_display" @@ -5,4 +7,4 @@ echo "Using display: x_display=$x_display" export DISPLAY=":$x_display" xsetroot -solid grey -cursor_name left_ptr -python show_3d.py --dataroot ~/Development/data/viewsyn_tiny/ --idx 3 --model compG_epoch3_10000.pth +python realenv/envs/show_3d.py --dataroot ~/Development/data/viewsyn_tiny/ --idx 3 --model compG_epoch3_10000.pth diff --git a/realenv/agents/random_agent.py b/realenv/agents/random_agent.py index 1efb9d9f1..f71f4d252 100644 --- a/realenv/agents/random_agent.py +++ b/realenv/agents/random_agent.py @@ -35,12 +35,11 @@ if __name__ == '__main__': observation, infos, err = client.reset() else: action = agent.act(ob) - print('action', action) observation, infos, err = client.step(action) - # display + ## display if any(infos[i]['stats.vnc.updates.n'] for i in infos.keys()): + # TODO: is network causing bottleneck here? for ob in observation.keys(): - # print(observation[ob]) viewer.imshow(observation[ob]) time.sleep(0.2) diff --git a/realenv/client/vnc_client.py b/realenv/client/vnc_client.py index 80642c80c..ad954bd3f 100644 --- a/realenv/client/vnc_client.py +++ b/realenv/client/vnc_client.py @@ -55,7 +55,9 @@ class VNCClient: def step(self, action): observations, infos, errors = self.vnc_session.step({CONNECTION_NAME: [("KeyEvent", keycode(action), 1)]}) - observations, infos, errors = self.vnc_session.step({CONNECTION_NAME: [("KeyEvent", keycode(action), 0)]}) + # TODO: botton release causes bug here + # self.vnc_session.step({CONNECTION_NAME: [("KeyEvent", keycode(action), 0)]}) + # observations, infos, errors = self.vnc_session.step({CONNECTION_NAME: [("KeyEvent", keycode(action), 0)]}) return observations, infos, errors diff --git a/realenv/envs/build.sh b/realenv/envs/build.sh new file mode 100755 index 000000000..b2165bc45 --- /dev/null +++ b/realenv/envs/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash +g++ -std=c++11 ./realenv/envs/render.cpp -o ./realenv/envs/render.so -shared -fPIC -O2 -D_GLIBCXX_USE_CXX11_ABI=0 + + diff --git a/completion.py b/realenv/envs/completion.py similarity index 100% rename from completion.py rename to realenv/envs/completion.py diff --git a/datasets.py b/realenv/envs/datasets.py similarity index 100% rename from datasets.py rename to realenv/envs/datasets.py diff --git a/render.cpp b/realenv/envs/render.cpp similarity index 99% rename from render.cpp rename to realenv/envs/render.cpp index 56cf85bb6..70e005e88 100644 --- a/render.cpp +++ b/realenv/envs/render.cpp @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/show_3d.py b/realenv/envs/show_3d.py similarity index 98% rename from show_3d.py rename to realenv/envs/show_3d.py index ecc52a9ca..034db8e61 100644 --- a/show_3d.py +++ b/realenv/envs/show_3d.py @@ -1,6 +1,7 @@ import numpy as np import ctypes as ct import cv2 +import os import sys import argparse from datasets import ViewDataSet3D @@ -24,7 +25,9 @@ mousedown = False clickstart = (0,0) fps = 0 -dll=np.ctypeslib.load_library('render','.') +dir_path = os.path.dirname(os.path.realpath(__file__)) + "/" +print(dir_path) +dll=np.ctypeslib.load_library('render', dir_path) def onmouse(*args): diff --git a/utils.py b/realenv/envs/utils.py similarity index 100% rename from utils.py rename to realenv/envs/utils.py diff --git a/vision_utils.py b/realenv/envs/vision_utils.py similarity index 100% rename from vision_utils.py rename to realenv/envs/vision_utils.py diff --git a/setup.py b/setup.py index 1abeaa2e0..1ee66cba5 100644 --- a/setup.py +++ b/setup.py @@ -5,28 +5,32 @@ from subprocess import check_call from distutils.command.build_py import build_py as _build_py import sys, os.path - +''' class PostInstallCommand(install): """Post-installation for installation mode.""" def run(self): print('post installation') - check_call("bash build.sh".split()) + check_call("bash realenv/envs/build.sh".split()) install.run(self) - +''' setup(name='realenv', - description='Real Environment Developed by Stanford University', - url='https://github.com/fxia22/realenv', - author='Stanford University', - zip_safe=False, - install_requires=[ - 'numpy>=1.10.4', - 'go-vncdriver>=0.4.19', - 'pyglet>=1.2.0', - 'gym>=0.9.2' - ], - tests_require=[], - cmdclass={ - 'install': PostInstallCommand - } + version='0.0.1', + description='Real Environment Developed by Stanford University', + url='https://github.com/fxia22/realenv', + author='Stanford University', + zip_safe=False, + install_requires=[ + 'numpy>=1.10.4', + 'go-vncdriver>=0.4.19', + 'pyglet>=1.2.0', + 'gym>=0.9.2' + ], + tests_require=[], + # cmdclass={ + # 'install': PostInstallCommand + #} ) + + +# check_call("bash realenv/envs/build.sh".split()) \ No newline at end of file