Project 1 (Mini Project on Vehicle Direction Detection
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
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).
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 |
- |
- |
Steps for making this project :
1] DEVELOPMENT OF THE SIMULINK MODEL:
The main subsystem 'Vehicle_Direction' along with inputs 'SteeringWheel_YawDegreeInput' , 'CameraInput_RoadSign' and output signal ' Vehicle_Direction_Indicator' is shown below:

Fig 1: 'Vehicle_Direction' subsystem
2] The main subsystem 'Vehicle_Direction' is further divided into two more subsytems which are 'Requirement1' and 'Requirement2' as shown below:

Figure 2: 'Requirement1' and 'Requirement2' subsystems
Requirement-1:
- In the 'Requirement1' subsystem, the steering wheel yaw degree (Signal name: SteeringWheel_YawDegreeInput) is fed as input to the subsystem and this value 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.
- The input signal 'SteeringWheel_YawDegreeInput' is compared against three angular values using the relational operator '==', 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. In this case, the output of the relational operator '==' is equal to 1 only when the 'SteeringWheel_YawDegreeInput' matches the calibraton value angular limit specified in Right_Turn_AngularLimit, Left_Turn_AngularLimit, or Straight_Drive_Steering_Angle.
- Three switch blocks are used to implement an if-else logic. The output from each relational operator is given as a condition input (input2) to each Switch block. The switch will pass input1 (calibration value) when the condition (input2~=0) condition is satisfied, else input3 (output from the next switch block) is passed as output.
- The signal 'Vehicle_Turn_Status' obtained at the output of the first switch will be a calibration angular value (Right_Turn_AngularLimit OR Left_Turn_AngularLimit, OR Straight_Drive_Steering_Angle). If none of the conditions get satisfied, zero is passed as the output from the last switch. The signal 'Vehicle_Turn_Status' is fed to the outport of subsystem 'Requirement1'.

Figure 3: 'Requirement-1' subsystem
Requirement-2:
- In 'Requirement2' subsystem, the local signal 'Vehicle_Turn_Status' fed from 'Requirement1' subsystem is taken as input and is compared against calibration values (RightTurn_RoadSign, LeftTurn_RoadSign, Straight_RoadSign) using the relational operator '=='.
- The boolean value obatined at the output of the realtional operator is compared against a boolean input signal from camera (Signal Name: CameraInput_RoadSign), which confirms the occurrence of a road sign using 'AND' operotor.
- The boolean output signal obtained from each of the three 'AND' blocks are fed to the outport 'Vehicle_Direction_Indicator' to indicate the vehicle direction. The output 'Vehicle_Direction_Indicator' will be a three dimension signal having three boolean elements, with the first element to indicate 'Right Turn', second element to indicate 'Left Turn' and third element to indicate 'Straight Drive'.

Figure 4: 'Requirement2' subsystem
3] Requirement Tagging of Simulink Model:
The requirements ‘Requirement-1’ and ‘Requirement-2’ as provided in the Requirements Word document are tagged to their corresponding subsystem in the Simulink Model.
The steps involved in tagging a requirement in the Simulink model is to first highlight the requirement statement in the Word document, then right click on the subsystem in the model that has to be tagged, then select ‘Requirements’ and then ‘Link to Selection in Word’


Figure 5: Highlighting the requirement to be tagged in requirement Word document.

Figure 6: Tagging ‘Requirement1’ Subsystem to its requirement in Word document
4] Creation of Simulink Data Dictionary file (SLDD):
A Simulink Data Dictionary (SLDD) file is created that contains input, output signals and calibration parameters used in the model. SLDD file is created by clicking on Modeling, then ‘Model Properties’, then ‘External Data’ and specifying a file name for the Data Dictionary.

Figure 7: Simulink Data Dictionary Dialog Box
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 |
3 |
0 |
1 |
- |
- |

Figure 9: Simulink Data Dictionary Input, Output and Calibration Parameters in Model Explorer
5] MAAB Guidelines Check in Model Advisor:
A check is performed using ‘Model Advisor’ tool in Simulink to see whether the developed model meets the modeling standards for MAAB.

Figure 10: MAAB Guidelines Check in Model Advisor
6] Creation of Model In Loop Test Harness:
A harness for Model In Loop test is created by right clicking on the main ‘Vehicle_Direction’ subsystem, then selecting ‘Test Harness’ and then ‘Create for Vehicle_Direction’.

Figure 11: Creation of MIL Test Harness from Main Subsystem ‘Vehicle_Direction’
The input signal of the MIL test harness is a signal builder block and the output signal ‘Vehicle_Direction_Indicator’ is given to a workspace.

Figure 12: Create Test Harness Dialog Box

Figure 13: Model In Loop Test Harness
6] The test signals are 'SteeringWheel_YawDegreeInput' and ‘CameraInput_RoadSign’ whose values at different time are specified in an excel sheet and then imported into the signal builder block. Excel attachment screen shoot are given below figure:



Figure 14: Signal Builder block test signals for 'SteeringWheel_YawDegreeInput' and ‘CameraInput_RoadSign’
7] Creation of Software In Loop Test Harness:
In order to create a Software In Loop block from the main ‘Vehicle_Direction’ subsystem, the steps followed is to right click on the subsystem, then select C/C++ code, then ‘Generate S-Function’.

Figure 15: Creation of S-Function block from ‘Vehicle_Direction’ subsystem’
In the ‘Generate S-Function for Subsystem’ dialog box, ‘Create Software-In-the =-Loop (SIL) block’ is checked and build is clicked to create a SIL block for ‘Vehicle_Direction’. The SIL test can be done by replacing the subsystem ‘Vehicle_Direction’ in the MIL test with the SIL block.

Fig 16: Generate S-Function for Subsystem Dialog Box

Fig 17: SIL test harness for Vehicle_Direction

8] Results:
Test is performed for the developed model using Model in Loop and then Simulation in Loop test. The test is carried out for three seconds duration with step time for all signals set as 0.01s.
The input signal ‘CameraInput_RoadSign’ value is set as ‘1’ between 0 and 3 seconds to confirm the occurrence of a road sign.
The input signal ‘SteeringWheel_YawDegreeInput’ is value is set as:
- ‘30’ between 0 to 1 seconds which matches with the value of the calibration parameter ‘Right_Turn_AngularLimit’ in ‘Requirement1’ subsystem and parameter ‘RightTurn_RoadSign’ in ‘Requirement2’ subsystem. The output signal ‘Vehicle_Direction_Indicator’ whose dimension is ‘3’ will have a boolean value [1 0 0] to indicate Right Turn between 0 and 1 second.
- ‘-120’ between 1 to 2 seconds which matches with the value of the calibration parameter ‘Left_Turn_AngularLimit’ in ‘Requirement1’ subsystem and parameter ‘LeftTurn_RoadSign’ in ‘Requirement2’ subsystem. The output signal ‘Vehicle_Direction_Indicator’ whose dimension is ‘3’ will have a boolean value [0 1 0] to indicate Left Turn between 1 and 2 second.
- ‘0’ between 2 to 3 seconds which matches with the value of the calibration parameter ‘Straight_Drive_Steering_Angle’ in ‘Requirement1’ subsystem and parameter ‘Straight_RoadSign’ in ‘Requirement2’ subsystem. The output signal ‘Vehicle_Direction_Indicator’ whose dimension is ‘3’ will have a boolean value [0 0 1] to indicate Straight Drive between 2 and 3 second.
The simulation is run for three seconds first using the MIL test harness and then SIL test harness and the results for output signal ‘Vehicle_Direction_Indicator’ is copied from the workspace into an excel sheet ‘Test_Report_Data’ to check whether the results match the expected output.

Fig 18: Output signal ‘Vehicle_Direction_Indicator’ values taken from workspace after simulation run.
End