Project 1 (Mini Project on Vehicle Direction Detection
Project 1 (Mini Project on Vehicle Direction Detection)
Aim :
To Develop a model for vehicle direction determination from the requirements given, the requirements are given below:
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 and Calibration Data :

Simulink Model :

1. The Inputs to the Sub-System are Steering wheel yaw degree and Camera Input Road Sign, Output from the block is the Vehicle Direction indicator.
Inside Sub-System Vehicle Direction Determination:

Modeled Sub-System for requirement 1:

2. It can be seen that the Yaw Degree is compared against right turn angular limit, left turn angular limit, and Stright drive steering and Vehicle turn status is given as output.
Model for Requirement 2:

3. The Output from sub-system 1 is input to sub-system 2 along with the camera input road sign.
4. Here the Vehicle turn status is compared against Road signs and then compared with the actual value of camera input road sign.
Requirement Tagging:


Data Dictionary Creation:

Model Configurations :
Code Generation Settings :


Solver Settings:

Code Generation :

Generate C - Code :
/*
* File: mini_project_2021aaa.c
*
* Code generated for Simulink model 'mini_project_2021aaa'.
*
* Model version : 3.22
* Simulink Coder version : 9.7 (R2022a) 13-Nov-2021
* C/C++ source code generated on : Sun Aug 28 20:31:18 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "mini_project_2021aaa.h"
#include "rtwtypes.h"
#include "mini_project_2021aaa_private.h"
/* Exported block signals */
int16_T Vehicle_Turn_Status; /* '<S2>/Switch' */
/* Exported data definition */
/* Const memory section */
/* Definition for custom storage class: Const */
const int16_T LeftTurn_RoadSign = -120;
/* Referenced by: '<S1>/LeftTurn_RoadSign' */
const int16_T Left_Turn_AngularLimit = -120;
/* Referenced by: '<S1>/CoLeft_Turn_AngularLimitnstant1' */
const int16_T RightTurn_RoadSign = 30;
/* Referenced by: '<S1>/ConsRightTurn_RoadSigntant3' */
const int16_T Right_Turn_AngularLimit = 30;
/* Referenced by: '<S1>/ConRight_Turn_AngularLimitstant' */
const int16_T Straight_Drive_Steering_Angle = 0;
/* Referenced by: '<S1>/Straight_Drive_Steering_Angle' */
const int16_T Straight_RoadSign = 0;
/* Referenced by: '<S1>/Straight_RoadSign' */
/* External outputs (root outports fed by signals with default storage) */
ExtY_mini_project_2021aaa_T mini_project_2021aaa_Y;
/* Real-time model */
static RT_MODEL_mini_project_2021aaa_T mini_project_2021aaa_M_;
RT_MODEL_mini_project_2021aaa_T *const mini_project_2021aaa_M =
&mini_project_2021aaa_M_;
/* Model step function */
void mini_project_2021aaa_step(void)
{
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S1>/CoLeft_Turn_AngularLimitnstant1'
* Constant: '<S1>/ConRight_Turn_AngularLimitstant'
* Inport: '<Root>/SteeringWheel_YawDegreeInput '
* RelationalOperator: '<S2>/Relational Operator'
* RelationalOperator: '<S2>/Relational Operator1'
* Switch: '<S2>/Switch1'
*/
if (Right_Turn_AngularLimit == SteeringWheel_YawDegreeInput) {
/* Switch: '<S2>/Switch' */
Vehicle_Turn_Status = Right_Turn_AngularLimit;
} else if (Left_Turn_AngularLimit == SteeringWheel_YawDegreeInput) {
/* Switch: '<S2>/Switch1' incorporates:
* Constant: '<S1>/CoLeft_Turn_AngularLimitnstant1'
* Switch: '<S2>/Switch'
*/
Vehicle_Turn_Status = Left_Turn_AngularLimit;
} else {
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S1>/Straight_Drive_Steering_Angle'
* Switch: '<S2>/Switch1'
*/
Vehicle_Turn_Status = Straight_Drive_Steering_Angle;
}
/* End of Switch: '<S2>/Switch' */
/* Outport: '<Root>/Vehicle_Direction_Indicator ' incorporates:
* Constant: '<S1>/ConsRightTurn_RoadSigntant3'
* Constant: '<S1>/LeftTurn_RoadSign'
* Constant: '<S1>/Straight_RoadSign'
* Inport: '<Root>/CameraInput_RoadSign '
* Logic: '<S3>/AND'
* Logic: '<S3>/AND1'
* Logic: '<S3>/AND2'
* RelationalOperator: '<S3>/Relational Operator'
* RelationalOperator: '<S3>/Relational Operator1'
* RelationalOperator: '<S3>/Relational Operator2'
*/
mini_project_2021aaa_Y.Vehicle_Direction_Indicator[0] = (CameraInput_RoadSign &&
(RightTurn_RoadSign == Vehicle_Turn_Status));
mini_project_2021aaa_Y.Vehicle_Direction_Indicator[1] = (CameraInput_RoadSign &&
(LeftTurn_RoadSign == Vehicle_Turn_Status));
mini_project_2021aaa_Y.Vehicle_Direction_Indicator[2] = (CameraInput_RoadSign &&
(Straight_RoadSign == Vehicle_Turn_Status));
}
/* Model initialize function */
void mini_project_2021aaa_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void mini_project_2021aaa_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
Conclusion:
The Model has been developed as per the requirement sheet, and the Simulink data dictionary along with code generation and requirement tagging has been completed, supporting screenshots are also submitted. All the files are attached while submitting the assignment.