Files
kair_algorithms_draft/scripts/run_lunarlander_continuous.py
T
Whi Kwon 37e9697b1b Refactor OpenManipulator env class (#46)
* Merge subin branch

Squashed commit of the following:

commit 98112b8c05f955b1eb49a6b78023cad0979d5f95
Author: Subin Yang <ysb8049@naver.com>
Date:   Sat Mar 30 18:19:46 2019 +0900

    Remove noqa

commit f45571a80afd403c8ec56db8a2fb5cbedf288db7
Author: Subin Yang <ysb8049@naver.com>
Date:   Sat Mar 30 17:50:39 2019 +0900

    Resolve flake8

commit 058d85bc4ed09441d27065e6d304bfb946942a98
Author: Subin Yang <ysb8049@naver.com>
Date:   Sat Mar 30 17:41:35 2019 +0900

    Modify structures of ros interface and reacher env

commit ae4c859ffa6b008823050f310bdccbee6a1de30a
Author: Subin Yang <ysb8049@naver.com>
Date:   Sat Mar 30 17:28:15 2019 +0900

    Resolve flake8

commit 4c74ec6527b52d75882ddbe1b4f518f9c252a25c
Author: Subin Yang <ysb8049@naver.com>
Date:   Sat Mar 30 17:23:30 2019 +0900

    Resolve flake8

commit 243b2f3739b4388d814a886d5cf1b85a05bb526a
Author: Subin Yang <ysb8049@naver.com>
Date:   Sat Mar 30 17:18:13 2019 +0900

    Add open manipulator environment

* Refactor openmanipulator environment class

* Refactored env structure

* Fix errors

* Fix error

* Add open_manipulator launch file

* Fix errors

* fix error

* fix error

* fix error

* fix error

* fix error

* fix error

* fix error

* Fix typo

* Delete unused script

* Change reward

* Fix typo, add env name to config

* Change demo file compatible to python2 (#40)

* Change demo file to python2 compatible

* Add object to classes for compatibility with python2

* Refactoring config, envs and ros interface (#48)

* Refactoring config architecture

* Replace network hyper params on agent config

* Modify env class and ros interface class

* Modify getter and setter on ros interface

* Modify wrong code

* Fix typo

* Add env config

* Final environment class and test scripts before the test (#43)

* new user branch

* Resolve formatting issues on test scripts

* Resolve formatting issues on test scripts

* Merge subin branch

Squashed commit of the following:

commit 98112b8c05f955b1eb49a6b78023cad0979d5f95
Author: Subin Yang <ysb8049@naver.com>
Date:   Sat Mar 30 18:19:46 2019 +0900

    Remove noqa

commit f45571a80afd403c8ec56db8a2fb5cbedf288db7
Author: Subin Yang <ysb8049@naver.com>
Date:   Sat Mar 30 17:50:39 2019 +0900

    Resolve flake8

commit 058d85bc4ed09441d27065e6d304bfb946942a98
Author: Subin Yang <ysb8049@naver.com>
Date:   Sat Mar 30 17:41:35 2019 +0900

    Modify structures of ros interface and reacher env

commit ae4c859ffa6b008823050f310bdccbee6a1de30a
Author: Subin Yang <ysb8049@naver.com>
Date:   Sat Mar 30 17:28:15 2019 +0900

    Resolve flake8

commit 4c74ec6527b52d75882ddbe1b4f518f9c252a25c
Author: Subin Yang <ysb8049@naver.com>
Date:   Sat Mar 30 17:23:30 2019 +0900

    Resolve flake8

commit 243b2f3739b4388d814a886d5cf1b85a05bb526a
Author: Subin Yang <ysb8049@naver.com>
Date:   Sat Mar 30 17:18:13 2019 +0900

    Add open manipulator environment

* Refactor openmanipulator environment class

* Test the training loop with td3 baseline

* Add one-shot launch file for gazebo initialization

* Refactored env structure

* Fix errors

* Fix error

* Fix errors

* fix error

* fix error

* fix error

* fix error

* fix error

* fix error

* fix error

* Fix typo

* Delete unused script

* Change reward

* Fix typo, add env name to config

* Refactoring config, envs and ros interface (#48)

* Refactoring config architecture

* Replace network hyper params on agent config

* Modify env class and ros interface class

* Modify getter and setter on ros interface

* Modify wrong code

* Fix typo

* Add env config

* Resolve flake8, typo issue

* Resolve conflict during pull remote
2019-04-09 20:45:21 +09:00

76 lines
1.9 KiB
Python

# -*- coding: utf-8 -*-
"""Train or test baselines on LunarLanderContinuous-v2.
- Author: Curt Park
- Contact: curt.park@medipixel.io
"""
import argparse
import importlib
import gym
import algorithms.common.helper_functions as common_utils
# configurations
parser = argparse.ArgumentParser(description="Pytorch RL baselines")
parser.add_argument(
"--seed", type=int, default=777, help="random seed for reproducibility"
)
parser.add_argument("--algo", type=str, default="sac", help="choose an algorithm")
parser.add_argument(
"--load-from",
type=str,
default=None,
help="load the saved model and optimizer at the beginning",
)
parser.add_argument("--episode-num", type=int, default=1500, help="total episode num")
parser.add_argument(
"--max-episode-steps", type=int, default=300, help="max episode step"
)
parser.add_argument(
"--off-render", dest="render", action="store_false", help="turn off rendering"
)
parser.add_argument(
"--render-after",
type=int,
default=0,
help="start rendering after the input number of episode",
)
parser.add_argument("--save-period", type=int, default=100, help="save model period")
parser.add_argument("--log", action="store_true", help="turn on logging")
parser.add_argument("--test", action="store_true", help="test mode (no training)")
parser.add_argument(
"--demo-path",
type=str,
default="data/lunarlander_continuous_demo.pkl",
help="demonstration path",
)
parser.set_defaults(render=True)
args = parser.parse_args()
def main():
"""Main."""
# env initialization
env = gym.make("LunarLanderContinuous-v2")
# set a random seed
common_utils.set_random_seed(args.seed, env)
# run
module_path = "config.agent.lunarlander_continuous_v2." + args.algo
agent = importlib.import_module(module_path)
agent = agent.get(env, args)
# run
if args.test:
agent.test()
else:
agent.train()
if __name__ == "__main__":
main()