Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/recording #12

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
venv/
__pycache__/
__pycache__/
video/
3 changes: 2 additions & 1 deletion golem_driving/envs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def add_env_args(parser: ArgumentParser) -> type(None):
parser.add_argument('--domain-rand', action='store_true', help='enable domain randomization')
parser.add_argument('--frame-skip', default=1, type=int, help='number of frames to skip')
parser.add_argument('--frame-rate', default=None, help='number of frames per second')

parser.add_argument('--dir', default='./video', help='directory in which recordings are stored')
lychanl marked this conversation as resolved.
Show resolved Hide resolved

def get_env_from_args(args, discrete: bool=False) -> Callable[[], Simulator]:
def builder():
Expand All @@ -28,6 +28,7 @@ def builder():
domain_rand=args.domain_rand,
frame_skip=args.frame_skip,
distortion=args.distortion,

)
else:
env = gym.make(args.env_name)
Expand Down
8 changes: 3 additions & 5 deletions golem_driving/run/show.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import pyglet
from gym.wrappers import Monitor
from pyglet.window import key
from gym_duckietown.simulator import Simulator

from golem_driving.agents.agent import Agent
from golem_driving.config import ShowConfig


def show(env: Simulator, agent: Agent, config: ShowConfig) -> type(None):
def show(env, agent, config, directory):
DawidRucinski marked this conversation as resolved.
Show resolved Hide resolved
env = Monitor(env, directory, video_callable=lambda episode_id: True, force=True)
obs = env.reset()
env.render()

Expand Down
5 changes: 3 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
args = parser.parse_args()

mode = modes.get(args.mode)

directory = args.dir
print(directory)
with open(args.config, 'r') as config_file:
config = mode.config()
config.load(config_file)

with get_env_from_args(args, discrete=False) as env:
agent = config.build_agent()

mode.run(env=env, agent=agent, config=config)
mode.run(env=env, agent=agent, config=config, directory=directory)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
numpy
gym
tensorflow==1.*
baselines
Expand Down