Skip to content

beingujjwalraj/AI-Driven-adaptive-torque-allocation-for-electric-vehicles-on-rough-terrain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

57 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

AI-Driven Adaptive Torque Allocation for Electric Vehicles on Rough Terrain ๐Ÿš—โšก๐ŸŒ

Project Demo Techgium Finalist


๐Ÿ”ฅ Project Overview

This project, selected among the finalists of the 8th edition of TECHgium (L&T Technology Services) from over 40,000+ students, proposes a novel AI-based torque allocation system for electric vehicles navigating rough terrains. The aim is to maximize vehicle stability, avoid skidding, and adaptively balance torque across all four wheels based on real-time sensor input.

We built a complete simulation using Gazebo, developed an optimization algorithm (SLSQP) to compute adaptive torque distribution, trained a deep learning model, and finally deployed it in a Raspberry Pi-powered prototype. The real-time control and monitoring were achieved via a custom-built Flask web application.


๐Ÿ“ Project Structure

Rubicon/
โ”œโ”€โ”€ Evata/                          # EV Car Model
โ”‚   โ”œโ”€โ”€ Materials/
โ”‚   โ”œโ”€โ”€ Meshes/
โ”‚   โ”œโ”€โ”€ Thumbnails/
โ”‚   โ””โ”€โ”€ model.sdf
โ”‚
โ”œโ”€โ”€ World_Assets/                  # Terrain Assets for Gazebo
โ”‚   โ”œโ”€โ”€ Materials/
โ”‚   โ”œโ”€โ”€ Meshes/
โ”‚   โ”œโ”€โ”€ Thumbnails/
โ”‚   โ””โ”€โ”€ model.sdf
โ”‚
โ”œโ”€โ”€ try_world.sdf                  # Custom rough terrain Gazebo world

โ”œโ”€โ”€ imu_reader5.py                 # IMU sensor reading and preprocessing script
โ”œโ”€โ”€ training_data.csv              # Raw data from Gazebo simulation
โ”œโ”€โ”€ ai_model.csv                   # Processed dataset after optimization and feature engineering
โ”œโ”€โ”€ ai_model.ipynb                 # AI training notebook
โ”œโ”€โ”€ ai_model.keras                 # Trained neural network model (exported)
โ”œโ”€โ”€ index.html                     # Flask dashboard template
โ”œโ”€โ”€ raspi3.py                      # Main hardware control script (Raspberry Pi + sensors + AI + Flask)

๐Ÿš€ Key Highlights

๐Ÿ› ๏ธ Phase 1: Simulation in Gazebo

  • Rough Terrain World: Created a custom uneven terrain in Gazebo.
  • EV Model: Integrated a 4-wheel-drive electric car model with sensor mounts.
  • Data Logging: Captured ax, ay, az, wx, wy, wz from the IMU during runs.

๐Ÿ“Š Phase 2: Data Processing & Optimization

  • Velocity Calculation: Derived vx, vy using acceleration data.
  • Wheel Speed Estimation: Applied rigid body kinematics.
  • Slip Angle: Estimated slip angle for each wheel โ€” a major factor in torque gaps.
  • Optimization Algorithm: Used SLSQP to:
    • Ensure torque โ‰ค motor max torque.
    • Fulfill driver-demanded torque.
    • Balance left vs. right wheels.
  • Torque to Duty Cycle: Converted optimized torque to RPM โ†’ Duty Cycle (for motor drivers).

๐Ÿง  Phase 3: AI Model Development

  • Input Features: ax, ay, wx, wy, wz
  • Target: fl_duty, fr_duty, rl_duty, rr_duty
  • Model: Neural Network (4 hidden layers, ReLU + Dropout)
  • Optimizer: Adam
  • Output: .keras file + scaler.pkl

๐Ÿ’ป Phase 4: Deployment on Raspberry Pi 4B

  • Created a virtual environment for isolated dependency management.
  • Installed packages like keras, scikit-learn, flask, RPi.GPIO, etc.
  • Uploaded model and scaler to run real-time inference from IMU.

๐Ÿ”ง Phase 5: Hardware Prototype

  • Chassis: 4-wheel drive (4 DC motors).
  • Motor Control: Two L298N motor drivers for independent control.
  • Sensors:
    • IMU: Real-time terrain sensing.
    • Ultrasonic Sensor: Obstacle avoidance (20cm threshold).
    • Buzzer: Alerts on obstacle detection.
  • AI Inference: AI model predicts optimal duty cycles in real-time.

๐ŸŒ Phase 6: Flask-Based Web App (RC + Visualization)

  • Control: Forward, Backward, Left, Right
  • Live Graphs:
    • Roll vs. Time ๐Ÿ“ˆ
    • Pitch vs. Time ๐Ÿ“‰
    • Duty Cycle Distribution
  • Toggle AI Mode ON/OFF to compare stability
  • Emergency Stop Button
  • Responsive and clean UI

๐Ÿง  Project Architecture

Screenshot 2025-05-20 at 1 50 10โ€ฏAM

๐Ÿ“ฝ๏ธ Project at a Glance

Screenshot 2025-05-20 at 1 58 00โ€ฏAM

๐ŸŒŸ Results

Condition Stability (Pitch/Roll) Torque Distribution
Without AI High Variance Random/Fixed
With AI Smoother Performance Dynamic
  • Significant improvement in vehicle stability
  • Real-time torque balancing with AI
  • Effective slip angle adaptation

๐Ÿ”ฎ Future Enhancements

  • Integrate 360ยฐ LIDAR for advanced obstacle detection.
  • Implement Reinforcement Learning for adaptive control.
  • Expand model to handle multi-terrain transitions.
  • Deploy on real EV platforms for field testing.
  • Add cloud sync and mobile app control.

๐Ÿ“ฆ Requirements

๐Ÿงช Software Setup

Install Python dependencies using:

pip install -r requirements.txt

This includes:

  • tensorflow / keras for AI model inference
  • scikit-learn for data preprocessing (StandardScaler)
  • flask for the web dashboard
  • matplotlib, numpy, etc.

๐ŸŒ Gazebo Harmonic (For Mac M1 Users)

If you are using Mac M1, follow these steps to run the simulation and collect IMU data:

  1. Start the Gazebo Server:

    gz sim -v 4 try_world.sdf -s
  2. Launch the Gazebo GUI (in a new terminal):

    gz sim -v 4 -g
  3. To view IMU data from the running simulation, use:

    gz topic -e -t /imu

Ensure you have the EV model and terrain world files placed correctly in your project directory (try_world.sdf, Evata/, and World_Assets/).


๐Ÿ”ฉ Hardware Prototyping Requirements

To replicate the real-world testing on a prototype, you'll need:

Component Quantity Purpose
Raspberry Pi 4B 1 Main controller for AI inference + sensors
L298N Motor Driver 2 For independent control of 4 DC motors
DC Motors 4 To drive each wheel
MPU6050 Sensor 1 For real-time pitch, roll, and acceleration
Ultrasonic Sensor 1 For obstacle detection
Buzzer 1 Alerts when obstacle is near
Jumper Wires Many To connect components on breadboard
Li-Po Battery Pack 1 Power supply for motors + Raspberry Pi
Car Chassis 1 Mounting platform for motors and sensors
Breadboard 1 Prototyping connections
Power Bank 1 (optional) Power Raspberry Pi independently

๐Ÿ“ฆ Total POC cost โ‰ˆ โ‚น18,800 (as per Techgium presentation)


๐Ÿค Connect With Me

Feel free to reach out if you're curious about:

  • ๐Ÿ” AI/ML for real-world robotics
  • ๐Ÿค– AI in embedded hardware systems
  • ๐Ÿ“ˆ Data science or computer vision applications
  • ๐Ÿ’ก Startup ideas around intelligent mobility

๐Ÿ“ง ujjwalrajbgis@gmail.com
๐Ÿ”— LinkedIn

๐Ÿง‘โ€๐Ÿ’ป Authors

  • Ujjwal Raj โ€“ System Design, AI Modeling, Hardware & Integration

    Finalist at TECHgium 8th Edition | IIITDM Kancheepuram


About

An AI-driven torque allocation system for EVs on rough terrain using IMU data, deep learning, and real-time motor control via Raspberry Pi with Gazebo simulation and Flask-based dashboard.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors