Donkey Car

一、 參考資料

Donkey Car 官網 https://www.donkeycar.com/

Donkey Car文件 https://docs.donkeycar.com/

Donkey Car(Pi4版)向icshop購買 https://www.icshop.com.tw/product-page.php?27840

二、軟體安裝
1. 安裝Raspberry Pi作業系統

(1) 下載raspbian_lite_latest作業系統 https://downloads.raspberrypi.org/raspbian_lite_latest

(2)依此將印像檔安裝至mini sd card https://www.raspberrypi.org/documentation/computers/getting-started.html

2.第一次登入 user name: pi password: raspberry

3.設定wifi及其他功能開啟(Camera,SSH,VNC,I2C)

sudo raspi-config //跟筆電要同一個wifi網段(建議用手機分享wifi熱點)

4.查Raspberry Pi 網路資訊指令
ip -br aifconfig wlan0

5.進行系統更新指令

sudo apt-get update

sudo apt-get upgrade

6.安裝python

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

7.安裝OpenCV環境

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

8.設定安裝環境

python3 -m virtualenv -p python3 env --system-site-packages

echo "source env/bin/activate" >> ~/.bashrc

source ~/.bashrc

9.下載Donkey Car Python程式

mkdir projects

cd projec

git clone https://github.com/autorope/donkeycar

cd donkeycar

git checkout master

pip install -e .[pi]

pip install numpy --upgrade

curl -sc /tmp/cookie "https://drive.google.com/uc?export=download&id=1DCfoSwlsdX9X4E3pLClE1z0fvw8tFESP" > /dev/null

CODE="$(awk '/_warning_/ {print $NF}' /tmp/cookie)"

curl -Lb /tmp/cookie "https://drive.google.com/uc?export=download&confirm=${CODE}&id=1DCfoSwlsdX9X4E3pLClE1z0fvw8tFESP" -o tensorflow-2.2.0-cp37-cp37m-linux_armv7l.whl

pip install tensorflow-2.2.0-cp37-cp37m-linux_armv7l.whl

10.設定OpenCV

sudo apt install python3-opencv

pip install opencv-python

11.下載Donkey Car控制程式

git clone https://github.com/robocarstore/donkeycar-console

sudo mv donkeycar-console /opt

cd /opt/donkeycar-console

12.測試Donkey Car

pip install -r requirements/production.txt

python manage.py migrate

python manage.py runserver 0.0.0.0:8000

sudo ln -s gunicorn.service /etc/systemd/system/gunicorn.service

三、駕駛Donkey Car

1.啟動Donkey Car程式

cd ~/mycar

python manage.py drive //如果要用遙桿控制改輸入 python manage.py drive --js

2.用瀏覽器連線

http://Raspberry Pi的ip:8887

space : stop car and stop recording

r : toggle recording

i : increase throttle

k : decrease throttle

j : turn left

l : turn right

python manage.py drive --js

  • Left analog stick - Left and right to adjust steering

  • Right analog stick - Forward to increase forward throttle

  • Pull back twice on right analog to reverse

  • Select button switches modes - "User, Local Angle, Local(angle and throttle)"

  • Triangle - Increase max throttle

  • X - Decrease max throttle

  • Circle - Toggle recording (disabled by default. auto record on throttle is enabled by default)

  • dpad up - Increase throttle scale

  • dpad down - Decrease throttle scale

  • dpad left - Increase steering scale

  • dpad right - Decrease steering scale

  • Start - Toggle constant throttle. Sets to max throttle (modified by X and Triangle).