Project 1 (Mini Project on Vehicle Direction Detection
Mini Project: Vehicle Direction Detection
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.
Aim:
- 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.
Procedure:
- Creating two subsystems as per the given instruction in the requirement document.
- Attaching the required documents.
- Creating a Simulink Data Dictionary (SLDD).
- Generating a model advisor report (with necessary tested selected)
- Generation of code.
SIMULINK MODEL:
Vehicle_Direction_Detection Subsystems:
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).
Vehicle_Turn_Status_Subsystem:
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).
Vehicle_Direction_Indication_
Attaching Required Documents:
- In word documents we have already requirement in the form of word.
- So we need to first, highlight our requirement.
- Then in simulink after clikling on the model, go to the requirement and then link to selection in word.
- Then again go to the requirements where we can see our highlighted text.
- Click on it, so finally requirement tagging is done.
- Same in this case as well.
- Instead of choosing requirement 1 in word we have to choose requirement 2.
- Then follow the same procedure as before.
Simulink Data Dictionary:
- A SLDD file is created which contains input, output signals and caliberation parameters used in the model.
- For creating SLDD file, first click on modelling and link to data dictionary.
- Then click on NEW and browse the location where we need to add the file.
- We need to remove the access to base workspace.
- Then we can add data,parameters,Signals,etc..

Model Advisor:
- This check is performed by using "model advisor" tools to see whether the developed model meets the modelling standards for MAB.
- To check this open the simulink model, click on model setting and then go to the model advisor. Where we have different option which subsystem or main subsystem which we want to check.

Generated Code:
/*
2 * File: Vehicle_Direction_Detection.c
3 *
4 * Code generated for Simulink model 'Vehicle_Direction_Detection'.
5 *
6 * Model version : 1.2
7 * Simulink Coder version : 9.3 (R2020a) 18-Nov-2019
8 * C/C++ source code generated on : Sat May 14 22:18:00 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 "Vehicle_Direction_Detection. h"
17 #include "Vehicle_Direction_Detection_ private.h"
18
19 /* Exported data definition */
20
21 /* Definition for custom storage class: ExportToFile */
22 boolean_T Vehicle_Direction_Indicator[3] ;/* '/Signal Conversion' */
23
24 /* Const memory section */
25 /* Definition for custom storage class: Const */
26 const int16_T LeftTurn_RoadSign = -120;/* Referenced by: '/Constant1' */
27 const int16_T Left_Turn_AngularLimit = -120;/* Referenced by: '/Constant1' */
28 const int16_T RightTurn_RoadSign = 30; /* Referenced by: '/Constant' */
29 const int16_T Right_Turn_AngularLimit = 30;/* Referenced by: '/Constant2' */
30 const int16_T Straight_Drive_Steering_Angle = 0;/* Referenced by: '/Constant' */
31 const int16_T Straight_RoadSign = 0; /* Referenced by: '/Constant2' */
32
33 /* External inputs (root inport signals with default storage) */
34 ExtU_Vehicle_Direction_Detect_ T Vehicle_Direction_Detection_U;
35
36 /* Real-time model */
37 RT_MODEL_Vehicle_Direction_De_ T Vehicle_Direction_Detection_M_ ;
38 RT_MODEL_Vehicle_Direction_De_ T *const Vehicle_Direction_Detection_M =
39 &Vehicle_Direction_Detection_ M_;
40
41 /* Model step function */
42 void Vehicle_Direction_Detection_ step(void)
43 {
44 /* local block i/o variables */
45 int16_T Vehicle_Turn_Status;
46
47 /* Switch: '/Switch1' incorporates:
48 * Constant: '/Constant1'
49 * Constant: '/Constant2'
50 * Constant: '/Constant'
51 * Constant: '/Constant'
52 * Inport: '/SteeringWheel_ YawDegreeInput'
53 * RelationalOperator: '/Compare'
54 * RelationalOperator: '/Compare'
55 * Switch: '/Switch'
56 */
57 if (Vehicle_Direction_Detection_ U.SteeringWheel_YawDegreeInput > 0.0) {
58 Vehicle_Turn_Status = Right_Turn_AngularLimit;
59 } else if (Vehicle_Direction_Detection_ U.SteeringWheel_YawDegreeInput == 0.0)
60 {
61 /* Switch: '/Switch' incorporates:
62 * Constant: '/Constant'
63 */
64 Vehicle_Turn_Status = Straight_Drive_Steering_Angle;
65 } else {
66 Vehicle_Turn_Status = Left_Turn_AngularLimit;
67 }
68
69 /* End of Switch: '/Switch1' */
70
71 /* SignalConversion: '/Signal Conversion' incorporates:
72 * Constant: '/Constant'
73 * Constant: '/Constant1'
74 * Constant: '/Constant2'
75 * Inport: '/CameraInput_RoadSign'
76 * Logic: '/Logical Operator'
77 * Logic: '/Logical Operator1'
78 * Logic: '/Logical Operator2'
79 * RelationalOperator: '/Relational Operator'
80 * RelationalOperator: '/Relational Operator1'
81 * RelationalOperator: '/Relational Operator2'
82 */
83 Vehicle_Direction_Indicator[0] = ((Vehicle_Turn_Status == RightTurn_RoadSign) &&
84 Vehicle_Direction_Detection_U. CameraInput_RoadSign);
85 Vehicle_Direction_Indicator[1] = ((Vehicle_Turn_Status == LeftTurn_RoadSign) &&
86 Vehicle_Direction_Detection_U. CameraInput_RoadSign);
87 Vehicle_Direction_Indicator[2] = ((Vehicle_Turn_Status == Straight_RoadSign) &&
88 Vehicle_Direction_Detection_U. CameraInput_RoadSign);
89 }
90
91 /* Model initialize function */
92 void Vehicle_Direction_Detection_ initialize(void)
93 {
94 /* (no initialization code required) */
95 }
96
97 /* Model terminate function */
98 void Vehicle_Direction_Detection_ terminate(void)
99 {
100 /* (no terminate code required) */
101 }
102
103 /*
104 * File trailer for generated code.
105 *
106 * [EOF]
107 */
108
CONCLUSION AND RESULT:
- Model is created as per the requirements given.
- The subsystems are attached with the required documents.
- SLDD file is created as per the given requirement.
- Model advisor report is generated.
- Code is generated.