A real-time driver monitoring and safety system built on ROS2 that detects drowsiness using computer vision and progressively applies braking via Autoware.
- ποΈ 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)
graph LR
CAM[Camera] --> DET[Detector]
DET --> CTRL[Braking Controller]
CTRL --> AUTO[Autoware Interface]
AUTO --> VEH[Vehicle Control]
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)cd ~/project/autoware/src
git clone <your-repo-url>pip3 install mediapipe opencv-pythoncd ~/project/autoware
colcon build --packages-select drowsiness_control --symlink-install
source install/setup.bashros2 launch drowsiness_control drowsiness_control.launch.pyros2 launch drowsiness_control drowsiness_control.launch.py \
camera_index:=0 \
max_velocity_mps:=8.33 \
publish_debug:=true| 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 |
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
| 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 |
- β 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
pytestβοΈ Result:
16 passed in 0.75s
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]# 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- Night-time robustness
- Driver-specific calibration
- Multi-camera fusion
- ML-based fatigue prediction
- Integration with cabin sensors
Contributions are welcome!
- Fork the repo
- Create a feature branch
- Commit changes
- Open a pull request
This project is licensed under the MIT License.
Abinesh K
If you find this project useful:
- β Star the repo
- π΄ Fork it
- π§βπ» Contribute
- ROS2
- Python
- OpenCV
- MediaPipe
- Autoware
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.