Project 1 (Mini Project on Vehicle Direction Detection
EV B20 MBD B1
Mini Project - Vehicle Direction Determination
General Overview:
Identifying the direction of the vehicle is one of the important & diverse features in Autonomous driving & Advanced Driver Assistance Features. This particular sub-feature of identifying the direction of vehicle is basically identifying the direction the vehicle is taking based on the camera input.
Camera reads the road signs & stores into its memory with unique values for left turn, right turn & straight drive. Depending on the direction it is taking, final indication is given to the driver – as an indication if he is driving in the recommended direction or not.
Vehicle Direction Determination can also be coupled along - side features like GPS systems to identify whether the vehicle is reaching its destination in an optimized manner. This sub feature can also be used along with Lane Detection, Highway Warning, Ramp Entry / Exit in Wrong Way Detection etc.
Objective of Mini Project:
- Development of MATLAB Simulink model as per requirement.
- Tag the requirements to the simulink model; tagging requirement 1 & requirement 2 to their corresponding subsystems is fine.
- MBD compliant changes, Data Dictionary creation & code generation is added advantage, and that is not scope of this project.
- If choosing code generation, Storage class for Input signals: ImportedExtern; Storage class for Output signal: Export to File; Storage class for local signals: localizable; Storage class for calibration signals: Const.
- Choose sample time for all signals as 0.01s
Signals & Calibration Data List:
|
Signal / Calibration Name |
Signal Type |
Data Type |
Dimension |
Min |
Max |
Initial Value |
Units |
|
SteeringWheel_YawDegreeInput |
Input |
Int16 |
1 |
-180 |
180 |
- |
Deg |
|
CameraInput_RoadSign |
Input |
Boolean |
1 |
0 |
1 |
- |
- |
|
Vehicle_Turn_Status |
Local |
Int16 |
1 |
-180 |
180 |
- |
Deg |
|
Right_Turn_AngularLimit |
Calibration |
Int16 |
[1 1] |
-180 |
180 |
30 |
Deg |
|
Left_Turn_AngularLimit |
Calibration |
Int16 |
[1 1] |
-180 |
180 |
-120 |
Deg |
|
Straight_Drive_Steering_Angle |
Calibration |
Int16 |
[1 1] |
-180 |
180 |
0 |
Deg |
|
RightTurn_RoadSign |
Calibration |
Int16 |
[1 1] |
-180 |
180 |
30 |
|
|
LeftTurn_RoadSign |
Calibration |
Int16 |
[1 1] |
-180 |
180 |
-120 |
|
|
Straight_RoadSign |
Calibration |
Int16 |
[1 1] |
-180 |
180 |
0 |
|
|
Vehicle_Direction_Indicator |
Output |
Boolean |
1 |
0 |
1 |
- |
- |
To Create .SLDD File Go to Modeling and click Link To Data Dictionary and External and Click on NEW and create a Miniproject_sldd file.And in Model Explorer under Model Hierarchy External Data ,Miniproject_Sldd ,Design Data Add all the Given Signal and Calibration data as per the requirement.

DEVELOPMENT OF SIMULINK MODEL:
The Main subsystem vehicle Direction consists of the two input signal SteeringWheel_YawDegreeInput and CameraInput_RoadSign and output signal Vehicle_Direction_Indicator is as shown in below fig.

The Main Subsystem is Divided into Two Subsystem as per the given requirement and we can be see in below fig.

Requirement - 1:
- Steering wheel input as yaw rate (Signal name: SteeringWheel_YawDegreeInput) is the input for this system.
- This is compared against 3 angular values, one each for left turn, right turn & straight drive (Calibration Values: Right_Turn_AngularLimit, Left_Turn_AngularLimit, Straight_Drive_Steering_Angle) to say which specific direction the steering wheel is turning towards.
- Use switch blocks to compare & develop this requirement. Keep this requirement in a subsystem & output of this requirement is a local signal (Signal Name: Vehicle_Turn_Status).

Requirement – 2:
- Keep this requirement as a separate subsystem. Inputs to this requirement are local signal from requirement 1 (Signal Name: Vehicle_Turn_Status) & an input signal from camera (Signal Name: CameraInput_RoadSign), which confirms the occurrence of a road sign.
- Signal Vehicle_Turn_Status is compared against calibration values (Calibration Values: RightTurn_RoadSign, LeftTurn_RoadSign, Straight_RoadSign), if each of them is found equal, then each of the three corresponding output is compared against the camera input signal,
- Using a logical operator block, only one among them is finally given as output signal (Signal Name: Vehicle_Direction_Indicator).

Signal Resolving:
The signal resolving is done to Take the properties of the signal from SLDD file


From the above figure we can see that the Signal is resolved For Both Inputs indicating in the blue mark
Signal Propogating:
Continuing the same signal in the Subsystem

Working Of The Model:
In Requirement-1:
- Steering wheel input as yaw rate (Signal name: SteeringWheel_YawDegreeInput) is the input for this system.
- This is compared against 3 angular values, one each for left turn, right turn & straight drive (Calibration Values: Right_Turn_AngularLimit, Left_Turn_AngularLimit, Straight_Drive_Steering_Angle) to say which specific direction the steering wheel is turning towards.
Condition
1:SteeringWheel_YawDegreeInput > 0, Right_Turn_AngularLimit
2.SteeringWheel_YawDegreeInput = 0,Straight_Drive_Steering_Angle
3.SteeringWheel_YawDegreeInput < 0,Left_Turn_AngularLimit
- The switch blocks are used to compare & develop this requirement. Keep this requirement in a subsystem & output of this requirement is a local signal (Signal Name: Vehicle_Turn_Status).
Requirement – 2:
- Keep this requirement as a separate subsystem. Inputs to this requirement are local signal from requirement 1 (Signal Name: Vehicle_Turn_Status) & an input signal from camera (Signal Name: CameraInput_RoadSign), which confirms the occurrence of a road sign.
- Signal Vehicle_Turn_Status is compared against calibration values (Calibration Values: RightTurn_RoadSign, LeftTurn_RoadSign, Straight_RoadSign), if each of them is found equal, then each of the three corresponding output is compared against the camera input signal,
Condition:
1.Vehicle_Turn_Status==RightTurn_RoadSign,Output for the Vehicle indication is 1 and CameraInput_Roadsign Input =1 given to AND gate ,If the Both input is same the Vehicle Detection indicator shows RightTurn_RoadSign .
2. .Vehicle_Turn_Status==LeftTurn_RoadSign,Output for the Vehicle indication is 1 and CameraInput_Roadsign Input =1 given to AND gate ,If the Both input is same the Vehicle Detection indicator shows LeftTurn_RoadSign.
3.Vehicle_Turn_Status==Straight_RoadSign,Output for the Vehicle indication is 1 and CameraInput_Roadsign Input =1 given to AND gate ,If the Both input is same the Vehicle Detection indicator shows Straight_RoadSign.
- By Using a logical operator block, only one among them is finally given as output signal (Signal Name: Vehicle_Direction_Indicator).
Requirement Tagging
To do the requirement Tagging select the Heading of the particular word file in MS word and go to Subsystem, where we need to tag the requirement and right click requirement1 subsystem and Click on Requirements and click on Link to selection in Word.

The requirement Tagging is done to Read the given Description and Requirement From the Word File .
Model Advisory Check
To check The MAAB Guidelines
Model Setting need to be done As shown in below


Select Modeling Standard For MAB

To Resolve the Warning,

After changing the current value to recommended value we get the Warning Reduced and Minimize the Warning.

As we keep on retifying the warning will reduce to MinimumNo of Warning From 10 to 5 warnings

Generating a Report:It will be Saved in Current Working Directory

Totally 4 Test Cases are Generated as Shown Below

TEST Harness Creation:
MIL TEST:



Importing the Data of test cases from excel File to Signal builder

The MUX is Used to Combine the 3 input in the requirement 2 subsystem to get the output we need to connect DMUX

MIL TEST HARNESS MODEL:
The Input is Given as
For 0 to 1 Sec The Input Value is 30 which is > 0and Positive value The Expected Output is 1 i.e Right Turn
For 1 to 2 Sec The Input Value is -120 which is < 0and Negative value The Expected Output is 1 i.e Left Turn
For 2 to 3 Sec The Input Value is 0 which is = 0and The Expected Output is 1 i.e Straight
For 3 to 4 sec The input value is 50 which is >0 or any value but the CameraInput_RoadSign is 0 we Can see the is 0.
OUTPUT:

The Differance is taken Using the Subtract Block between the Expected Output and Actual Output we are getting Zero Hence MIL Test Verified.

2.SIL TEST

We have to import the Data of Test Cases from Excel to signal builder

We have connected the Mux inModel to combine the 3 input in the requirement 2 subsystem to take output we need to use DMUX
SIL HARNESS TEST MODEL

OUTPUT:

The Difference between the Expected output and the Actual output is compared the difference we get is Zero. Hence the SIL TEST Verified

Tested for both the MIL and SIL Test we can see the rigth Bottom Corner in Internal Test Harness

CONVERTING THE MODEL TO C CODE
Go to APPS option-->Embedded Coder->Build Option-->View Code

Also the Data containing code is stored in the file where the model is located as _ert_rtw file.

CONCLUSION:
- Development of MATLAB Simulink model as per requirement is created and Simulated.
- The Vehicle Direction is Detected Based on the input SteeringWheel_YawDegreeInput and CameraInput_Roadsign to Indicate the RightTurn,LeftTurn and Straight .
- The requirements to the simulink model; tagging requirement 1 & requirement 2 to their corresponding subsystems is Created
- MBD compliant changes, Data Dictionary creation & code generation is Generated as per given Requirement.
- Verfication and Validation of Model is Done.
- Model In Loop and Software in Loop Testing Is Verified and Test Harness is Created.
- SIL Testing is Testing the Generated C Code.The Model is Converted to SIL_Repalce Matlab Model block with S function Builder Block.