Skip to main content
emobility.academy
M.TechLane keeping & lateralAdvanced About 8 weeksADAS & AUTOSAR

Lateral Assistance Concepts for Two-Wheelers: Lean-Angle-Aware Warnings

Build lean-angle-aware lateral warnings for electric two-wheelers: a Simulink motorcycle model computes safe lean limits for curves, and a bench prototype on the DIYguru EV kit estimates lean from the MPU6050 and warns of excessive lean or a fast curve approach.

Tools: MATLAB · Simulink

Lateral Assistance Concepts for Two-Wheelers: Lean-Angle-Aware Warnings: Students studying an electric car with DIYguru trainers in the workshop
Representative photo from DIYguru's EV lab, not of this specific project.

The problem

Two-wheelers make up most of India's vehicles and a large share of road fatalities, yet most lateral ADAS concepts are designed for cars. A two-wheeler leans to corner, so lane-keeping style steering assists do not transfer directly. Warnings based on lean angle, curve radius and speed are a practical first step, but they need a correct lean estimate and a sound physical limit.

Objectives

  • Model steady cornering and lean dynamics of a two-wheeler in Simulink.
  • Derive speed-dependent safe lean and speed limits for given curve radii and friction.
  • Estimate lean angle on the kit with a complementary or Kalman filter on MPU6050 data.
  • Implement warning logic and test it on a tilting bench rig and on simulated rides.

What you need

Tools and toolboxes

  • MATLAB — Deriving lean limits, analysing logged IMU data and plotting.
  • Simulink — A simplified two-wheeler roll and yaw model and the warning logic, simulated on curve scenarios.
  • Stateflow — Warning states with hysteresis (normal, caution, warning).
  • STM32CubeIDE — Firmware for IMU reading, lean estimation and warnings on the kit.
  • Python (optional) — Logging UART data from the bench rig.

From the EV Embedded Development Kit

  • STM32F103C8T6 microcontroller unit (Arm Cortex-M3)
  • 3-axis accelerometer and gyroscope (MPU6050, I2C)
  • Analog potentiometer input
  • RGB LEDs and a buzzer
  • 16×2 LCD with contrast control
  • Serial UART interface

Software

  • MATLAB, Simulink and Stateflow
  • STM32CubeIDE with STM32 HAL
  • Python 3 with pyserial (optional)

Extra parts and data

  • A simple tilting bench rig (hinged wooden board with a protractor) — Gives known lean angles and controlled rolling motion to validate the lean estimate safely, without riding.

Key concepts

Steady-state lean angle
In a steady turn the lean angle satisfies tan(phi) = v²/(g·R), ignoring tyre width. Higher speed or a tighter curve needs more lean.
Friction-limited lean
The tyre can supply lateral force up to about mu times the normal load, so the maximum lean angle is roughly arctan(mu); in practice a margin is kept well below it.
Complementary filter
Combines the gyroscope roll rate, accurate over short periods, with the accelerometer's gravity direction, accurate over long periods, to estimate lean without drift.
Centripetal acceleration error
In a turn the accelerometer measures gravity plus centripetal acceleration, so its tilt estimate is wrong; the gyro and speed-based correction must handle this.

Step-by-step guide

  1. 1

    Define scope and requirements

    Scope the project to warnings only, no steering or braking intervention, for an electric scooter or motorcycle on dry roads. Define two warnings: excessive lean, when the estimated lean approaches a set fraction of the friction-limited lean, and curve speed, when the speed is too high for an upcoming curve radius. Set targets for lean estimation error, warning latency and false-alert rate. Make it explicit that testing is on a bench rig and in simulation only.

    Checkpoint: A requirements sheet with warning definitions, accuracy targets and the test scope.

  2. 2

    Model two-wheeler cornering

    Build a Simulink model with roll and yaw dynamics of a simplified two-wheeler, using the inverted pendulum approximation for roll and a kinematic relation between steer, speed and yaw rate. Parameterise mass, centre-of-gravity height and wheelbase from published data for a typical electric scooter, noting the source. Simulate curves of different radii at several speeds and check that steady lean matches tan(phi) = v²/(gR).

    Checkpoint: Simulated steady lean angles agree with the analytical formula within a degree.

  3. 3

    Derive warning thresholds

    For friction coefficients representing dry and wet asphalt, compute the friction-limited lean and the maximum safe speed for each radius with a chosen safety margin. Produce lookup tables of safe speed against radius and lean warning thresholds. In Simulink, add a curve preview input (radius ahead at a distance) and compute the deceleration needed to reach safe speed before the curve. Trigger a curve warning when the needed deceleration exceeds a comfortable value.

    Checkpoint: Lookup tables and a curve-warning signal that fires earlier for tighter curves at higher speed.

  4. 4

    Bring up the IMU on the kit

    Enable the I2C and MPU6050 DIP switches, initialise the sensor at a known gyro and accelerometer range, and read raw data at 100 to 200 Hz in a timer interrupt. Calibrate the gyro bias by averaging readings while stationary, and check the accelerometer reads about 1 g when level. Stream the data over UART. Mount the kit on the tilting rig with the roll axis aligned with the hinge.

    Checkpoint: Stationary gyro output near zero after bias removal and accelerometer magnitude near 1 g.

  5. 5

    Estimate lean angle

    Implement a complementary filter on the STM32: integrate gyro roll rate and blend it with the accelerometer roll estimate using a time constant around 0.5 to 2 s. Validate on the rig against protractor angles at 0, 10, 20 and 30 degrees, and with slow and fast rocking motions. Optionally implement a small Kalman filter and compare. Note that on a real vehicle centripetal acceleration biases the accelerometer, and discuss a speed and yaw-rate correction.

    Checkpoint: Static lean error within about 1 degree and stable tracking during rocking motion.

  6. 6

    Implement warnings on the kit

    Use the potentiometer to stand in for vehicle speed and a fixed table of upcoming curve radii to stand in for map data. Port the threshold tables to C. Show lean angle and speed on the LCD, set the RGB LED to green, amber or red with the warning state, and sound the buzzer for warnings. Add hysteresis and minimum on-times so warnings do not chatter. Keep the warning loop in a fixed-rate task.

    Checkpoint: Tilting the rig past the threshold or turning up the speed knob triggers the correct warning state.

  7. 7

    Test in simulation and on the bench

    In Simulink, run ride profiles through a set of curves at safe and unsafe speeds and log warning timing. On the bench, replay lean profiles by hand on the rig and log the filter output and warnings over UART. Count correct warnings, missed warnings and nuisance alerts, and measure latency from crossing the threshold to the LED or buzzer change.

    Checkpoint: Tables of warning correctness and latency for simulation and bench tests.

  8. 8

    Report

    Document the model, lean limits, filter design, firmware and test results. Discuss the gap between bench and road: vibration, centripetal acceleration, tyre width effects and rider behaviour. Explain what further validation a manufacturer would need, such as instrumented rides on a closed track with a professional rider. State clearly that no on-road testing was done. Attach the firmware, Simulink model and logged data so results can be reproduced.

    Checkpoint: A report with results, limitations and a validation plan for future work.

Testing & validation

  • Lean estimate error against known rig angles, static and dynamic.
  • Warning timing in simulated rides through curves at safe and unsafe speeds.
  • Warning latency on the kit from threshold crossing to output.
  • Nuisance alerts during normal lean profiles.

Expected results

A simulated two-wheeler cornering model with lean and curve-speed limits, and a kit-based bench prototype that estimates lean from the MPU6050 and gives graded warnings with measured accuracy and latency.

Research angle for your M.Tech thesis

Research questions: how accurately can a low-cost IMU estimate lean in cornering once centripetal effects are compensated, and what warning thresholds give useful lead time with few nuisance alerts? Metrics: lean RMS error, warning lead time, false-alert rate. Comparing complementary and Kalman estimators, and evaluating threshold strategies on simulated and recorded ride data, gives a focused M.Tech study relevant to the two-wheeler-dominated Indian market.

Take it further

  • Correct the accelerometer for centripetal acceleration using speed and yaw rate.
  • Send warning states over CAN to a dashboard node.
  • Add a GPS module and map curvature for real curve preview.

Viva and review questions

Why can't car lane keeping be applied directly to a two-wheeler?

A two-wheeler corners by leaning and its steering is counter-intuitive at speed, so an automatic steering torque could destabilise it. Warnings based on lean and speed are a safer first step.

Why does the accelerometer alone give a wrong lean in a turn?

It senses gravity plus centripetal acceleration. In a coordinated turn the resultant points through the vehicle's vertical axis, so the accelerometer suggests near-zero lean.

How did you validate the lean estimate safely?

On a hinged tilting rig with a protractor, comparing the filter output with known angles under static and rocking motion.

Learn it at DIYguru

These DIYguru courses and programmes teach what this project needs.

Related EV projects

All 100 ADAS & AUTOSAR projects