Lane change assist and traffic jam assist calculator
A lane change is safe under UN Regulation 79 when the car coming up behind in the target lane would not have to brake harder than 3 m/s², from 0.4 s after you start moving over, to stay one second of your travel behind you. At 80 km/h, with a car behind at 130 km/h, that needs a gap of 59.9 m.
This calculator works out that critical gap for UN R79 and UN R157, the R157 following distances for a traffic jam, and checks Simulink models of a traffic jam assistant and a lane changing assistant. Traffic jam assist follows the car ahead in dense, slow traffic and keeps the lane; lane change assist watches the lanes beside and behind before a move. The last two tabs test the two Skill-Lync MBD projects of those names over every input, with what 569 public reports did. Free, no sign-up, runs in your browser.
UN R79 03 series (ACSF Category C), UN R157 01 series (ALKS), MathWorks Simulink block documentation (R2026b) · checked against an independent script (9,033 checks at build) · Updated 23 Nov 2026
Speeds are those at the start of the lane change manoeuvre; the gap is from your rear bumper to the rear car's front. R79 caps the rear car's speed at 130 km/h in the formula; R157 does not. R157 gives the rule in words, and the page applies R79's formula with R157's A, B and C. The lateral check assumes a smooth minimum-jerk path, which neither regulation prescribes.
R157's table runs to 60 km/h; above that it points to national rules, so no minimum is shown. The stop check is for a car ahead that is already standing: delay, then constant braking. For a car ahead that brakes while you follow, use the ACC calculator.
The page models each block as MathWorks documents it, then runs all 131,072 combinations of Input_Voltage 0-255, Enable_Display 0-255 and Input_Switch 0/1 against the project statement. The spec does not say what to show for a saturated Enable_Display of 0, 6 or 7, so those cases are listed apart, not counted as wrong. Port numbers are read as one-based, the block's default.
The sweep runs Highway_Input_Signal and Lane_Input_Signal 0-255 with Enable_Display and Input_Switch 0/1 (262,144 cases), each held for two steps from the start. It takes on = 1, off = 0 and lane mode = Highway_Input_Signal 0, which the spec implies but does not state; Highway_Input_Signal 2-255 is not in the spec and is only reported.
- Terms: closing 5.56 m during tB + 32.2 m while braking + 22.2 m (1 s of your travel) = 59.93 m.
How does a car decide a lane change is safe?
UN Regulation No. 79 covers steering equipment. Its ACSF Category C is a lane change the system carries out after the driver switches on the indicator, on roads with no pedestrians or cyclists, a physical separation from oncoming traffic and at least two lanes each way. Paragraph 5.6.4.7 defines when the system must not start the move: when a car coming up from behind in the target lane "would have to decelerate at a higher level than 3m/s², 0.4 seconds after the lane change manoeuvre has started, to ensure the distance between the two vehicles is never less than that which the lane change vehicle travels in 1 second". The resulting critical distance is printed as:
with a = 3 m/s², tB = 0.4 s, tG = 1 s, and vrear the approaching car's speed or 130 km/h, whichever is lower. The three terms are the distance the rear car closes before it brakes, the distance it closes while braking down to your speed, and the one second of your travel that must be left. Worked by hand:
| Your speed | Rear car | Before braking | While braking | 1 s of yours | Critical gap |
|---|---|---|---|---|---|
| 80 km/h | 130 km/h | 5.56 m | 32.15 m | 22.22 m | 59.9 m |
| 100 km/h | 120 km/h | 2.22 m | 5.14 m | 27.78 m | 35.1 m |
| 60 km/h | 150 km/h (130 used) | 7.78 m | 63.01 m | 16.67 m | 87.5 m |
Without the 130 km/h cap, the last row would need 130.8 m. The time to collision is not the test: at 80 km/h against 130 km/h, a 70 m gap closes in 5.04 s, yet the lane change may start, because the rear car only needs 2.28 m/s² to keep its distance:
Sensor range. Paragraph 5.6.4.8.1 asks the system to detect cars approaching from the rear up to a distance Srear that the maker declares, "not less than 55 m". Below a minimum speed the system may only change lanes when it has a car in view; with Vapp = 36.1 m/s (130 km/h):
For Srear = 55 m this gives 23.5 m/s, or 84.6 km/h. A sensor that sees 55 m behind cannot vouch for an empty lane below that speed. R79 also limits the manoeuvre: lateral acceleration at most 1 m/s² above what the curve gives, a half-second moving average of lateral jerk at most 5 m/s³, and the move completed in under 5 s for cars and vans (10 s for buses and trucks).
R157 lane changes. The 01 series of UN R157 (Automated Lane Keeping Systems) states the same condition in words with A, B and C. For a regular lane change A is 3.0 m/s², C is 1.0 s and B is 0.4 s if the rear car's full width was seen for at least 1 s, else 1.4 s. At 80 km/h against 130 km/h that is 59.9 m or 73.8 m. For a minimal risk manoeuvre A is 3.7 m/s², B can be 0 s, and C 0.5 s towards a slower lane or the hard shoulder: 37.2 m. A car behind at your speed or slower must be at least one second of its own travel away (0.7 s in an MRM). If no car is seen, R157 assumes one at the rearward detection range at the speed limit + 30 km/h (at most 160 km/h). At 100 km/h on a 130 km/h road, the check passes only if the declared range is at least 80.7 m (B = 0.4 s) or 97.4 m (B = 1.4 s).
How long a lane change takes. On a minimum-jerk path the peak lateral acceleration is fixed by the lateral move Y and the time T:
A 3.5 m move within 1 m/s² needs at least 4.5 s, inside R79's 5 s for a car. In 4.8 s it peaks at 0.877 m/s², with a 0.5 s average jerk of 1.35 m/s³.
What following distance does R157 ask for in a traffic jam?
An ALKS up to 60 km/h must keep at least dmin to the car in front, never below 2 m (2.4 m for buses and trucks) under 2 m/s. Speeds between rows are linearly interpolated; the text does not say whether the time gap or the distance is interpolated, so the calculator interpolates the time gap and also shows the other reading:
| Speed | m/s | Time gap, M1/N1 | Distance | Time gap, M2/M3/N2/N3 | Distance |
|---|---|---|---|---|---|
| 7.2 km/h | 2 | 1 s | 2 m | 1.2 s | 2.4 m |
| 10 km/h | 2.78 | 1.1 s | 3.1 m | 1.4 s | 3.9 m |
| 20 km/h | 5.56 | 1.2 s | 6.7 m | 1.6 s | 8.9 m |
| 30 km/h | 8.33 | 1.3 s | 10.8 m | 1.8 s | 15 m |
| 40 km/h | 11.11 | 1.4 s | 15.6 m | 2 s | 22.2 m |
| 50 km/h | 13.89 | 1.5 s | 20.8 m | 2.2 s | 30.6 m |
| 60 km/h | 16.67 | 1.6 s | 26.7 m | 2.4 s | 40 m |
At 35 km/h the interpolated time gap gives 13.13 m, and interpolating the printed distances gives 13.2 m. At 40 km/h behind a car doing 20 km/h with an 18 m gap, the time gap is 1.62 s and the time to collision 3.24 s; stopping from 40 km/h at 4 m/s² after a 0.5 s delay takes 21 m. A car cutting in at 20 km/h slower must be avoided if the time to collision at the lane intrusion point is above 0.813 s (R157 5.2.5.2). For a car ahead that brakes while you follow, the adaptive cruise control calculator runs the ISO 15622 time gap and the two-car braking case.
R157's original text limited the system to 60 km/h; the 01 series allows up to 130 km/h, but above 60 km/h only if the system can change lanes in a minimal risk manoeuvre. The declared forward detection range must be at least 46 m up to 60 km/h:
| Specified maximum speed | 0-60 | 70 | 80 | 90 | 100 | 110 | 120 | 130 |
|---|---|---|---|---|---|---|---|---|
| Minimum forward range (m) | 46 | 50 | 60 | 75 | 90 | 110 | 130 | 150 |
The Traffic Jam Assistant project's own description sets the same 60 km/h boundary for activation ("at speeds less than 60 kmph"). That is the project's assumption, not a figure from R157.
What the Traffic Jam Assistant project asks, and which Simulink settings change the answer
"Project 1- Traffic Jam Assistant Feature" is display logic for the instrument cluster, built in Simulink to MBD rules with a data dictionary, a Model Advisor report and Embedded Coder. Optimum_Voltage is true when VOLTAGE_MINIMUM_RANGE (30) ≤ Input_Voltage ≤ VOLTAGE_MAXIMUM_RANGE (50). Enable_Display is saturated to 0-7 and feeds a five-port Multiport Switch: ports 1 and 2 are ON_MODE (1), 3 and 4 OFF_MODE (2), 5 STANDBY_MODE (3). A Switch passes that value when NOT Input_Switch AND Optimum_Voltage AND (INTERRUPT_1 == INTERRUPT_2), and NO_DISPLAY (0) otherwise.
The spec never sets the Switch criterion, the Multiport port order or its default case. Here is what each does, from the MathWorks block pages:
- The Switch. The current default is u2 > Threshold with Threshold 0. A trap would be u2 >= 0, which a 0 or 1 control always meets. But the AND block outputs boolean by default, and for a boolean control Simulink routes by the boolean and warns whenever the criterion is not one of (u2 >= 1), (u2 > 0) or (u2 ~= 0). So u2 >= 0 only breaks the model if the AND output is typed uint8 or double; then 1,25,696 of the 1,25,801 specified cases show a mode instead of NO_DISPLAY. No report's pasted code shows the trap: in 138, NO_DISPLAY is reached whenever the AND is 0.
- The Multiport Switch. Defaults: one-based ports, last data port for the default case, diagnostic Error. A saturated Enable_Display of 0, 6 or 7 has no port. In simulation those inputs stop the run: with the display on (21 voltages × 251 values of Enable_Display), 5,271 of the 131,072 combinations. Generated code uses port 5 instead, so the same inputs show STANDBY. With conditional input branch execution off (it is on by default), the Multiport Switch runs even when the Switch passes NO_DISPLAY, and 1,28,512 combinations stop the run.
- Zero-based order sends 0 to port 1 (ON) and moves every other value up a port, so Enable_Display 2 shows OFF and 4 shows STANDBY: 42 specified cases differ from the one-based reading, plus 21 for the value 0.
The mistakes the reports' code actually shows are elsewhere. An OR gate instead of the AND, or Relational Operators chained so that the second compares the first one's true/false output with 50, makes Optimum_Voltage always true: 60,160 cases differ. A saturation of 0 to 1 means only ON_MODE can show: 63 cases. Pick a start in the "Check my TJA model" tab to see each.
What the Lane Changing Assistant project asks
"Project 2-Highway Assistant-Lane Changing Assistant" is also cluster display logic, generated with the AUTOSAR coder. Two Stateflow charts write four display values each. With Highway_Input_Signal = 1 and Input_Switch on, Highway_Display_Mode_1 to 4 are 232, 183, 41, 94 with Enable_Display off and 213, 183, 9, 94 with it on. With Lane_Input_Signal = 6, the lane values are 132, 185, 54, 67 and 127, 248, 186, 84. Four Switch blocks, with Highway_Input_Signal as control, pick highway or lane values as Display_Mode_1 to 4. Ports are named Rp_ (receiver, inputs) and Pp_ (sender, outputs), interfaces SRIf_ and data elements DE_.
The spec leaves open what on and off are for a uint8, what the outputs are when no row holds, and the Switch criterion. The defaults work: u2 > 0 sends Highway_Input_Signal 1 to the highway values and 0 to the lane values, and the reports' code uses > 0 (57) or ~= 0 (53), which are the same for a uint8. With u2 >= 0, every lane-mode case shows highway values (1,024 cases). Swapping the Enable_Display rows or testing Input_Switch == 0 breaks all 514 spec cases. A chart whose default transition enters a row state shows that row's values before any input matches; held for one step, 257 spec cases start with the wrong row.
What 569 traffic jam and lane change reports did
As of 23 Nov 2026, Skill-Lync has 307 public reports on the Traffic Jam Assistant project (n = 307) and 262 on the Lane Changing Assistant (n = 262). The problem statement is pasted into most of them, so the counts below come from each learner's own text and, above all, from the generated C code they pasted, never from the spec text. 51 reports are image-only (screenshots and under 100 words of their own), so every count is a floor.
| Traffic Jam Assistant (n = 307) | Reports |
|---|---|
| Pasted the generated C step function (1, 2, 3) | 166 |
| Code: NO_DISPLAY is reached when the AND is 0 (Switch criterion is not "u2 >= 0") (1, 2, 3) | 138 |
| Code: Multiport Switch one-based (case 1-4 + default): Enable_Display 0, 5, 6, 7 show STANDBY_MODE (1, 2, 3) | 83 |
| Code: Multiport Switch zero-based (case 0-3 + default): Enable_Display 0 shows ON_MODE, 4-7 STANDBY_MODE (1, 2, 3) | 31 |
| Code: Saturation is 0-7 (upper limit 7) (1, 2, 3) | 102 |
| Code: Saturation is not 0-7 (left at +/-0.5, or clamps Enable_Display to 0/1) (1, 2, 3) | 27 |
| Code: voltage window is not MIN <= V <= MAX (OR gate, chained compare, wrong bound, strict compare) (1, 2, 3) | 53 |
| Code: inputs typed double (real_T) instead of uint8 (1, 2, 3) | 25 |
| Stated the Switch block criterion or threshold in own text | 0 |
| Stated the Multiport data-port order or default-case setting in own text (1, 2, 3) | 4 |
| Described input/output test cases in own text (1) | 1 |
| Image-only (screenshots, under 100 words of own text, no code) (1, 2, 3) | 29 |
| Lane Changing Assistant (n = 262) | Reports |
|---|---|
| Pasted the generated C step function (1, 2, 3) | 133 |
| Code: AUTOSAR target (autosar.tlc) (1, 2, 3) | 143 |
| Code: Rte reads use Rp_ ports and DE_ data elements (1, 2, 3) | 116 |
| Code: Rte port and data element names disagree (typo, shared element, or another signal) (1, 2, 3) | 15 |
| Code: Req 3 Switch tests Highway_Input_Signal ~= 0 (1, 2, 3) | 53 |
| Code: Req 3 Switch tests Highway_Input_Signal > 0 (1, 2, 3) | 57 |
| Code: Stateflow on = 1, off = 0 for Enable_Display (1, 2, 3) | 118 |
| Code: chart starts in a state that already outputs spec values (before any condition holds) (1, 2, 3) | 119 |
| Code: chart starts in an init state with no outputs set (outputs stay at initial value 0) (1, 2, 3) | 8 |
| Code: chart guards differ from the spec rows (on/off rows swapped, Input_Switch == 0, or signals crossed) (1, 2, 3) | 37 |
| Code: a chart writes a display value that is not in the spec table (typo) (1, 2, 3) | 8 |
| Named the SRIf_ interface prefix in text (any spelling) (1, 2, 3) | 131 |
| Stated on/off encoding in own text (on = 1, off = 0 ...) | 0 |
| Stated Stateflow default transition / initial state in own text (1) | 1 |
| Stated the Req 3 Switch criterion or threshold in own text | 0 |
| Described input/output test cases in own text | 0 |
| Image-only (screenshots, under 100 words of own text, no code) (1, 2, 3) | 22 |
What stands out. 53 of 307 Traffic Jam Assistant reports have a voltage window that is not MIN ≤ V ≤ MAX in their code: an OR gate in 29, a chained compare that is always true in 12, a wrong bound in 9. No report says which Switch criterion or port order it used. In the lane change reports, 32 of the 106 charts whose code could be read swap the Enable_Display rows, 15 pair a port with another signal's data element, and SRIf_ is also spelt SRIF_ (15), SRif_ (9) and SIRF_ (5). The name check in the last tab catches those.
What this calculator does not cover
- Later R79 revisions. The R79 values are from the 03 series text (Revision 3, Amendment 2); later revisions were not read.
- Braking or accelerating during the lane change. R157 says any deceleration of the ALKS vehicle must be counted; the calculator holds your speed constant.
- R79's detection area figure and R157's sensing widths beyond the 9 m stated in the text.
- Saturation left at ±0.5. 10 reports keep the block's default limits; how a uint8 signal rounds against a 0.5 limit is not in the pages read, so the tool only takes whole-number limits.
- Older Simulink releases. The block defaults are from the R2026b and R2024a pages; the reports mostly used R2021a, whose pages are not online. Set the criterion you used.
Turning a requirement into a Simulink and Stateflow model, testing it and generating Embedded Coder or AUTOSAR code is what ADAS software roles ask for. Both projects on this page sit in Skill-Lync's model-based development course.
Frequently asked questions
What is traffic jam assist?
It follows the car ahead in slow, dense traffic and keeps the lane, so the car starts, brakes and steers by itself while the driver supervises. The Skill-Lync project text describes it as adaptive cruise with stop and go plus lane keeping, which the driver switches on at speeds below 60 km/h.
What is a lane change assist?
In the project's description, two mid-range radars in the rear bumper watch the lanes beside and behind the car. If a car approaches fast or sits in the blind spot, a light in the mirror warns the driver, and an acoustic or haptic warning follows if the driver still signals to change lanes.
How does a car decide a lane change is safe?
UN R79 calls it critical when the car behind in the target lane would have to brake harder than 3 m/s², starting 0.4 s after the manoeuvre begins, to stay one second of your travel behind you. At 80 km/h with a car closing at 130 km/h, the gap must be 59.9 m.
What are UN R79 and UN R157?
They are UN regulations for vehicle approval. R79 covers steering equipment, including ACSF Category C: a lane change the system performs after the driver signals. R157 covers Automated Lane Keeping Systems. Its original text allowed up to 60 km/h; the 01 series allows up to 130 km/h, with lane changes.
What does the Simulink Switch threshold do?
The Switch passes input 1 when the control (u2) meets the criterion, else input 3. The criteria are u2 >= Threshold, u2 > Threshold (the default in the current documentation) and u2 ~= 0; the default threshold is 0. With a boolean control, other combinations are ignored with a warning.
Why does my Multiport Switch error for 0?
With the default one-based port order, 0 has no data port. The default diagnostic for that case is Error, which stops the simulation. Generated code instead uses the last data port. Saturating Enable_Display to 0 to 7 leaves 0, 6 and 7 without a port, so pick zero-based order, specified indices or a warning.
What is SLDD in Simulink?
SLDD is a Simulink data dictionary, an .sldd file. MathWorks calls it a persistent repository of the design data for a model: parameters, signals and their types, not the simulation data that flow through inports and outports. You link it to the model, which reads the data from it in simulation and code generation.
What does Model Advisor check with MAB guidelines?
MAB guidelines are MathWorks Advisory Board rules for Simulink and Stateflow models, aimed at readability, simulation and verification, and code generation. With a Simulink Check licence, Model Advisor checks a model against them: naming, diagram appearance, blocks, signals and Stateflow patterns, as the report's pass and warning lists show.
What are Rp_ and Pp_ ports in AUTOSAR?
They are the prefixes the lane changing project asks for: Rp_ for receiver ports (the inputs) and Pp_ for sender ports (the outputs). In AUTOSAR terms these are require and provide ports of sender-receiver interfaces, named SRIf_ here, whose data elements carry the DE_ prefix.
Related on Skill-Lync
- Adaptive cruise control calculator (ISO 15622 time gap, the car ahead braking, a Stateflow guard checker)
- MC/DC coverage calculator (the minimum tests for NOT Input_Switch AND Optimum_Voltage AND INTERRUPT_1 == INTERRUPT_2)
- Vehicle direction detection checker (the same course's Project 1: steering angle to Vehicle_Turn_Status, the road sign camera, boundary test vectors)
- Lookup table calculator (Simulink 1-D and 2-D lookup tables)
- ABS slip ratio and wheel speed calculator (another MBD project)
- Steering geometry calculator
- All free engineering tools
Sources
- UNECE, UN Regulation No. 79, Revision 3, Amendment 2 (03 series, in force 16 October 2018), E/ECE/324/Rev.1/Add.78/Rev.3/Amend.2: paragraphs 5.6.4.2.3, 5.6.4.4, 5.6.4.6.4, 5.6.4.6.5, 5.6.4.7 (critical situation and formula) and 5.6.4.8.1 (Srear at least 55 m, VSmin).
- UNECE, UN Regulation No. 157, Amendment 4 (01 series, in force 4 January 2023), E/ECE/TRANS/505/Rev.3/Add.156/Amend.4: 2.1, 5.2.3.1, 5.2.3.3 (minimum following distance table), 5.2.5.2 (cut-in TTC), 5.2.6.6.1, 5.2.6.7.2 and 5.2.6.7.3 (target lane assessment), 7.1.1 and 7.1.3 (detection ranges). Amendment 1 to the original version: 5.2.3.1 (60 km/h).
- MathWorks, Simulink documentation (R2026b, read 23 Nov 2026): Switch (criteria, default u2 > Threshold, Threshold 0, boolean control behaviour, conditional input execution), Multiport Switch (port order, default case, diagnostic, simulation and code generation tables), Conditional input branch execution, Saturation, Logical Operator and Relational Operator (boolean output), Stateflow data properties (initial value 0), What Is a Data Dictionary, MAB modeling guidelines, Configure AUTOSAR Sender-Receiver Communication.
- Skill-Lync, 569 public reports on the two MBD projects, read 23 Nov 2026: the project statements and the counts above, from a script whose matches were checked by hand.
- Skill-Lync, scripts/verify/lane_change_assist.py: critical gaps found by moving the two cars and bisecting the starting gap, the lateral path differentiated as a polynomial, the R157 tables typed in again, and both projects rebuilt block by block and swept over every input; the page compares 9,033 numbers with it when it is built.