The problem
In Indian cities, traffic moves in slow waves with frequent stops and constant cut-ins by two-wheelers, autos and cars. Standard ACC often switches off below a certain speed, leaving the driver to creep along. A stop-and-go function that follows the lead vehicle to a stop, holds, and resumes reduces fatigue, but it must handle short gaps, frequent cut-ins and the risk of a pedestrian crossing in front of a stopped car.
Objectives
- Write requirements for low-speed following, standstill hold and resume.
- Model the EV longitudinal dynamics at low speed, including creep and brake hold.
- Design a spacing controller suited to short gaps and low speeds.
- Implement standstill, hold and resume logic in Stateflow with driver confirmation.
- Test on dense stop-and-go traffic profiles with frequent cut-ins.
What you need
Tools and toolboxes
- Simulink — The low-speed vehicle model, spacing controller and test bench.
- Stateflow — The mode logic for following, stopping, standstill hold, auto-resume and driver-confirmed resume.
- MATLAB — Generating stop-and-go traffic profiles, batch runs and metric calculation.
- Automated Driving Toolbox (optional) — Driving Scenario Designer scenarios with cut-ins by cars and motorcycles in dense traffic.
Software
- MATLAB R2023b or later
- Simulink
- Stateflow
- Automated Driving Toolbox (optional)
Extra parts and data
None beyond the software above.
Key concepts
- Standstill distance
- The gap left when both vehicles are stopped, typically a few metres. Too short feels unsafe; too long invites cut-ins, which is a real issue in Indian traffic.
- Standstill hold
- Holding the car with the brakes after it stops, so it does not creep forward. After a set time, the system may require the driver to confirm before it moves off again.
- Auto-resume
- Moving off automatically when the lead vehicle pulls away within a short time after stopping. After longer stops, a driver input is required, because the scene may have changed.
- Cut-in handling
- When a vehicle moves into the gap, the target changes suddenly to a closer one. The controller must respond smoothly without harsh braking unless needed for safety.
Step-by-step guide
- 1
Write the requirements
Write numbered requirements: operation from standstill to 60 km/h; following with a time gap plus a standstill distance of about 2 to 4 m; automatic stop behind a stopping lead vehicle; brake hold at standstill; automatic resume if the lead moves within a short window, such as 3 s, otherwise resume only after a driver input; and comfort limits on acceleration, deceleration and jerk at low speed. Include a requirement for cut-in response with a measurable criterion.
Checkpoint: A numbered requirement list with measurable criteria for every behaviour.
- 2
Build the low-speed vehicle model
Model the EV's longitudinal dynamics with attention to low speed: creep torque if the vehicle has it, rolling resistance at low speed, brake hold at standstill and the transition between motor drive and friction braking. Add actuator lag. Make sure the model can come to a true stop and stay stopped, with no small negative speeds from numerical integration. Test with step inputs to and from standstill.
Checkpoint: Stop and pull-away tests where speed reaches exactly zero and remains there under brake hold.
- 3
Generate stop-and-go traffic profiles
Create lead-vehicle speed profiles typical of congested city roads: repeated waves between 0 and 25 km/h, stops of different lengths, slow creeping and sudden stops. Build them from piecewise segments with random durations and accelerations within realistic limits, using fixed seeds. Also script cut-in events where a two-wheeler or car enters the gap at different distances, and cut-outs revealing a stopped vehicle.
Checkpoint: A set of at least ten traffic profiles plotted with stops and cut-ins marked.
- 4
Design the low-speed spacing controller
Use a desired distance of standstill distance plus time gap times ego speed, and a feedback law on spacing error and relative speed. Tune gains for low speed, where a fixed gain designed for highway speed often feels too aggressive. Consider gain scheduling with speed. Limit acceleration, deceleration and jerk. Check that the ego stops at the standstill distance without overshoot when the lead vehicle stops.
Checkpoint: Stopping behind a stopping lead with final gap within a stated tolerance of the standstill distance.
- 5
Implement the Stateflow mode logic
Build states for Off, Following, Stopping, StandstillHold, AutoResumeWindow and WaitDriverResume. Following moves to Stopping when the demand brings speed near zero; StandstillHold holds the brakes; if the lead pulls away within the resume window, the car moves off automatically; otherwise it waits for a driver input such as the resume button or a light accelerator tap. Brake pedal input cancels at any time.
Checkpoint: Animated Stateflow runs showing correct transitions for short stops, long stops and driver inputs.
- 6
Handle cut-ins and target changes
When the selected target changes to a closer vehicle, the spacing error jumps. Smooth the response by limiting the rate of change of the desired gap or by temporarily accepting a shorter time gap, while keeping a minimum safe gap. If the required deceleration exceeds the comfort limit, request a takeover warning. Test with two-wheeler cut-ins at 3, 5 and 8 m at low speed.
Checkpoint: Cut-in runs where deceleration stays within comfort limits except where a warning is correctly raised.
- 7
Add a moving-off safety check
Before an automatic resume, check that the space ahead is clear using the lead-vehicle distance and a simple flag for an object detected in the near zone in front of the car. If something appears in that zone, such as a pedestrian crossing, block the resume and wait for the driver. Model the near-zone flag as an input that test scenarios can set at chosen times.
Checkpoint: A test where a near-zone object appears during the resume window and the car stays stopped.
- 8
Run the batch tests
Run every traffic profile with sim() at the three time-gap settings, logging speed, gap, acceleration, jerk, mode and events. Compute metrics: mean and minimum gap, maximum deceleration and jerk, number of stops, standstill distance error, resume delay after the lead moves off and number of takeover warnings. Compare with a baseline ACC that switches off below 30 km/h, where the driver model takes over.
Checkpoint: A results table comparing the stop-and-go function with the baseline ACC on all profiles.
- 9
Verify the requirements
Write automatic checks for each requirement and run them over all results, producing a pass or fail per requirement and profile. Give special attention to standstill hold, auto-resume window and cut-in behaviour, which are the most safety-relevant. Investigate every failure, then fix the design or adjust the requirement with a written justification, never silently. Keep the checking functions separate from the model so they can be reused if the design changes later.
Checkpoint: A requirement pass/fail matrix with every failure resolved or justified.
- 10
Report
Write up the requirements, low-speed model, traffic profile generation, controller and mode logic, cut-in handling, safety checks and results. Discuss the trade-off between short gaps that discourage cut-ins and the comfort and safety margins needed. State that this is a simulation study and that any vehicle testing must be done in a closed area under supervision, not in public traffic.
Checkpoint: A report with traceability, comparison results and the reproducible model and profiles.
Testing & validation
- Vehicle model reaches and holds standstill correctly.
- Standstill distance error and minimum gap in all stop-and-go profiles.
- Comfort metrics: maximum deceleration and jerk at low speed.
- Auto-resume, driver-confirmed resume and near-zone blocking behaviour.
- Cut-in response for two-wheelers and cars at several distances.
Expected results
A stop-and-go traffic jam assist that follows to standstill, holds and resumes safely, tested on synthetic dense city traffic with frequent cut-ins and verified against written requirements.
Take it further
- Add lateral lane centring at low speed for a full traffic jam assist.
- Use recorded speed traces from congested Indian roads to build the profiles.
- Optimise the controller for energy use with regenerative braking.
- Replace the near-zone flag with an ultrasonic sensor model.
Viva and review questions
Why does the car need a driver input to resume after a long stop?
During a long stop the scene may have changed, for example a pedestrian may be in front, so a driver confirmation adds a check before the car moves.
Why is the standstill distance a trade-off in Indian traffic?
A large gap invites two-wheelers and cars to cut in, while a very small gap leaves no margin for errors or rollback.
How did you handle a cut-in?
The target switches to the closer vehicle, and the desired gap is changed at a limited rate so the response stays smooth, with a takeover warning if comfort braking is not enough.
Learn it at DIYguru
These DIYguru courses and programmes teach what this project needs.
