Skip to content

wisambunni/robotic-leader-follower

 
 

Repository files navigation

Robotic Leader Follower Capstone Project

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/

Preparing a Raspberry Pi For Leader/Follower

Setting Up SSH

  1. Connect the Pi to a monitor and power source.
  2. The default username is "pi" and the default password is "raspberry"
  3. Enter the Raspberry Pi configuration tool.
sudo raspi-config
  1. Network Configuration.
  2. Change the Raspberry Pi's name to something more specific.
    • This will be referred to as $PI_NAME in later steps.
  3. Enter the WiFi SSID.
  4. Enter the WiFi password.
  5. Select Interfacing Options.
  6. Enable SSH.
  7. Reboot.
  8. On another computer, open a terminal and enter:
ssh pi@$PI_NAME
  1. Enter the password.

Setup Repository After SSH

  1. Update package lists.
sudo apt-get update
  1. Update installed packages.
sudo apt-get upgrade
  1. Install the Bluez Bluetooth stack.
sudo apt-get install bluez
  1. Install the XBox gamepad driver.
sudo apt-get install xboxdrv
  1. Enter the Raspberry Pi configuration tool.
sudo raspi-config
  1. Select Interfacing Options.
  2. Enable Camera.
  3. Enable I2C.
  4. Save changes.
  5. Clone the repository and submodules.
git clone --recurse-submodules https://github.com/johnshamoon/robotic-leader-follower.git
  1. Enter the SunFounder submodule.
cd SunFounder_PiCar-V
  1. Install the SunFounder dependencies.
sudo ./install_dependencies
  1. Adjust wheel and camera servos.
picar servo-install
  1. Add libraries path to bashrc.
export LD_LIBRARY_PATH=/usr/local/lib/ >> ~/.bashrc

Connect Bluetooth Controller

  1. Disable ERTM on startup.
echo "sudo su -s /bin/bash -c \"echo 1 > /sys/module/bluetooth/parameters/disable_ertm\"" >> .bashrc
  1. Enter the Bluetooth command line control tool.
sudo bluetoothctl
  1. Power on the Bluetooth controller.
power on
  1. Enable the Bluetooth agent.
agent on
  1. Set the current agent as the default.
default-agent
  1. Scan for devices.
scan on
  1. Pair to the Bluetooth controller's Bluetooth address.
pair $ADDRESS
  1. Trust the Bluetooth controller.
trust $ADDRESS
  1. Connect to the Bluetooth controller.
connect $ADDRESS
  1. Exit bluetoothctl.
quit
  1. Check that the controller paired and connected properly.
ls /dev/input/js0

Compiling and Installing OpenCV

Installing OpenCV on Raspbian requires manual compilation. Here's are the steps to compile and link OpenCV to Python:

  1. Update package lists.
sudo apt-get update
  1. Update installed packages.
sudo apt-get upgrade
  1. 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
  1. Go back to the home directory.
cd ~
  1. Clone the OpenCV source.
git clone https://github.com/opencv/opencv.git
  1. Clone OpenCV's extra modules.
git clone https://github.com/opencv/opencv_contrib.git
  1. Install numpy.
pip install numpy
  1. Enter the opencv directory.
cd ~/opencv
  1. Create a directory called build.
mkdir build
  1. Enter the build directory.
cd build
  1. 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 ..
  1. 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
  1. Install OpenCV.
sudo make install
  1. Link the newly installed OpenCV libraries.
sudo ldconfig

Adding Virtual Memory

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:

  1. Check if the system has any swap memory configured.
free -m
  1. Check how much storage the system has and how much can be sacrificed for virtual memory.
df -h
  1. Allocate some memory to a swapfile. 4GB should be plenty.
sudo fallocate -l 4G /swapfile
  1. Verify that the file was created with the correct amount of memory.
ls -lh /swapfile
  1. Change the permissions on swapfile.
sudo chmod 600 /swapfile
  1. Make swapfile an actual swap-file.
sudo mkswap /swapfile
  1. Enable the swap-file.
sudo swapon /swapfile
  1. Verify that the swap-file has been turned on.
free -m
  1. 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

Python Dependencies

This system uses Python 2.7 as is required by the SunFounder APIs. The following packages are required:

numpy>=1.15.1

Starting The System On Boot

The system can start as soon as the Raspberry Pi powers on.

  1. Add
sudo python main.py &

to /etc/rc.local (before the exit 0).

sudo vim /etc/rc.local

  1. Append to the .bashrc so that the system stops during development or installation.

sudo kill $(pidof python)

About

Wayne State University Senior Capstone Project to develop a semi-autonomous robotic vehicle.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 88.9%
  • C++ 8.1%
  • Makefile 2.4%
  • Shell 0.6%