DonkeyCar for Jetson Nano-Setup Jetson Nano

From Waveshare Wiki
Jump to: navigation, search

Guides of DonkeyCar

Step 1. Install libraries

Please make sure that you have installed the image and that it could start normally. Open the terminal and install the libraries as below:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran
sudo apt-get install -y python3-dev python3-pip
sudo apt-get install -y libxslt1-dev libxml2-dev libffi-dev libcurl4-openssl-dev libssl-dev libpng-dev libopenblas-dev
sudo apt-get install -y git nano
sudo apt-get install -y openmpi-doc openmpi-bin libopenmpi-dev libopenblas-dev

Step 2. Setup virtual environment

pip3 install virtualenv
python3 -m virtualenv -p python3 env --system-site-packages
echo "source env/bin/activate" >> ~/.bashrc
source env/bin/activate  #enter virtual environment
*Note: From now on, all operations related to donkeycar need to be performed within this virtual environment. If a new terminal does not enter the virtual environment, run the command "source env/bin/activate" to enter this virtual environment.

Step 3. Install DonkeyCar Python codes

  • Install the dependency library through pip:
pip3 install -U pip testresources setuptools
pip3 install -U futures==3.1.1 protobuf==3.12.2 pybind11==2.5.0
pip3 install -U cython==0.29.21 pyserial
pip3 install -U future==0.18.2 mock==4.0.2 h5py==2.10.0 keras_preprocessing==1.1.2 keras_applications==1.0.8 gast==0.3.3
pip3 install -U absl-py==0.9.0 py-cpuinfo==7.0.0 psutil==5.7.2 portpicker==1.3.1 six requests==2.24.0 astor==0.8.1 termcolor==1.1.0 wrapt==1.12.1 google-pasta==0.2.0
pip3 install -U gdown

# This will install tensorflow as a system package
pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v45 tensorflow==2.3.1
  • Install PyTorch:
wget https://nvidia.box.com/shared/static/p57jwntv436lfrd78inwl7iml6p13fzh.whl
cp p57jwntv436lfrd78inwl7iml6p13fzh.whl torch-1.8.0-cp36-cp36m-linux_aarch64.whl
pip3 install torch-1.8.0-cp36-cp36m-linux_aarch64.whl
sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libavcodec-dev libavformat-dev libswscale-dev
mkdir -p ~/projects; cd ~/projects
git clone -b v0.9.0 https://github.com/pytorch/vision torchvision
cd torchvision 
python setup.py install
cd ../

Step 4: Install Donkeycar Python

  • Download the latest donkeycar demo from Github:
cd ~/projects
git clone https://github.com/autorope/donkeycar
cd donkeycar
git checkout master
pip install -e .[nano]
pip install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 tensorflow-gpu==1.13.1+nv19.3

Step 5. Create DonkeyCar

  • Create donkeycar example:
donkey createcar --path ~/mycar

After running, files will be generated and saved in the directly ~/mycar.

  • Open the myconfig.py file and modify the camera parameters.
nano myconfig.py
  • The camera we use is based on Sony IMX219, so we need to change it to CSIC and set the resolution to 224*224.
#CAMERA
CAMERA_TYPE = "CSIC"   # (PICAM|WEBCAM|CVCAM|CSIC|V4L|MOCK)
IMAGE_W = 224
IMAGE_H = 224