Skip to content

Abinesh0610/Driver-Drowsiness-Detection-for-Autoware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš— Drowsiness Control System for Autoware

ROS2 Python Tests License

A real-time driver monitoring and safety system built on ROS2 that detects drowsiness using computer vision and progressively applies braking via Autoware.


✨ Features

  • πŸ‘οΈ Real-time drowsiness detection using facial landmarks
  • 🧠 Multi-signal analysis (EAR, MAR, head pose)
  • βš™οΈ 6-stage braking state machine
  • 🚦 Seamless Autoware integration
  • πŸ“Š Live debug visualization & status topics
  • πŸ›‘οΈ Safety-first gradual intervention (no sudden braking)
  • βœ… Fully tested (16/16 tests passing)

🧠 System Overview

graph LR
    CAM[Camera] --> DET[Detector]
    DET --> CTRL[Braking Controller]
    CTRL --> AUTO[Autoware Interface]
    AUTO --> VEH[Vehicle Control]
Loading

πŸ“ Project Structure

drowsiness_control/
β”œβ”€β”€ config/                     # Runtime parameters
β”œβ”€β”€ launch/                     # ROS2 launch files
β”œβ”€β”€ drowsiness_control/
β”‚   β”œβ”€β”€ camera_input.py
β”‚   β”œβ”€β”€ drowsiness_detector.py
β”‚   β”œβ”€β”€ braking_controller.py
β”‚   β”œβ”€β”€ autoware_interface.py
β”‚   β”œβ”€β”€ drowsiness_node.py
β”‚   └── constants.py
└── test/                       # Unit tests (16 total)

βš™οΈ Installation

1. Clone into Autoware workspace

cd ~/project/autoware/src
git clone <your-repo-url>

2. Install dependencies

pip3 install mediapipe opencv-python

3. Build

cd ~/project/autoware
colcon build --packages-select drowsiness_control --symlink-install
source install/setup.bash

▢️ Usage

Run the system

ros2 launch drowsiness_control drowsiness_control.launch.py

Run with custom parameters

ros2 launch drowsiness_control drowsiness_control.launch.py \
    camera_index:=0 \
    max_velocity_mps:=8.33 \
    publish_debug:=true

πŸ“‘ ROS2 Topics

Topic Description
/drowsiness_control/status Drowsiness level output
/drowsiness_control/braking_state Current braking state
/drowsiness_control/debug_image Debug visualization
/planning/scenario_planning/max_velocity Velocity control

🧠 Detection Method

The system evaluates driver alertness using:

  • EAR (Eye Aspect Ratio) β†’ detects eye closure
  • MAR (Mouth Aspect Ratio) β†’ detects yawning
  • Head Pose Estimation β†’ detects nodding

These signals are combined into a normalized score (0–1) and mapped to:

  • ALERT
  • MILDLY_DROWSY
  • DROWSY
  • SEVERELY_DROWSY

🚦 Braking Logic

State Behavior
NORMAL No action
ALERT_PHASE Warning + 80% speed
GENTLE_BRAKE Gradual slowdown
HARD_BRAKE Full stop
EMERGENCY_STOP Emergency command
RECOVERY Smooth speed restoration

πŸ›‘οΈ Safety Design

  • ❌ No sudden braking
  • πŸ“‰ Gradual velocity reduction using jerk limits
  • ⏱️ Progressive escalation (~25 seconds)
  • πŸ”„ Controlled recovery (~8 seconds ramp-up)
  • 🚫 No false positives if camera fails

πŸ§ͺ Testing

pytest

βœ”οΈ Result:

16 passed in 0.75s

πŸ“Š Configuration

Edit parameters in:

config/drowsiness_params.yaml

Example:

ear_threshold: 0.21
mar_threshold: 0.75
velocity_steps: [0.80, 0.60, 0.40, 0.20, 0.10, 0.0]

πŸ” Monitoring & Debugging

# View drowsiness state
ros2 topic echo /drowsiness_control/status

# View braking state
ros2 topic echo /drowsiness_control/braking_state

# View debug feed
ros2 run rqt_image_view rqt_image_view /drowsiness_control/debug_image

πŸš€ Future Work

  • Night-time robustness
  • Driver-specific calibration
  • Multi-camera fusion
  • ML-based fatigue prediction
  • Integration with cabin sensors

🀝 Contributing

Contributions are welcome!

  1. Fork the repo
  2. Create a feature branch
  3. Commit changes
  4. Open a pull request

πŸ“œ License

This project is licensed under the MIT License.


πŸ‘€ Author

Abinesh K


⭐ Show Your Support

If you find this project useful:

  • ⭐ Star the repo
  • 🍴 Fork it
  • πŸ§‘β€πŸ’» Contribute

🧩 Tech Stack

  • ROS2
  • Python
  • OpenCV
  • MediaPipe
  • Autoware

πŸ“Œ Summary

A complete end-to-end safety system combining:

  • Computer Vision
  • ROS2 Middleware
  • Autonomous Vehicle Control
  • Real-time State Machines

Designed for real-world autonomous driving safety applications.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors