Chapter 4 Donkey Command-line Utilities

This chapter is copied from the donkey car utility doc

The donkey command is created when you install the donkeycar Python package. This is a Python script that adds some important functionality. The operations here are vehicle independent, and should work on any hardware configuration.

4.1 Create Car

This command creates a new dir which will contain the files needed to run and train your robot.

Usage:

donkey createcar --path <dir> [--overwrite] [--template <donkey2>]
  • This command may be run from any dir
  • Run on the host computer or the robot
  • It uses the --path as the destination dir to create. If .py files exist there, it will not overwrite them, unless the optional --overwrite is used.
  • The optional --template will specify the template file to start from. For a list of templates, see the donkeycar/templates dir

4.2 Update Car

donkey update from your ~/mycar dir works the same as donkey createcar –overwrite –path=…

donkey update # from your ~/mycar dir
createcar --overwrite --path=... 

4.3 Find Car

This command attempts to locate your car on the local network using nmap.

Usage:

donkey findcar
  • Run on the host computer
  • Prints the host computer IP address and the car IP address if found
  • Requires the nmap utility:
sudo apt install nmap

4.4 Calibrate Car

This command allows you to manually enter values to interactively set the PWM values and experiment with how your robot responds. See also more information.

Usage:

donkey calibrate --channel <0-15 channel id>
  • Run on the host computer
  • Opens the PWM channel specified by --channel
  • Type integer values to specify PWM values and hit enter
  • Hit Ctrl + C to exit

4.5 Clean data in Tub

Opens a web server to delete bad data from a tub.

Usage:

donkey tubclean <folder containing tubs>
  • Run on pi or host computer.
  • Opens the web server to delete bad data.
  • Hit Ctrl + C to exit

4.6 Make Movie from Tub

This command allows you to create a movie file from the images in a Tub.

Usage:

donkey makemovie <tub_path> [--out=<tub_movie.mp4>] [--config=<config.py>] [--model=<model path>] [--model_type=(linear|categorical|rnn|imu|behavior|3d)] [--start=0] [--end=-1] [--scale=2] [--salient]
  • Run on the host computer or the robot
  • Uses the image records from --tub dir path given
  • Creates a movie given by --out. Codec is inferred from file extension. Default: tub_movie.mp4
  • Optional argument to specify a different config.py other than default: config.py
  • Optional model argument will load the keras model and display prediction as lines on the movie
  • model_type may optionally give a hint about what model type we are loading. Categorical is default.
  • optional --salient will overlay a visualization of which pixels excited the NN the most
  • optional --start and/or --end can specify a range of frame numbers to use. scale will cause ouput image to be scaled by this amount

Examples:

(donkeyV3) Uwes-MBP:mycarV3 uwesterr$ donkey makemovie --tub=/Users/uwesterr/mycarV3/data/tubVaihingenIIIProcessed  --out=VaihingenTubMovieV3.mp4 --config=config.py --model=/Users/uwesterr/mycarV3/vaihingenIII.h5  --type=linear --start=0 --end=1000 --salient

Results in the following movie

The animations within the video are:

  • Green lines are the steering predictions as per defined model
  • Visualization of which pixels excited the NN the most

4.7 Check Tub

This command allows you to see how many records are contained in any/all tubs. It will also open each record and ensure that the data is readable and intact. If not, it will allow you to remove corrupt records.

Usage:

donkey tubcheck <tub_path> [--fix]
donkey tubcheck /Users/uwesterr/mycarV3/data/tubVaihingenIIIProcessed  
  • Run on the host computer or the robot
  • It will print summary of record count and channels recorded for each tub
  • It will print the records that throw an exception while reading
  • The optional --fix will delete records that have problems

4.8 Histogram

This command will show a pop-up window showing the histogram of record values in a given tub.

Usage:

donkey tubhist <tub_path> --rec=<"user/angle">
  • Run on the host computer

  • When the --tub is omitted, it will check all tubs in the default data dir

4.9 Plot Predictions

This command allows you plot steering and throttle against predictions coming from a trained model.

Usage:

donkey tubplot <tub_path> [--model=<model_path>]

don’t forget to use a myconfig.py file which matches to the model your are using, i.e. if you use an RNN model make sure you use a myconfig.py file in which SEQUENCE_LENGTH = 6 set to the correct value, the one you used when training the model

  • This command may be run from ~/mycar dir
  • Run on the host computer
  • Will show a pop-up window showing the plot of steering values in a given tub compared to NN predictions from the trained model
  • When the --tub is omitted, it will check all tubs in the default data dir

4.10 Simulation Server

This command allows you serve steering and throttle controls to a simulated vehicle using the Donkey Simulator.

Usage:

donkey sim --model=<model_path> [--type=<linear|categorical>] [--top_speed=<speed>] [--config=<config.py>]
  • This command may be run from ~/mycar dir
  • Run on the host computer
  • Uses the model to make predictions based on images and telemetry from the simulator
  • --type can specify whether the model needs angle output to be treated as categorical
  • Top speed can be modified to ascertain stability at different goal speeds

4.11 Colab training

on raspi bundel the data for easy retrieval

(env) pi@donkeypi_uwe:~/mycar/data $ tar -czf tubRp.tar.gz tub*

fist we need to get the data in a format to upload to our google mydrive as a tar zip

tar -czf tubTest.tar.gz tub*

more info on how to train in colab is given in the notebook itself

https://colab.research.google.com/github/robocarstore/donkey-car-training-on-google-colab/blob/master/Donkey_Car_Training_using_Google_Colab.ipynb#scrollTo=0ShFSsaewLCT

4.11.1 Blog: Train donkeycar with GPU support in Colab

Check out the blog https://uwesterr.github.io/MlFastAiBlog/donkeycar/colab/2020/03/01/TrainDonkeyCar.html The blog can be turned into a Jupyter Notebook running in Google Colab with one mouse click