Project 1 (Mini Project on Vehicle Direction Detection
Mini Project - Vehicle Direction Determination
Overview of the project:-
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:-
- 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).
SIMULINK MODEL FOR REQUIREMENT 1:-

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).
SIMULINK MODEL FOR REQUIREMENT 2:-

Hence for both the requirements, a simulink model along with SLDD is created and code generation is done as a part of this project:-
FINAL SIMULINK MODEL:-

SLDD:-

REQUIREMENT TAGGING:-
The given requirements are then tagged in the specific model which will be useful for the developer as well as for the entire team, who is working in the project. It will also be very helpfull in the future usage if we have a very tedious models. It can be done by Right Click ---> Requirements ---> Link to selection in Word. For doing this the requirements which should be tagged should be selected in prior, and the word file should be in active (ie., open).

This can bee seen through Apps ---> Requirements Manager command. And hence by clicking the requirements, we will be directed to the tagged component easily. And by this way, the requirement tagging is done to the given model.
MODEL ADVISORY CHECK:-
The next step is to do the model advisory check. To start the Model check, first update the diagram by using ctrl+D . Then go to Apps ---> Model advisor

Then the Model advisor diaglog box will appear and then choose the entire model name for model check.
And then in the dialog box select the tasks which you want to go for the check. Since it is a mini project, I have chosen only MAAB guidelines for the advisory check. But depending upon our project we can go for our required checks and after selecting the guideline click on ' Run the selected checks '. And hence the checks will be done and our results will be displayed as follows:-

And then, when you give ' Generate report ' command, the model advisory report will get generated for us.

Note:- The warnings are mostly for the file names , which we have stored in that particular folder so it is neglected in this report.
CODE GENERATION:-
The final step for the Model based development, is the Code generation. This is done by giving the command, Apps ---> Embbedded coder ---> Build ---> Generate code and build model. And hence the C code is generated and stored for the model sucessfully.
C-Code:-
File: miniproject1_final.c
1 /*
2 * File: miniproject1_final.c
3 *
4 * Code generated for Simulink model 'miniproject1_final'.
5 *
6 * Model version : 1.5
7 * Simulink Coder version : 9.2 (R2019b) 18-Jul-2019
8 * C/C++ source code generated on : Mon Oct 10 11:05:46 2022
9 *
10 * Target selection: ert.tlc
11 * Embedded hardware selection: Intel->x86-64 (Windows64)
12 * Code generation objectives: Unspecified
13 * Validation result: Not run
14 */
15
16 #include "miniproject1_final.h"
17 #include "miniproject1_final_private.h"
18
19 /* Exported data definition */
20
21 /* Definition for custom storage class: ExportToFile */
22 boolean_T Vehicle_Direction_Indicator; /* '<S2>/OR3' */
23
24 /* Const memory section */
25 /* Definition for custom storage class: Const */
26 const int16_T LeftTurn_RoadSign = -120;/* Referenced by: '<S4>/Constant' */
27 const int16_T Left_Turn_AngularLimit = -120;/* Referenced by: '<S1>/Constant1' */
28 const int16_T RightTurn_RoadSign = 30; /* Referenced by: '<S3>/Constant' */
29 const int16_T Right_Turn_AngularLimit = 30;/* Referenced by: '<S1>/Constant' */
30 const int16_T Straight_Drive_Steering_Angle = 0;/* Referenced by: '<S1>/Constant2' */
31 const int16_T Straight_RoadSign = 0; /* Referenced by: '<S5>/Constant' */
32
33 /* Real-time model */
34 RT_MODEL_miniproject1_final_T miniproject1_final_M_;
35 RT_MODEL_miniproject1_final_T *const miniproject1_final_M =
36 &miniproject1_final_M_;
37
38 /* Model step function */
39 void miniproject1_final_step(void)
40 {
41 /* local block i/o variables */
42 int16_T Vehicle_Turn_Status;
43
44 /* Switch: '<S1>/Switch' incorporates:
45 * Constant: '<S1>/Constant'
46 * Constant: '<S1>/Constant1'
47 * Inport: '<Root>/SteeringWheel_YawDegreeInput'
48 * Switch: '<S1>/Switch1'
49 */
50 if (SteeringWheel_YawDegreeInput >= 30) {
51 Vehicle_Turn_Status = Right_Turn_AngularLimit;
52 } else if (SteeringWheel_YawDegreeInput >= 0) {
53 /* Switch: '<S1>/Switch1' incorporates:
54 * Constant: '<S1>/Constant2'
55 */
56 Vehicle_Turn_Status = Straight_Drive_Steering_Angle;
57 } else {
58 Vehicle_Turn_Status = Left_Turn_AngularLimit;
59 }
60
61 /* End of Switch: '<S1>/Switch' */
62
63 /* Logic: '<S2>/OR3' incorporates:
64 * Constant: '<S3>/Constant'
65 * Constant: '<S4>/Constant'
66 * Constant: '<S5>/Constant'
67 * Inport: '<Root>/CameraInput_RoadSign'
68 * Logic: '<S2>/OR'
69 * Logic: '<S2>/OR1'
70 * Logic: '<S2>/OR2'
71 * RelationalOperator: '<S3>/Compare'
72 * RelationalOperator: '<S4>/Compare'
73 * RelationalOperator: '<S5>/Compare'
74 */
75 Vehicle_Direction_Indicator = (((Vehicle_Turn_Status == RightTurn_RoadSign) &&
76 CameraInput_RoadSign) || ((Vehicle_Turn_Status == LeftTurn_RoadSign) &&
77 CameraInput_RoadSign) || ((Vehicle_Turn_Status == Straight_RoadSign) &&
78 CameraInput_RoadSign));
79 }
80
81 /* Model initialize function */
82 void miniproject1_final_initialize(void)
83 {
84 /* (no initialization code required) */
85 }
86
87 /* Model terminate function */
88 void miniproject1_final_terminate(void)
89 {
90 /* (no terminate code required) */
91 }
92
93 /*
94 * File trailer for generated code.
95 *
96 * [EOF]
97 */
98