Wayne State University Senior Capstone Project to develop a semi-autonomous robotic vehicle.
View the module documentation at https://johnshamoon.github.io/robotic-leader-follower/
- Connect the Pi to a monitor and power source.
- The default username is "pi" and the default password is "raspberry"
- Enter the Raspberry Pi configuration tool.
sudo raspi-config
- Network Configuration.
- Change the Raspberry Pi's name to something more specific.
- This will be referred to as $PI_NAME in later steps.
- Enter the WiFi SSID.
- Enter the WiFi password.
- Select Interfacing Options.
- Enable SSH.
- Reboot.
- On another computer, open a terminal and enter:
ssh pi@$PI_NAME
- Enter the password.
- Update package lists.
sudo apt-get update
- Update installed packages.
sudo apt-get upgrade
- Install the Bluez Bluetooth stack.
sudo apt-get install bluez
- Install the XBox gamepad driver.
sudo apt-get install xboxdrv
- Enter the Raspberry Pi configuration tool.
sudo raspi-config
- Select Interfacing Options.
- Enable Camera.
- Enable I2C.
- Save changes.
- Clone the repository and submodules.
git clone --recurse-submodules https://github.com/johnshamoon/robotic-leader-follower.git
- Enter the SunFounder submodule.
cd SunFounder_PiCar-V
- Install the SunFounder dependencies.
sudo ./install_dependencies
- Adjust wheel and camera servos.
picar servo-install
- Add libraries path to bashrc.
export LD_LIBRARY_PATH=/usr/local/lib/ >> ~/.bashrc
- Disable ERTM on startup.
echo "sudo su -s /bin/bash -c \"echo 1 > /sys/module/bluetooth/parameters/disable_ertm\"" >> .bashrc
- Enter the Bluetooth command line control tool.
sudo bluetoothctl
- Power on the Bluetooth controller.
power on
- Enable the Bluetooth agent.
agent on
- Set the current agent as the default.
default-agent
- Scan for devices.
scan on
- Pair to the Bluetooth controller's Bluetooth address.
pair $ADDRESS
- Trust the Bluetooth controller.
trust $ADDRESS
- Connect to the Bluetooth controller.
connect $ADDRESS
- Exit bluetoothctl.
quit
- Check that the controller paired and connected properly.
ls /dev/input/js0
Installing OpenCV on Raspbian requires manual compilation. Here's are the steps to compile and link OpenCV to Python:
- Update package lists.
sudo apt-get update
- Update installed packages.
sudo apt-get upgrade
- Install necessary libraries and packages.
sudo apt-get install -y build-essential cmake pkg-config sudo apt-get install -y libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libv4l-dev sudo apt-get install -y libxvidcore-dev libx264-dev sudo apt-get install -y libgtk2.0-dev sudo apt-get install -y libatlas-base-dev gfortran sudo apt-get install -y python2.7-dev python3-dev
- Go back to the home directory.
cd ~
- Clone the OpenCV source.
git clone https://github.com/opencv/opencv.git
- Clone OpenCV's extra modules.
git clone https://github.com/opencv/opencv_contrib.git
- Install numpy.
pip install numpy
- Enter the opencv directory.
cd ~/opencv
- Create a directory called build.
mkdir build
- Enter the build directory.
cd build
- Configure the project and create the cmake cache entries.
cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \ -D BUILD_EXAMPLES=ON ..
- Build OpenCV.
- Using more jobs will cause compilation to fail.
- This will likely require more virtual (swap) memory. View Adding Virtual Memory for instructions.
make -j1
- Install OpenCV.
sudo make install
- Link the newly installed OpenCV libraries.
sudo ldconfig
Compiling OpenCV will most likely require more RAM than the Pi has. This can be solved by adding more virtual (swap) memory. Here are the steps to do that:
- Check if the system has any swap memory configured.
free -m
- Check how much storage the system has and how much can be sacrificed for virtual memory.
df -h
- Allocate some memory to a swapfile. 4GB should be plenty.
sudo fallocate -l 4G /swapfile
- Verify that the file was created with the correct amount of memory.
ls -lh /swapfile
- Change the permissions on swapfile.
sudo chmod 600 /swapfile
- Make swapfile an actual swap-file.
sudo mkswap /swapfile
- Enable the swap-file.
sudo swapon /swapfile
- Verify that the swap-file has been turned on.
free -m
- Our swapfile changes will reset when the Pi reboots. Add the following line in /etc/fstab to make these change permanent:
/swapfile none swap sw 0 0
This system uses Python 2.7 as is required by the SunFounder APIs. The following packages are required:
numpy>=1.15.1
The system can start as soon as the Raspberry Pi powers on.
- Add
sudo python main.py &
to /etc/rc.local (before the exit 0).
sudo vim /etc/rc.local
- Append to the .bashrc so that the system stops during development or installation.
sudo kill $(pidof python)