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

Allow User to Specify Port in Create 2 Examples #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
14 changes: 11 additions & 3 deletions examples/create2_docker.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import time
import copy
import numpy as np
Expand All @@ -14,9 +15,9 @@
from helper import create_callback


def main():
def main(args):
# Create the Create2 docker environment
env = Create2DockerEnv(30, port='/dev/ttyUSB0', ir_window=20, ir_history=1,
env = Create2DockerEnv(30, port=args['port'], ir_window=20, ir_history=1,
obs_history=1, dt=0.045)
env = NormalizedEnv(env)

Expand Down Expand Up @@ -194,5 +195,12 @@ def plot_create2_docker(env, batch_size, shared_returns, plot_running):
count += 1


def parse_args():
parser = argparse.ArgumentParser(description='Trains a Create 2 to dock at its charging '
'station.')
parser.add_argument('-p', '--port', default='/dev/ttyUSB0',
help='port to communicate with Create 2 on')
return vars(parser.parse_args())

if __name__ == '__main__':
main()
main(parse_args())
15 changes: 9 additions & 6 deletions examples/create2_mover.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import time
import copy
import numpy as np
Expand All @@ -14,9 +15,9 @@
from helper import create_callback


def main():
def main(args):
# Create the Create2 mover environment
env = Create2MoverEnv(90, port='/dev/ttyUSB0', obs_history=1, dt=0.15)
env = Create2MoverEnv(90, port=args['port'], obs_history=1, dt=0.15)
env = NormalizedEnv(env)

# Start environment processes
Expand Down Expand Up @@ -192,9 +193,11 @@ def plot_create2_mover(env, batch_size, shared_returns, plot_running):

count += 1

def parse_args():
parser = argparse.ArgumentParser(description='Trains a Create 2 to drive forwards.')
parser.add_argument('-p', '--port', default='/dev/ttyUSB0',
help='port to communicate with Create 2 on')
return vars(parser.parse_args())

if __name__ == '__main__':
main()



main(parse_args())