DonkeyCar for Pi-Setup Raspberry Pi

From Waveshare Wiki
Jump to: navigation, search

Guide of DonkeyCar

Step 1. Install libraries

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

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential python3 python3-dev python3-pip python3-virtualenv python3-numpy python3-picamera 
sudo apt-get install python3-pandas python3-rpi.gpio i2c-tools avahi-utils joystick libopenjp2-7-dev libtiff5-dev gfortran 
sudo apt-get install libatlas-base-dev libopenblas-dev libhdf5-serial-dev git ntp

Step 2. Install libraries for OpenCV

sudo apt-get install libilmbase-dev libopenexr-dev libgstreamer1.0-dev libjasper-dev libwebp-dev 
sudo apt-get install libatlas-base-dev libavcodec-dev libavformat-dev libswscale-dev libqtgui4 libqt4-test

Step 3. Setup virtual environment

python3 -m virtualenv -p python3 env --system-site-packages
echo "source env/bin/activate" >> ~/.bashrc
source ~/.bashrc

Note: Here we modify .bashrc for auto-entering the virtual environment, if you want to back to normal environment, please use command deactivate.

Step 4. Install Donkeycar Python codes

  • Create project directory
mkdir projects
cd ~/projects
  • Clone donkeycar codes from Github (Use the commands of next one if you buy the pro version)
git clone https://github.com/waveshare/donkeycar
cd donkeycar
git checkout master
pip install -e .[pi]
pip install tensorflow==1.13.1
pip install numpy --upgrade
  • If the version you buy is Piracer Pro Kit. Please use the following commands instead.
git clone https://github.com/autorope/donkeycar
cd donkeycar
git checkout master
pip install -e .[pi]
pip install tensorflow==1.13.1
pip install numpy --upgrade
  • Check if you have install tensorflow successfully
python -c "import tensorflow"
  • It is normal that if you get wronging as below
/home/pi/env/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: compiletime version 3.4 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.5
  return f(*args, **kwds)
/home/pi/env/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: builtins.type size changed, may indicate binary incompatibility. Expected 432, got 412
  return f(*args, **kwds)

Step 5. Install OpenCV

  • Install OpenCV
sudo apt install python3-opencv
  • If you fail at the last command, please use this command to install OpenCV again
pip install opencv-python
  • Check if the OpenCV is installed successfully
python -c "import cv2"

Step 6. Install Service of OLED Display

  • Use command belows to install service for OLED displaying. The OLED onboard can be used to display IP address, Voltage and current, etc.
cd ~
git clone https://github.com/waveshare/pi-display
cd pi-display
sudo ./install.sh

Step 7. Create DonkeyCar

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

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