Vehicle direction detection: Simulink model checker

In the vehicle direction detection project, Req 1 turns the steering-wheel angle into Vehicle_Turn_Status (30, −120 or 0 deg) with Switch blocks, and Req 2 sets Vehicle_Direction_Indicator when that status equals a RoadSign value and the camera saw a sign. Built as the statement reads, the indicator equals the camera input at every one of the 361 angles.

Run the two requirements for any angle, see the active path through the blocks, get 22 boundary test cases and a 0.01 s drive as CSV, and check your own Switch settings: the checker runs every angle from −180 to 180 deg with the camera off and on, lists the angle ranges where your model differs, and names the slip. The project is Project 1 of the Skill-Lync model-based development course; 615 public reports were read for this page. Free, no sign-up, runs in your browser.

Project statement as pasted in the reports, MathWorks Simulink and Embedded Coder documentation (R2026b), kinematic bicycle model · checked against an independent script (729 checks at build) · Updated 23 Nov 2026

Calibrations are int16 from −180 to 180. The Switch thresholds follow the angular limits; the RoadSign values are what Req 2 compares with. An int16 holds −32,768 to 32,767: type a value outside ±180 to see what the model does without a Saturation block (set its limits to −180 and 180; the block's defaults are ±0.5).

Vehicle_Turn_Status30 degSwitch 1 passes Right_Turn_AngularLimit
Direction indicator1status = RightTurn_RoadSign, camera 1
Indicator = camera722/722all angles × camera 0/1
Req 1 angle = 45 degSwitch 1: angle ≥ 30 ?TR lim 30FSwitch 2: angle ≤ -120 ?TL lim -120Fotherwise (input 3)straight 0Vehicle_Turn_Status = 30 degReq 2 S = 30, camera 1right: S = 30AND camleft: S = -120AND camstraight: S = 0AND camORVehicle_Direction_Indicator = 1
  • The indicator equals the camera input for all 722 cases (361 angles × camera 0/1): the camera alone decides it.

How does the vehicle direction detection model work?

The project has two inputs and one output. SteeringWheel_YawDegreeInput is an int16 from −180 to 180 deg; CameraInput_RoadSign is a Boolean that "confirms the occurrence of a road sign". Six int16 calibrations, all Const, hold the angles: Right_Turn_AngularLimit 30, Left_Turn_AngularLimit −120 and Straight_Drive_Steering_Angle 0 for Req 1, and RightTurn_RoadSign 30, LeftTurn_RoadSign −120 and Straight_RoadSign 0 for Req 2. Every signal runs at 0.01 s.

Req 1 compares the angle against the three angular values with Switch blocks and writes the local signal Vehicle_Turn_Status. The statement does not say what happens between the limits. The reading this page takes as the reference, with θ the steering-wheel angle:

Req 2 compares Vehicle_Turn_Status for equality with the three RoadSign values, ANDs each result with the camera input, and a logical operator gives "only one" output, Vehicle_Direction_Indicator. With S the status and C the camera:

The second line is the same expression with C taken outside. It is where the catch below comes from.

Why does the indicator just follow the camera?

Under the reference reading, Vehicle_Turn_Status is always 30, −120 or 0, so the bracket in the second line is always true and the indicator equals C. The checker does not assume this; it runs all 361 angles with the camera off and on. The indicator equals the camera input in 722 of 722 cases, and it does under the three other readings below as well. The steering angle never changes the output.

The reason is that a Boolean camera signal says that a sign was seen, not which one. The statement's overview says the camera stores "unique values for left turn, right turn & straight drive", but the signal list makes CameraInput_RoadSign a Boolean. Two things break the catch, and neither is a fix: a status that can leave the three values (for example a branch that passes the raw angle, or a default of 1), or RoadSign values that differ from the angular limits. With RightTurn_RoadSign set to 25 while the limit stays 30, the 151 right-turn angles never light the indicator: on with the camera in 210 of 361 angles instead of 361.

Beyond the spec. If the camera sends an enumeration (0 none, 1 left, 2 right, 3 straight), the indicator can mean "the driver is steering the way the sign says": indicator = (sign ≠ none) AND (status equals that sign's value). The toggle in the first tab does this. The truth table changes from a copy of the camera to a real check:

AngleStatusBoolean camera 0 / 1Sign: noneleftrightstraight
45 deg300 / 10010
10 deg00 / 10001
-60 deg00 / 10001
-150 deg-1200 / 10100

That is a change to the requirement, not a reading of it, so label it as such if you build it.

Switch criterion: u2 >= Threshold or u2 > Threshold?

The Simulink Switch passes its first input when the control input meets the criterion, else its third input. The criteria are u2 > Threshold (the default in the current documentation), u2 >= Threshold and u2 ~= 0, and the default threshold is 0. A Compare To Constant block in front of the Switch gives the same test with any of ==, ~=, <, <=, >, >= (its default operator is <=).

  • >= vs >. u2 > 30 and u2 < −120 differ from the reference only at exactly 30 and −120 (2 angles), and the indicator not at all. Choose one and test the boundary.
  • The sign reading. > 0 right, = 0 straight, else left makes 1 to 29 deg a right turn and −1 to −119 a left turn: 148 of 361 status values differ from the reference. It treats the straight angle as a point, not a band, which the statement does not ask for, but it never uses Right_Turn_AngularLimit as a threshold.
  • u2 ~= 0 on the angle passes input 1 for every angle except 0, positive and negative. Used as the second switch after ≥ 30, it turns 1 to 29 deg into left turns.
  • Threshold left at 0 makes every positive angle a right turn, not only from 30 deg.

Because of the catch, none of these changes the indicator. They change Vehicle_Turn_Status, which a requirement-based test checks, so the boundary tests matter even though the output looks right.

Which test cases should you run?

Requirement-based tests sit on and around each limit. For the reference reading that is 11 angles (−180, −121, −120, −119, −1, 0, 1, 29, 30, 31, 180), each with the camera off and on: 22 cases at one per 0.01 s step. They take Switch 1 (θ ≥ 30) and Switch 2 (θ ≤ −120) both ways, give each AND gate all four input pairs, and drive the OR to 0 and 1. The Test vectors tab lists the expected outputs and which branch each case takes, and downloads them as CSV.

The preset drives add time behaviour. In the right turn to 60 deg, the angle reaches 30 deg at 1.00 s and Vehicle_Turn_Status steps from 0 to 30 there; the indicator is on for 200 samples, exactly the 2 s the sign is seen. The model has no memory, so a MIL and a SIL run of the same CSV should match sample for sample. For the minimum MC/DC set of the AND and OR gates, use the MC/DC coverage calculator.

Which storage class goes on each signal?

The statement fixes the storage classes if you generate code. MathWorks' Embedded Coder page on choosing a storage class describes what each does; the C lines are the shapes the reports' generated code shows.

SignalStorage classWhat the generated C looks like
SteeringWheel_YawDegreeInput, CameraInput_RoadSignImportedExtern"The generated algorithmic code uses the variable without defining it": a header declares extern int16_T SteeringWheel_YawDegreeInput; and your own code must define it.
Vehicle_Direction_IndicatorExportToFileA global definition and declaration in files you can name: boolean_T Vehicle_Direction_Indicator; under "Definition for custom storage class: ExportToFile".
Vehicle_Turn_StatusLocalizableKept at file or function scope where possible: int16_T Vehicle_Turn_Status; as a local variable inside the step function.
The six calibrationsConstStandalone globals with the const qualifier: const int16_T Right_Turn_AngularLimit = 30;

"0.01 s" means a fixed-step solver with that step, 100 samples a second. 253 reports name ert.tlc as the target, most in their generated code header; the statement itself does not.

What do 30 and −120 degrees mean on a car?

The input is the steering-wheel angle. The road wheels turn by that angle divided by the steering ratio, 12:1 to 20:1 for most passenger cars. At low speed, with no tyre slip, the kinematic bicycle model links the road-wheel angle δ, the wheelbase L, the turn radius R and the speed V:

With a 15:1 ratio and a 2.7 m wheelbase, 30 deg at the wheel is 2 deg at the road wheels and a 77.32 m radius: a gentle bend, taken at 50 km/h with a yaw rate of 10.29 deg/s and 2.49 m/s² sideways. −120 deg is 8 deg at the road wheels and a 19.21 m radius: a junction turn, at 20 km/h 16.57 deg/s. A highway lane change uses far less: at 100 km/h, 1 m/s² of lateral acceleration needs about 3 deg at the wheel in this model, while 30 deg would mean 9.98 m/s², outside what the low-speed model can describe.

Steering angle vs yaw rate. The statement names the input "yaw rate", but its unit is degrees and its range ±180, so it is the steering-wheel angle. Yaw rate is how fast the car's heading turns, in deg/s; it follows from the angle only once you know the speed and the radius, r = V/R.

Sign convention. In this project a right turn is +30 and a left turn −120. That is the project's own choice. Vehicle axis systems are defined in ISO 8855 and SAE J670: both define a Z-up frame, SAE J670 also a Z-down frame in which Y points to the right. Check which one your vehicle model uses before you reuse these signs.

What 615 vehicle direction reports did

As of 23 Nov 2026, Skill-Lync has 615 public reports on this project (n = 615). 101 are image-only or thin (under 800 characters of their own text after the pasted statement and page text are removed), so every count is a floor and comes only from what the text shows. 205 reports paste generated C code, which shows the Switch tests exactly.

What the text or code showsReports
Req 1 chains readable in the code170
… first test > 0 or ≥ 0 (threshold 0, not 30)76
… first test ≥ 3038
… equality only (= 30, = −120, = 0)29
… first test > 25 or > 3024
… never compare the angle with −120139
… second test u2 ~= 0 on the angle40
Req 2 readable in the code182
… AND per branch and one OR, as the statement40
… three outputs, no OR (a 3-element vector)110
… camera combined with OR instead of AND19
Model Advisor result stated with 0 failures36
All four storage classes as the statement (of 205 with code)52
A Simulink data dictionary (SLDD) described483
Explicit test angles listed (of these, any neighbour of a limit)24 (0)

What stands out. Only 45 of the 170 readable chains compare the angle with 30; 76 compare it with 0 and use 30 only as the value passed, and 139 never compare it with −120. So the reports disagree about the band between the limits: at 10 deg their code gives a right turn in 73, straight in 48 and left in 36; at −60 deg, left in 116 and straight in 37. In 14 chains the second Switch repeats the first test, so one branch can never fire. In Req 2, 110 of 182 end in three outputs instead of one Boolean, and 19 OR the camera in, which makes the output 1 whenever the camera is 1. No report says the band is undefined (0 of 615), and none says the indicator follows the camera (0). Of the 24 reports that list their test angles in text, 18 include a limit and 0 test a neighbour such as 29 or 31. Reports where the work reads clearly end to end: 1, 2, 3, 4.

What this checker does not cover

  • Your Simulink file. It models the blocks from the settings you enter; it does not open a .slx. Data type casts other than int16 and overflow handling are not modelled: values outside the int16 range are refused.
  • Switch chains that branch. Each Switch hands over through its third input, as in a chain; a Switch nested on input 1 is not offered.
  • Older Simulink releases. Block defaults are from the R2026b pages. Set the criterion you used.
  • Vehicle dynamics above low speed. The radius and yaw rate are kinematic; tyre slip and understeer are left out.
Learn model-based development for ADAS

Reading a requirement, building it in Simulink, testing the boundaries in MIL and SIL and generating Embedded Coder code is the daily work of ADAS software teams. This project is the first one in Skill-Lync's model-based development course.

Frequently asked questions

Why does my vehicle direction indicator just follow the camera input?

Because Req 1 always outputs one of the three RoadSign values, so one of the three equality checks is true at every angle. The indicator becomes camera AND true, which is the camera. The Boolean camera signal does not say which sign it saw. The page sweeps all 361 angles to show it.

Should the Switch use u2 >= Threshold or u2 > Threshold?

The statement does not say. With u2 >= 30, an angle of exactly 30 deg is a right turn; with u2 > 30, the Switch default criterion, it is straight. Only 30 and −120 change, and the indicator does not change at all. Pick one, write it down, and test 29, 30 and 31.

Which storage class should the calibrations use in this project?

The statement asks for Const on the six calibrations, ImportedExtern on the two inputs, ExportToFile on the output and Localizable on Vehicle_Turn_Status. Const makes Embedded Coder write each as a const global, for example const int16_T Right_Turn_AngularLimit = 30, so the value sits in read-only memory.

How do I pick test cases for the vehicle direction model?

Test each limit and its neighbours: 29, 30, 31, −121, −120, −119, −1, 0, 1, plus −180 and 180, each with the camera off and on. That is 22 cases. They take every Switch both ways and give each AND gate all four input pairs. The Test vectors tab lists them with a CSV.

Is the steering input a yaw rate or a steering angle?

The statement calls it "yaw rate" but gives it in degrees from −180 to 180, so it is the steering-wheel angle. Yaw rate is how fast the car's heading turns, in deg/s. At low speed, yaw rate is speed divided by turn radius, and the radius comes from the road-wheel angle.

Why is the sample time 0.01 s in this project?

The statement asks for 0.01 s on every signal, which is 100 samples a second, with a fixed-step solver so the generated step function runs at that rate. The model has no states or integrators, so the step size changes only how often it is evaluated, not the answer at any one sample.

Related on Skill-Lync

Sources

  • Skill-Lync MBD course, "Project 1 (Mini Project on Vehicle Direction Detection": the statement and signal list as pasted in the public reports, read 23 Nov 2026.
  • MathWorks, Embedded Coder documentation (R2026b, read 23 Nov 2026): Choose Storage Class for Controlling Data Representation in Generated Code (ImportedExtern, ExportToFile, Localizable, Const).
  • MathWorks, Simulink documentation (R2026b): Switch (criteria, default u2 > Threshold, threshold 0, Boolean control), Compare To Constant (operators, default <=, Boolean output), Saturation (default limits ±0.5).
  • MathWorks, Robotics System Toolbox, Mobile Robot Kinematics Equations (R2026b): bicycle kinematics, heading rate ω = (v/l) tan ψ. Vehicle Dynamics Blockset, Kinematic Steering (road-wheel angle = steering angle / steering ratio) and Coordinate Systems (ISO 8855, SAE J670 axes).
  • Wikipedia, Steering ratio (read 23 Nov 2026): "In most passenger cars, the ratio is between 12:1 and 20:1."
  • Skill-Lync, 615 public reports on this project: the counts above, from a script whose matches were checked by hand.
  • Skill-Lync, scripts/verify/vehicle_direction.py: the readings written out as plain functions, the switch chain evaluated from the last block back, the sweeps, test vectors, drives and kinematics rebuilt independently; the page compares 729 values with it when it is built.
Free counselling

From a Switch block to an ADAS software job.

ADAS and MBD teams hire people who can turn a requirement into a model, test its boundaries and generate the code. A Skill-Lync counsellor can tell you which program fits where you are now.

Talk to an MBD course counsellor

Free. We call you back, usually the same day.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.