Giter Club home page Giter Club logo

gym-duckietown-agent's Introduction

gym-duckietown-agent

Docker Hub

Welcome to the gym-duckietown-agent, the default template for machine learning AI-DO submissions. It runs PyTorch, numpy, scipy and some other useful libraries for machine learning, however you can customize it to your liking.

There are two versions of the gym-duckietown-agent, both built from this repository and available on Docker Hub. The default version, duckietown/gym-duckietown-agent, runs on x86 and ARM devices. The GPU enabled version, duckietown/gym-duckietown-agent:gpu, runs on x86 or GPU-powered machines with nvidia-docker. Both of these depend on the duckietown/gym-duckietown simulator, or a compatible messaging interface. Below, you will find instructions for installing and running a gym-duckietown-agent container.

Prerequisites

To enable fully reproducible software environments, we use a container tool called Docker. For your convenience, we have prepared some reading material about Docker.

Setup

To get started, fork or clone this git repository and cd into the project directory:

git clone https://github.com/duckietown/gym-duckietown-agent.git && cd gym-duckietown-agent

Now, start the Docker containers (always make sure to have the latest simulator). On first start this will download the ~2GB duckietown/gym-duckietown-server container. Due to layer caching, successive starts should be significantly faster.

Several competition challenges are available to run.

To run the Lane Following (LF) task:

docker-compose -f docker-compose-lf.yml pull && \
docker-compose -f docker-compose-lf.yml up 

To run the Lane Following with Vehicles (LFV) task:

docker-compose -f docker-compose-lfv.yml pull && \
docker-compose -f docker-compose-lfv.yml up

This will give you a reward output like:

gym-duckietown-agent_1   | starting sub socket on 8902
gym-duckietown-agent_1   | listening for camera images
gym-duckietown-agent_1   | [Challenge: LF] The average reward of 10 episodes was -315.7005. Best episode: -283.9803, worst episode: -368.1122
gym-duckietown-agent_gym-duckietown-agent_1 exited with code 0

(The important bit is the second-to-last line above)

You can terminate the run at any time by pressing CTRL+c.

By default, Docker will use the ARM-emulator when running on x86, however you can switch to the GPU version by replacing duckietown/gym-duckietown-agent with duckietown/gym-duckietown-agent:gpu in your docker-compose*.yml file.

Write your own agent

To write your own agent, first fork this repository, and edit the file agent.py. Then run the following command from the root directory of this project on your local machine to evaluate the agent's performance:

docker build -t duckietown/gym-duckietown-agent . && \
docker-compose -f docker-compose-lf.yml up

Check the average reward and try to improve your score. Good luck!

Running

The duckietown/gym-duckietown-agent[:gpu] Docker image is based on PyTorch. You can use this image as a template for implementing your own agent. It runs on both x86 and ARM platforms.

ARM/x86

docker run -it duckietown/gym-duckietown-agent python -c "import torch; print(torch.randn(10))"

GPU

docker run -it duckietown/gym-duckietown-agent:gpu python -c "import torch; print(torch.randn(10))"

Building

Docker images for x86 and ARM are automatically rebuilt from this GitHub repository, however you should rebuild them locally when you want to test changes to the code.

To do so, first cd to the project directory on your local machine. Then, depending on whether you are targeting ARM/x86 or GPU, run one of the following commands:

ARM/x86

docker build -t duckietown/gym-duckietown-agent .

GPU

docker build --file=docker/gpu/Dockerfile -t duckietown/gym-duckietown-agent:gpu .

Submitting

When the competition opens, you will submit your Docker image using dts, the Duckietown Shell like so:

**** command not ready ****** 

The referenced Docker image will contain a pretrained model which you have trained locally. If you send us a GPU model, we will run it on the simulator only. If you send us an ARM image, we will evaluate the submission and run it on a physical robot, then send you a link to the corresponding log. Should you wish to participate in the robotarium challenge, you must submit an ARM-based image.

The leaderboard evaluation will occur in some randomized environments - so be careful not to overfit!

Customizing

By default, we provide a working PyTorch installation, however you can customize the duckietown/gym-duckietown-agent Dockerfile to use your favorite machine learning libraries. The only hard requirement is duckietown-slimremote to interact with the simulator. Here are some other popular machine learning libraries:

To customize the default distribution, modify the Dockerfile (or docker/gpu/Dockerfile if you are using a GPU) and rebuild the image using the build instructions.

gym-duckietown-agent's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gym-duckietown-agent's Issues

Getting Pillow Build error:

After trying to build with: docker-compose -f docker-compose-lf.yml up --build

got:

  warning: no files found matching '*.h'
  warning: no files found matching '*.sh'
  no previously-included directories found matching 'docs/_static'
  warning: no previously-included files found matching '.appveyor.yml'
  warning: no previously-included files found matching '.coveragerc'
  warning: no previously-included files found matching '.codecov.yml'
  warning: no previously-included files found matching '.editorconfig'
  warning: no previously-included files found matching '.landscape.yaml'
  warning: no previously-included files found matching '.travis'
  warning: no previously-included files found matching '.travis/*'
  warning: no previously-included files found matching 'tox.ini'
  warning: no previously-included files matching '.git*' found anywhere in distribution
  warning: no previously-included files matching '*.pyc' found anywhere in distribution
  warning: no previously-included files matching '*.so' found anywhere in distribution
  writing manifest file 'src/Pillow.egg-info/SOURCES.txt'
  running build_ext


  The headers or library files could not be found for jpeg,
  a required dependency when compiling Pillow from source.

  Please see the install instructions at:
     https://pillow.readthedocs.io/en/latest/installation.html

  Traceback (most recent call last):
    File "/tmp/pip-install-wk0bojxk/pillow/setup.py", line 795, in <module>
      zip_safe=not (debug_build() or PLATFORM_MINGW), )
    File "/usr/local/lib/python3.4/site-packages/setuptools/__init__.py", line 129, in setup
      return distutils.core.setup(**attrs)
    File "/usr/local/lib/python3.4/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/local/lib/python3.4/distutils/dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "/usr/local/lib/python3.4/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/usr/local/lib/python3.4/site-packages/wheel/bdist_wheel.py", line 202, in run
      self.run_command('build')
    File "/usr/local/lib/python3.4/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/local/lib/python3.4/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/usr/local/lib/python3.4/distutils/command/build.py", line 126, in run
      self.run_command(cmd_name)
    File "/usr/local/lib/python3.4/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/local/lib/python3.4/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/usr/local/lib/python3.4/distutils/command/build_ext.py", line 339, in run
      self.build_extensions()
    File "/tmp/pip-install-wk0bojxk/pillow/setup.py", line 582, in build_extensions
      raise RequiredDependencyException(f)
  __main__.RequiredDependencyException: jpeg

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-wk0bojxk/pillow/setup.py", line 807, in <module>
      raise RequiredDependencyException(msg)
  __main__.RequiredDependencyException:

  The headers or library files could not be found for jpeg,
  a required dependency when compiling Pillow from source.

  Please see the install instructions at:
     https://pillow.readthedocs.io/en/latest/installation.html



  ----------------------------------------
  Failed building wheel for pillow
  Running setup.py clean for pillow
  Running setup.py bdist_wheel for zmq: started
  Running setup.py bdist_wheel for zmq: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/44/7a/7d/ac1d865766b06f9769ac1154bf31dbb5abb3b52ecfe278247a
  Running setup.py bdist_wheel for pyzmq: started
^CGracefully stopping... (press Ctrl+C again to force)

Maybe need to fix the upstream issue in the server image:

https://stackoverflow.com/questions/44043906/the-headers-or-library-files-could-not-be-found-for-jpeg-installing-pillow-on

How to get the optimal trajectory, the dynamics and the map ?

According to the documentation the reward is based on how well the robot follows the optimal racing trajectory. Is it possible to have access to this optimal trajectory, the dynamics of the robot, the map used in the environment in order the create a controller based on these information ?

dts challenges evaluate -- ERROR: for evaluator Cannot start service evaluator: network

Hello, I am getting the following error when running dts challenges evaluate:

ERROR: for evaluator Cannot start service evaluator: network 99ea96c1bfd65da957934e7a4c9778ca9349a810313e4994643269a5e141b2dc not found
Encountered errors while bringing up the project.
ERROR:evaluator:Error while running Docker Compose:

Could not run ['docker-compose', '-p', 'project3', 'up', '-d']:

Command '['docker-compose', '-p', 'project3', 'up', '-d']' returned non-zero exit status 1

docker-compose stdout | None

LFV does not run and simply exits with code 1

When running the LFV task, this is the output

docker-compose -f docker-compose-lfv.yml pull && docker-compose -f docker-compose-lfv.yml up

Pulling gym-duckietown-server ... done
Pulling gym-duckietown-agent ... done
Starting gym-duckietown-agent_gym-duckietown-server_1 ... done
Starting gym-duckietown-agent_gym-duckietown-agent_1 ... done
Attaching to gym-duckietown-agent_gym-duckietown-server_1, gym-duckietown-agent_gym-duckietown-agent_1
gym-duckietown-agent_gym-duckietown-agent_1 exited with code 1

Not really sure what is happening/not happening here.

GL library missing

Running docker-compose up --build on the master branch fails with the following error:

gym-duckietown-server_1  |   File "/opt/conda/bin/duckietown-start-gym", line 11, in <module>
gym-duckietown-server_1  |   File "/opt/conda/lib/python3.6/site-packages/pkg_resources/__init__.py", lingym-duckietown-server_1  |   File "/opt/conda/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2318, in load
gym-duckietown-server_1  |     return self.resolve()
gym-duckietown-server_1  |     from pyglet.gl import *
gym-duckietown-server_1  |     from pyglet.gl.lib import GLException
gym-duckietown-server_1  |   File "/opt/conda/lib/python3.6/site-packages/pyglet/gl/lib.py", line 143, ingym-duckietown-server_1  |   File "/opt/conda/lib/python3.6/site-packages/pyglet/gl/lib_glx.py", line 50, in <module>
ad_library
gym-duckietown-server_1  |     raise ImportError('Library "%s" not found.' % names[0])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.