Project 1 (Mini Project on Vehicle Direction Detection
Aim: To develop a MATLAB Simulink Model for Vehicle Direction Detection as per requirement and generate a code for it.
Objective:
1) To Develop the Simulink Model as per the requirements,tagging requirement 1 & requirement 2 to their corresponding subsystems is fine.
2) To Create an a Simulink Data Dictionary.
3) Configuaration parameters.
4) Code generation.
List of signal/calibration data
|
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 |
- |
- |
SIMULATION
top level design

1) the steering wheel yaw degree alongwith camera's input is given to the system, these are the main input to the whole system
2) when diving in to the system , it will look like

According to the given requirement
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).
The first system is designed

So the right,left and straight drive are continously compared with a predefined value of steering wheel yaw input and the corresponding value is taken as output
now according to requirement 2
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).

Here the output - vehicle turn status fronm previous block is fed as one of the input alongwith camera input.
The main aim of this block is to compare the output from previous block with predefined value as mention in sldd file and the condition from all three -right,left and straight is passed though and operation and finally through or operation to get the final output of direction indicator.
The requirement document is being created for tagging the requirement

The model is also run with model advisor

The data as per the requirement is enlisted in sldd

Code generation

/*
* File: Vehicle_direction_detection.c
*
* Code generated for Simulink model 'Vehicle_direction_detection'.
*
* Model version : 1.4
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Wed Nov 3 11:24:48 2021
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "Vehicle_direction_detection.h"
#include "Vehicle_direction_detection_private.h"
/* Exported data definition */
/* Const memory section */
/* Definition for custom storage class: Const */
const int16_T LeftTurn_RoadSign = -120;/* Referenced by: '<S5>/Constant' */
const int16_T Left_Turn_AngularLimit = -120;/* Referenced by: '<S2>/Constant1' */
const int16_T RightTurn_RoadSign = 30; /* Referenced by: '<S4>/Constant' */
const int16_T Right_Turn_AngularLimit = 30;/* Referenced by: '<S2>/Constant' */
const int16_T Straight_Drive_Steering_Angle = 0;/* Referenced by: '<S2>/Constant2' */
const int16_T Straight_RoadSign = 0; /* Referenced by: '<S6>/Constant' */
/* External inputs (root inport signals with default storage) */
ExtU_Vehicle_direction_detect_T Vehicle_direction_detection_U;
/* External outputs (root outports fed by signals with default storage) */
ExtY_Vehicle_direction_detect_T Vehicle_direction_detection_Y;
/* Real-time model */
static RT_MODEL_Vehicle_direction_de_T Vehicle_direction_detection_M_;
RT_MODEL_Vehicle_direction_de_T *const Vehicle_direction_detection_M =
&Vehicle_direction_detection_M_;
/* Model step function */
void Vehicle_direction_detection_step(void)
{
int16_T rtb_Switch;
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant'
* Constant: '<S2>/Constant2'
* Inport: '<Root>/SteeringWheel_YawDegreeInput'
* Switch: '<S2>/Switch1'
*/
if (Vehicle_direction_detection_U.SteeringWheel_YawDegreeInput > 30.0) {
rtb_Switch = Right_Turn_AngularLimit;
} else if (Vehicle_direction_detection_U.SteeringWheel_YawDegreeInput > 0.0) {
/* Switch: '<S2>/Switch1' incorporates:
* Constant: '<S2>/Constant1'
*/
rtb_Switch = Left_Turn_AngularLimit;
} else {
rtb_Switch = Straight_Drive_Steering_Angle;
}
/* End of Switch: '<S2>/Switch' */
/* Outport: '<Root>/direction_indicator' incorporates:
* Constant: '<S4>/Constant'
* Constant: '<S5>/Constant'
* Constant: '<S6>/Constant'
* Inport: '<Root>/CameraInput_RoadSign'
* Logic: '<S3>/AND'
* Logic: '<S3>/AND1'