Please find the subject file in subject folder.
- Assemble PiRacer
- RasberryPi Setup
- PiRacer Setup
Use Racer AI Kit of WAVESHARE to assemble your PiRacer.
Carefully go through the instruction using PDF.
On Step 5 go to Rasberry Setup topic and PiRacer Setup.
After these steps done finish an assemble
- Install Putty
- Download Raspian Legacy
- Install on your computer. As a result while launching you should see image (below)
- Download RasberryPi Imager
- Connect you SD card to your computer (laptop)
- Change Operating System from step 4 (Image below)
- Change advanced options to connect WIFI (ask for relevant WiFi Settings your peers)
- Click WRITE to Download Rasberri Pi on SD card
- Move to
/boot
directory - Enter command
touch ssh
- Insert your SD card to PiRacer
- Connect to monitor
- Find IP of your Car (Image below)
- Connect IP of PiRacer to computer(laptop) with Putty using IP of PiRacer from previous step
- Connect to Pi
- login:
audi
- password:
seame2022
- login:
sudo apt-get update --allow-releaseinfo-change
sudo apt-get upgrade
sudo raspi-config
- change default passward and login for Pi (as you wish)
- change hostname (as you wish)
- enable
Interfacing Options
-I2C
- enable
Interfacing Options
-Camera
- enable
Interfacing Options
-SSH
- enable
Advanced Options
-Expand Filesystem
so you can use your whole SD card storage Advanced options
-GL Driver
-G2 GL (Fake KMS)
- Choose
<Finish>
and Reboot to complete Raspi-config
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
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
python3 -m virtualenv -p python3 env --system-site-packages
echo "source ~/env/bin/activate" >> ~/.bashrc
source ~/.bashrc
- Create Directory
cd ~
mkdir projects
cd projects
- Get the latest donkeycar from Github
git clone https://github.com/autorope/donkeycar
cd donkeycar
git checkout main
pip install -e .[pi]
pip install https://github.com/lhelontra/tensorflow-on-arm/releases/download/v2.2.0/tensorflow-2.2.0-cp37-none-linux_armv7l.whl
- Validate tensorflow install
python -c "import tensorflow; print(tensorflow.__version__)"
- Install OpenCV
sudo apt install python3-opencv
# if failed
# pip install opencv-python
- Test to see if import succeeds
python -c "import cv2"
# if no errors, you have OpenCV installed
cd ~
git clone https://github.com/waveshare/pi-display
cd pi-display
sudo ./install.sh
sudo pip3 install flask
cd pidisplay
python display_server.py
if you have problems
# Change from .utils -> from utils
sudo nano display_server.py
sudo reboot
- Connect PiRacer by SSH
donkey createcar --path ~/mycar
- Configure I2C PCA9685 ( servo driver board )
sudo apt-get install -y i2c-tools
sudo i2cdetect -y 1
- If Pi doesn’t display like below, exchange your PiRacer expansion board
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: 40 -- 42 -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: 70 -- -- -- -- -- -- --
- Open Raspberry Pi terminal and run the follow commands
source ~/env/bin/activate
cd ~/mycar
python manage.py drive
- Go to
http://<raspberrypi_ip_address>:8887
- You can use your mouse and Joystick to control PiRacer
- Adjust the value to make the servo turns to the center place and remember the value ( In our case, 380 was center )
cd ~/mycar
donkey calibrate --channel 0 --bus=1
- Test if 280, and 480 can let the servo turns to the far left and the far right
- Modify the config.py file and change variables
sudo nano config.py
# Change values
# STEERING_LEFT_PWM = 480
# STEERING_RIGHT_PWM = 280
# THROTTLE_FORWARD_PWM = 500
# THROTTLE_STOPPED_PWM = 370
# THROTTLE_REVERSE_PWM = 220
- Connect GamePad with PiRacer
- Create joystick creator wizard
cd ~/mycar
donkey createjs
- To map button, axis, control follow instructions on the screeb
In mapping steps of steering and throttle, you should set in opposite direction ( For example, If you want to throttle Left Stick: Vertical, you need to register Right Stick: Horizontal in the throttle step ) - Change configuration
cd ~/mycar
sudo nano config.py
# USE_JOYSTICK_AS_DEFAULT = True
# JOYSTICK_DEVICE_FIL = "/dev/input/js0"
# CONTROLLER_TYPE = 'custom'
# test with gamepad
python manage.py drive --js