Challenge

Project 1 (Mini Project on Vehicle Direction Detection

Aim:

To identify the vehicle's direction in Autonomous driving & Advanced Driver Assistance Features and develop the MATLAB Simulink model as per requirement.

Objective:

  • The objective of the project is to create a Simulink model for vehicle direction detection as per the requirement.
  • Tag the requirements to the Simulink model; Requirement 1 & Requirement 2 are tagged to their corresponding subsystem.
  • MBD compliant changes, Data Dictionary creation & code generation is added advantage, and that is not the scope of this project.

Task:

The inputs to the system are the steering wheel angular input given as yaw rate(Signal name: SteeringWheel_YawDegreeInput) and an input signal from the camera (Signal Name: CameraInput_RoadSign), which confirms the occurrence of a road sign.

A camera reads the road signs & stores them in its memory unique value for the left turn, right turn & straight drive. Depending on the direction the vehicle takes, a final indication is given to the driver- if he is driving in the recommended direction or not.

The output of the system is a boolean value (Signal Name: Vehicle_Direction_Indicator) which specifies whether the vehicle is turning right, left, or going straight.

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

The main subsystem 'Vehicle_Direction' is further divided into two more subsystems which are 'Requirement1' and 'Requirement2' as shown below:

Fig 2: 'Requirement 1' 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 a 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 'Steering Wheel 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 'Steering Wheel_YawDegreeInput' matches the calibration 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'.
Fig 3: Requirement 1 Subsystem
Requirement-2:
  • In the 'Requirement2' subsystem, the local signal Vehicle Turn Status' fed from the 'Requirement1' subsystem is taken as input and is compared against calibration values (Right Turn RoadSign, LeftTurn_RoadSign, Straight_RoadSign) using the relational operator'=='
  • The boolean value obtained at the output of the relational operator is compared against a boolean input signal from the camera (Signal Name: CameraInput_RoadSign), which confirms the occurrence of a road sign using 'AND' operator.
  • The boolean output signal obtained from each of the three 'AND' blocks is 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', the second element to indicate 'Left Turn', and the third element to indicate 'Straight Drive'.
Fig 4: Requirement2 Subsystem
Requirement Tagging of Simulink Model:
  • The requirements 'Requirement-l' 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 are to first highlight the requirement stated 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'.

Fig 5: Highlighting the requirement to be tagged in requirement Word document
Fig 6: Tagging 'Requirement1' Subsystem to its requirement in Word document
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.
Fig 7: Simulink Data Dictionary Dialog Box
Signals & Calibration Data List:
Fig 9: Simulink Data Dictionary Input, Output, and Calibration Parameters in Model Explorer
MAB Guidelines Check-in Model Advisor:
A check is performed using the 'Model Advisor' tool in Simulink to see whether the developed model meets the modeling standards for MAB.
Fig 10: MAB Guidelines Check-in Model Advisor
After running the selected checks of the model advisor, we generate the report. The generated report is shown below:
As per the requirement, we have created the data dictionary and now we are going to generate the code for the Simulink model.
To generate the code, select Apps-->Embedded coder
After selecting the embedded coder, the C Code window will be open. In C Code--> select the build option
Then code will be generated and it is shown below
The code is generated successfully in the model. In addition, we have also created a test harness for MIL tests and SIL tests.
MIL Tests:
In the above model, we have created the model and generated the code as per the given requirement. In addition we also have created a test harness of MIL test which is shown below:
By selecting the model, Goto Test Harness-->Create for 'Vehicle_Direction'
Create Test Harness dialog box will be opened, In the dialog box we are selecting the sources as Signal Builder in the Basic properties and Verification Mode as Normal in the Advanced Properties.
Then the below-shown model will be opened for the test harness
In the Signal builder block, we are importing the file as input to test the harness and The file for the input has been created through the excel sheet.
In the above-shown model, we have attached the demux block to split vector signals into scalars or smaller vectors. Check 'Bus Selection Mode' to split bus signals. The demux block is connected with the sum block to differentiate the values and show the error through the scope. On other hand, Demux is connected directly with the scope to display the vehicle direction indicator output.
From the above scope results, the MIL test has been completed successfully.
SIL Test:
In the SIL test, we also made the same process as same as MIL test but here we made small changes in the SIL test process as shown below:
In the SIL test, create a test harness by implementing Software-in-the-Loop(SIL) in the verification mode of Advanced properties.
In the block parameter, we have to select the 'Treat as atomic unit' to implement The SIL Test, or else the test will not be operated. Here we also set a sample time as 0.01
After running the test harness, the output of the test has been displayed through the Scope block for the SIL Test.
Conclusion:
  • The MATLAB Simulink model has been developed as per requirement.
  • Tagging of requirement 1 & requirement 2 has been done to their corresponding subsystems.
  • Data Dictionary has been created & the code has also been generated.
  • In addition, we also created a MIL test and SIL test.
Your portfolio, next

Ship work like this
in your own course.

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.

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.