/AutomatedSafteyDrivingCar

Automated Safety Driving Car

Primary LanguageC

Automated Safety Driving Car

Team Members By

Name Github
Mazen Hassan mhassan20328
Kareem Amr KareemAmr12
Omar Mohamed OmarMoheyeldinMohamed
Ahmed Dardir ahesham900

Features

  • The car should navigate to follow a path between two lines.
  • The car should stop whenever it detects an object infront of it.
  • The car should continue moving again when the object moves from its path.

Architecture

Software Architecture

  • For the STM32 Nucleo board: We decided to use STMCubeIDE for project management, source code editing, and program running.
  • For the ESP32 CAM: We use Arduino IDE only to take a picture downsize it and send it to the STM32 Nucleo board.

Hardware Architecture

Block Diagram

Block Diagram

System Components

Component Description Image Estimated Price
STM32L432KC Microcontroller It is the main controller of the system. It receives the image from the ESP32 CAM and processes it to detect the lines. Also communicates with the ultrasonic sensor to detect objects infront of the car and stop it. STM Microcontroller $11
ESP32-Cam It is the camera of the system. When prompted by the STM32 Nucleo board it takes a picture and sends it to the STM32 Nucleo board. 2-4-removebg-preview $15
Ultrasonic Sensor HC-SR04 It is used to detect objects infront of the car and stop it. Ultrasonic Sensor $2
The Pololu TReX Motor Controller It is used to control the motors of the car. Polulu Controller $200
Dagu Wild Thumper 4WD Chassis It is the car chassis. Dagu $350
Jumper Wires Used to connect the components together. Wires $1
Bread Board Used to connect the components together. Breadboard $2

Connections and Steps to Replicate the Project

Folder Structure

  • ESP32CameraSource folder contains all source files needed to program the ESP32 CAM.
  • STMSource folder contains all source files needed to program the STM32 Nucleo board.

Instructions

  • Use the source code in the ESP32 CAM folder to program the ESP32 CAM.
  • Open Arduino IDE and load the code into the camera. Note: you need to reset the camera anytime its power is cut off.
  • Use the source code in the STM32 Nucleo board folder to program the STM32 Nucleo board. Note: you might want to use STMCubeMX to setup UART1 (setup baud rate at 19200), UART2 (setup baud rate to 230,400), and TIM1 (use a prescalar of 31 to achieve a 1us clock tick).
  • Connect UART1 to the Pololu TReX Motor Controller.
  • Connect UART2 to the ESP32 CAM.
  • Connect the ultrasonic sensor trig and echo pins to PA3 and PA4 pins respectively on the STM32 Nucleo board.
  • Open STM32CubeIDE and run the project

    Car Picture

How it Works

Taking the picture

The ESP32 CAM takes a picture when it receives a signal from the STM32 Nucleo board. The ESP32 CAM then downsizes the image and sends it to the STM32 Nucleo board using UART2. Below is an example of the image taken by the ESP32 CAM.

Image Taken by ESP32 CAM

Processing the image

The STM32 Nucleo board receives the image from the ESP32 CAM and processes it to detect the lines using edge detection. An example of the image after edge detection is shown below.

Image After Edge Detection

How to move the car

A fisheye camera lens was used to capture a wider view of the road. This added a challenge to the lane detection algorithm as the two lane lines are not parrallel as seen in the image. Therefore the lane detection algorithm now simulates two lines that would have been the car tires' path and if these lines intersect the lane lines then the car should move in the opposite direction. For example, if the line from the left tire intersects a lane line the car should move to the right and vice versa. The image below shows the two lines simulated by the algorithm.

Simulated Lines

Link For Demo: Demo

Next Steps & Future Work

  • Try downsizing the image more to reduce the time needed to send the image.
  • May want to use Radar instead of the ultrasonic sensor to detect objects infront of the car.