Skip to content

Instantly share code, notes, and snippets.

@tawnkramer
Last active April 10, 2020 07:42
Show Gist options
  • Save tawnkramer/6d244090cb8f2af1bc9f6d1ebc0377b1 to your computer and use it in GitHub Desktop.
Save tawnkramer/6d244090cb8f2af1bc9f6d1ebc0377b1 to your computer and use it in GitHub Desktop.
* linux ubuntu only now
Get donkeycar, if you don't have it. If you do, just checkout dev.
* cd ~/projects
* git clone https://github.com/autorope/donkeycar
* cd donkeycar
* git checkout master
Install conda. Optional but recommended
* wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
* bash ./Miniconda3-latest-Linux-x86_64.sh
Create a virtual env if you don't already have one
* conda env create -f install/envs/ubuntu.yml
Activate your virtual env
* conda activate donkey
Get donkeycar sim:
* with a web browser, download https://drive.google.com/file/d/10lpqOZ-dX9K9mJX4ggmrUM4FSnc-ZJLn/view?usp=sharing
* mv ~/Downloads/DonkeySimLinux.zip ~/
* cd ~/
* unzip DonkeySimLinux.zip
Get gym-donkeycar:
* cd ~/projects
* git clone https://github.com/tawnkramer/gym-donkeycar
* cd gym-donkeycar
* pip install -e .
Make a donkeycar and point at server:
* donkey createcar --path ~/sim_racer
* cd ~/sim_racer
* edit myconfig.py
* DONKEY_GYM = True
* DONKEY_SIM_PATH = "/home/$USER/DonkeySimLinux/donkey_sim.x86_64"
* DONKEY_GYM_ENV_NAME = "donkey-generated-track-v0" # ("donkey-generated-track-v0"|"donkey-generated-roads-v0"|"donkey-warehouse-v0"|"donkey-avc-sparkfun-v0")
* python manage.py drive
This should start the simulator process, attach to it, and give you controls depending on your config choices.
To configure the look of your car:
* GYM_CONF = { "body_style" : "donkey", "body_rgb" : (128, 128, 128), "car_name" : "me", "font_size" : 100}
The body style should be one of these: (donkey|bare|car01)
The body rgb is a tuple of three values, each 0-255
The car name will be displayed to help identify racers
The font size can be adjusted in case your name is long.
When racing in the virtual-racing-league online, change these settings in your myconfig.py:
DONKEY_SIM_PATH = "remote"
SIM_HOST = "trainmydonkey.com"
If you are not racing with donkey car code, you can start with the simple example file:
https://github.com/tawnkramer/sdsandbox/blob/tcpserver/src/test_client.py
@Ezward
Copy link

Ezward commented Apr 2, 2020

Note, I have pre-exising donkey environment from another branch, so I had to do things in a different order:

  • Download DonkeySimLinux.zip described above and unzip in your home folder so you end up with ~/DonkeySimLinux
  • Git pull the donkey dev branch and recreate the conda donkey env as described here (you will delete your donkey conda environment if you have one and recreate it). Then activate the donkey environment.
  • Git clone gym-donkeycar, checkout tcpserver branch and pip install -e . from that project's folder while the donkey conda environment is activated, so all the stuff ends up in the donkey environment.
  • Go back to the donkeycar project folder and run donkey createcar to create your sim_racer folder. Make the modifications to myconfig.py for the gym. Remember the DONKEY_SIM_PATH is the path to where you unzipped the simulator. I unzipped mine in my home folder, so my value is, DONKEY_SIM_PATH = "/home/ezward/DonkeySimLinux/donkey_sim.x86_64"

@tawnkramer
Copy link
Author

This does assume you already have installed donkey before. Should I add the virtualenv conda setup too?

@Ezward
Copy link

Ezward commented Apr 4, 2020

This does assume you already have installed donkey before. Should I add the virtualenv conda setup too?

I would just point them to the donkey docs; if they already have it installed it says how to upgrade.

@RyanC1681
Copy link

I follow the steps, but it got error as below: Any idea? Thanks,

starting DonkeyGym env
self_start does not exist. you must start sim manually.
connecting to 127.0.0.1 9091
Traceback (most recent call last):
File "manage.py", line 599, in
meta=args['--meta'])
File "manage.py", line 96, in drive
cam = DonkeyGymEnv(cfg.DONKEY_SIM_PATH, env_name=cfg.DONKEY_GYM_ENV_NAME)
File "/home/nvidia/projects/donkeycar/donkeycar/parts/dgym.py", line 14, in init
self.env = gym.make(env_name)
File "/home/nvidia/.local/lib/python3.6/site-packages/gym/envs/registration.py", line 142, in make
return registry.make(id, **kwargs)
File "/home/nvidia/.local/lib/python3.6/site-packages/gym/envs/registration.py", line 87, in make
env = spec.make(kwargs)
File "/home/nvidia/.local/lib/python3.6/site-packages/gym/envs/registration.py", line 59, in make
env = cls(
_kwargs)
File "/home/nvidia/projects/gym-donkeycar/gym_donkeycar/envs/donkey_env.py", line 127, in init
super(GeneratedTrackEnv, self).init(level=3, *args, **kwargs)
File "/home/nvidia/projects/gym-donkeycar/gym_donkeycar/envs/donkey_env.py", line 48, in init
self.viewer = DonkeyUnitySimContoller(level=level, host=host, port=port)
File "/home/nvidia/projects/gym-donkeycar/gym_donkeycar/envs/donkey_sim.py", line 38, in init
self.client = SimClient(self.address, self.handler)
File "/home/nvidia/projects/gym-donkeycar/gym_donkeycar/core/sim_client.py", line 25, in init
super().init(*address)
File "/home/nvidia/projects/gym-donkeycar/gym_donkeycar/core/client.py", line 32, in init
self.connect()
File "/home/nvidia/projects/gym-donkeycar/gym_donkeycar/core/client.py", line 40, in connect
self.s.connect((self.host, self.port))
ConnectionRefusedError: [Errno 111] Connection refused
Exception ignored in: <bound method SimClient.del of <gym_donkeycar.core.sim_client.SimClient object at 0x7f772b4f2470>>
Traceback (most recent call last):
File "/home/nvidia/projects/gym-donkeycar/gym_donkeycar/core/sim_client.py", line 44, in del
self.close()
File "/home/nvidia/projects/gym-donkeycar/gym_donkeycar/core/sim_client.py", line 48, in close
self.stop()
File "/home/nvidia/projects/gym-donkeycar/gym_donkeycar/core/client.py", line 62, in stop
self.th.join()
AttributeError: 'SimClient' object has no attribute 'th'
Exception ignored in: <bound method DonkeyEnv.del of <gym_donkeycar.envs.donkey_env.GeneratedTrackEnv object at 0x7f772b57fc50>>
Traceback (most recent call last):
File "/home/nvidia/projects/gym-donkeycar/gym_donkeycar/envs/donkey_env.py", line 72, in del
self.close()
File "/home/nvidia/projects/gym-donkeycar/gym_donkeycar/envs/donkey_env.py", line 75, in close
self.viewer.quit()
AttributeError: 'GeneratedTrackEnv' object has no attribute 'viewer'

@RyanC1681
Copy link

python test_client.py
File "test_client.py", line 7

^
SyntaxError: invalid syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment