Skip to content

G1:Autonomous Parking Car

FaridaRagheb05 edited this page May 23, 2026 · 7 revisions

Autonomous Parking Car

Name GitHub
Freddy Amgad FreddyAmgad
Farida Ragheb FaridaRagheb05
Habiba Seif HabibaSeif

Github Repo: https://github.com/FaridaRagheb05/Autonomous-Parking

1. The Proposal

Abstract / Elevator Pitch:

This project is an autonomous parking car built using an STM32 Nucleo-L432KC microcontroller, FreeRTOS, two HC-SR04 ultrasonic sensors, a Bluetooth module, a motor driver, an active buzzer, and a Dagu Wild Thumper car platform. The car is controlled wirelessly over Bluetooth. When the user sends the start command, the car drives forward and scans for an available parking space on its right side. The right ultrasonic sensor is used to detect the length of an open parking gap, while the front ultrasonic sensor is used to stop the car safely during the parking maneuver. The car rejects spaces that are too small, parks correctly when the space fits, and parks in only one spot when the detected space is larger than needed.

Project Objectives & Scope:

  • RTOS integration: Use FreeRTOS to separate Bluetooth communication, motor control, and distance sensing into independent tasks.
  • Bluetooth control: Use UART communication to start and stop the car wirelessly.
  • Distance sensing: Use two HC-SR04 ultrasonic sensors to measure the right-side parking gap and the front stopping distance.
  • Autonomous parking: Detect a valid parking space and execute the parking maneuver without manual steering.
  • Safety behavior: Stop the car when the front sensor detects an obstacle at the stopping threshold.
  • Buzzer feedback: Turn on the active buzzer during the parking maneuver and turn it off once the car stops.

Required Parking Cases

The final system handles the three required parking-space cases:

Case car Behavior
Space too small The car does not park and continues moving forward.
Space fits the car The car detects a valid gap and parks inside the space.
Space too big The car parks after detecting one valid space and occupies only one parking spot.

Stretch Goals:

  • Parallel Parking Mode: Add a secondary bluetooth command to let the user choose between parallel and perpendicular parking modes.
  • Companion Mobile Interface: Develop a minimal Bluetooth-enabled app (or serial terminal UI) to monitor the car's telemetry (current distance readings, mode status).

2. System Architecture

2.1 High-Level Block Diagram:

Screenshot 2026-05-22 at 7 22 10 PM

Subsystem Breakdown:

Input Subsystem

  • Bluetooth module sends start/stop commands to the STM32 over UART.
  • Right HC-SR04 sensor detects whether there is an open parking gap beside the car.
  • Front HC-SR04 sensor detects when the car is close enough to the front obstacle while parking.

Processing Subsystem

  • The STM32 Nucleo-L432KC runs FreeRTOS.
  • Sensor measurements, UART communication, and motor behavior are handled in separate tasks.
  • The parking decision is based on right-side distance and how long the open gap remains detected.

Output Subsystem

  • The STM32 sends motor commands to the motor driver over UART.
  • The motor driver controls the Dagu Wild Thumper motors.
  • The active buzzer is driven through GPIO during the parking maneuver.

3. Hardware Design

Component Selection:

Component Purpose
STM32 Nucleo-L432KC Main microcontroller board
Dagu Wild Thumper car chassis and drive platform
2x HC-SR04 ultrasonic sensors Distance sensing for right-side gap and front stopping
Bluetooth module Wireless start/stop control
Motor driver Drives the car motors
Active buzzer Parking/safety indication
Battery supply Powers the chassis, motors, and electronics

Pin Connections

Component STM32 Pin
Front HC-SR04 trigger PB0
Front HC-SR04 echo PB1
Right HC-SR04 trigger PA4
Right HC-SR04 echo PA5
Active buzzer PA6
Bluetooth UART USART1
Motor driver UART USART2

4. Software Implementation

4.1 Software Architecture:

The firmware was written in C using STM32 HAL and FreeRTOS. STM32CubeMX was used for peripheral configuration and FreeRTOS setup, and the project was built and flashed using Keil uVision.

The software is split into FreeRTOS tasks:

Task Responsibility
StartTask02 Motor control, start/stop handling, and parking maneuver
StartTask03 Bluetooth UART reception and queueing commands
StartTask04 Ultrasonic sensor reading, gap detection, and parking trigger
StartDefaultTask Default CubeMX-generated task

Bluetooth reception is interrupt-based. When a character is received through USART1, the UART interrupt gives a semaphore. The UART task then places the received command into a FreeRTOS queue. The motor task reads commands from this queue and executes the appropriate behavior.

4.2 Flowcharts & State Machines:

Idle
 |
 | Bluetooth receives P/p
 v
Scanning
 |
 | Right sensor detects open gap > 60 cm
 v
Gap Tracking
 |
 | Gap remains open for >= 500 ms
 v
Parking Maneuver
 |
 | Front sensor detects obstacle <= 20 cm
 v
Stopped / Parked

If the gap ends before 500 ms, the car returns to scanning and does not park. This is how the system rejects spaces that are too small.

4.3 Key Algorithms:

Gap Detection

The right-side ultrasonic sensor measures the distance beside the car. A distance greater than 60 cm is treated as an open parking gap.

The system does not park immediately when an open area is detected. Instead, it tracks how long the gap remains open:

  • If the gap lasts less than 500 ms, the space is considered too small.
  • If the gap lasts at least 500 ms, the space is considered valid.
  • Once a valid space is found, first_turn_triggered prevents repeated parking triggers inside the same large gap.

Parking Maneuver

Once a valid gap is detected, the motor task performs the parking sequence:

  1. Reverse.
  2. Turn into the parking space.
  3. Move forward into the final parked position.
  4. Stop when the front sensor detects an obstacle at 20 cm or less.

Bluetooth Commands

Command Function
P / p Start autonomous parking mode
S Stop the car

4.4 Development Environment:

  • Programming language: C
  • Configuration tool: STM32CubeMX
  • IDE/compiler: Keil uVision
  • Runtime: FreeRTOS
  • Libraries: STM32 HAL
  • Target board: STM32 Nucleo-L432KC

5. Testing, Validation & Debugging

5.1 Unit Testing:

The main subsystems were tested independently before integration:

  • Verified HC-SR04 readings at different known distances.
  • Tested front and right sensor trigger/echo wiring separately.
  • Tested Bluetooth UART reception using single-character commands.
  • Tested motor driver commands for forward, reverse, stop, and turning behavior.
  • Tested buzzer GPIO output.

5.2 Integration Testing:

After subsystem testing, the full car was tested on the Dagu Wild Thumper chassis:

  • Verified that sending P starts the car and begins scanning.
  • Verified that sending S stops the car.
  • Tested the right-side sensor with different parking-space sizes.
  • Tested that the car does not park in a space that is too small.
  • Tested that the car parks when the space fits.
  • Tested that the car parks in only one spot when the space is larger than needed.
  • Verified that the front sensor stops the car during the parking phase.
  • Tuned timing thresholds for the physical car speed and parking-space dimensions.

5.3 Challenges & Solutions:

Challenge Solution
Ultrasonic readings were noisy during motion Used threshold-based logic and repeated polling rather than relying on one reading.
The car could trigger parking too early (if space was too small) Added a time requirement so the gap must remain open for at least 500 ms.
Large gaps could cause repeated parking triggers Added first_turn_triggered so the car parks only once per run.
Coordinating Bluetooth, sensors, and motors at the same time Used FreeRTOS tasks, a queue, and a semaphore to separate responsibilities.
Stopping at the correct final position Used the front sensor to stop when the distance reaches 20 cm or less.

6. Results & Demonstration

6.1 Final Prototype:

The final prototype uses the Dagu Wild Thumper chassis with the STM32 Nucleo-L432KC, two HC-SR04 sensors for front and right-side sensing, a Bluetooth module for wireless commands, and a motor driver for movement, along with an active buzzer for feedback. (High-quality photos of the completed build to be added here)

6.2 Video Demonstration:

https://drive.google.com/drive/folders/1UQNkpSfZhXkfl8AvvDutf5jlT8fbTCBL?usp=sharing

6.3 Performance Metrics:

Requirement Final Status
Start/stop using Bluetooth Completed
FreeRTOS task-based implementation Completed
Right-side parking gap detection Completed
Front stopping detection Completed
Space too small: do not park Completed
Space fits: park correctly Completed
Space too big: occupy only one spot Completed
Buzzer indication during parking Completed

7. Project Management

7.1 Division of Labor

Team Member Primary Responsibilities
Freddy RTOS architecture, FreeRTOS task design, motor control logic, and parking state machine
Habiba Distance sensor integration, threshold algorithm for the buzzer proximity alerts, telemetry over UART
Farida Hardware design, chassis assembly, motor driver wiring, integration testing and debugging

7.2 Timeline

A Gantt chart or milestone list showing the planned schedule versus the actual completion dates.

Milestone Deliverable Planned Date Owner(s)
M1: Team Formation Team formation sheet submitted Apr 14, 2026 All
M2: Proposal Presentation Initial project proposal and wiki setup Apr 15, 2026 All
Checkpoint A: Wiki Setup Proposal, architecture, requirements, and BOM draft Apr 20, 2026 All
M3: Progress Presentation & Demo Working subsystem demo with sensors and buzzer Apr 29, 2026 All
Checkpoint B: Integration Update Updated integration status, testing evidence, and remaining bugs May 6, 2026 All
M4: Final Demo & Presentation Full system demo, final presentation, completed wiki, and code repository May 22, 2026 All

Milestone-by-Milestone Breakdown: M2 to Checkpoint A

  • Defined FreeRTOS task structure.
  • Set up STM32CubeMX and Keil uVision project.
  • Selected the STM32 Nucleo-L432KC, HC-SR04 sensors, Bluetooth module, and Dagu Wild Thumper chassis.
  • Started hardware assembly and wiring plan.

Checkpoint A to M3

  • Tested ultrasonic sensors.
  • Tested motor driver commands.
  • Tested buzzer output.
  • Integrated Bluetooth UART command reception.

M3 to Checkpoint B

  • Integrated the car chassis, sensors, Bluetooth, and motor driver.
  • Developed the parking gap detection logic.
  • Tuned the right-side threshold and timing condition.
  • Added the front-sensor stop condition.

Checkpoint B to M4

  • Tested the three required parking cases.
  • Tuned the parking maneuver timing.
  • Debugged repeated-trigger behavior in large gaps.
  • Prepared the final demo and repository documentation.

8. Appendices & References

8.1 Source Code Repository:

https://github.com/FaridaRagheb05/Autonomous-Parking

8.2: Presentation Link:

https://www.canva.com/design/DAHKb9Xt6Ts/lc0Ep55GTH2nNOV1mgb-AQ/edit

8.3 References:

Clone this wiki locally