Project 1 (Mini Project on Vehicle Direction Detection
Development of MATLAB Simulink model as per requirement

This is the main model subsystem that having two inputs SteeringWheel_YawDegreeInput and Camerainput_Roadsign entering into the Vehicle Detection Determination and one output Vehicle_Direction_indicator.
There are 2 requirements are designed in two subsystem-
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 Tagging-

Vehicle_turn_status_subsystem is linked to the Requirement 1 in word.
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).

Tagging Requirement 2 is linked with word.

3. Developind SLDD-


All the inputs, outputs, calibration parameters are saved in SLDD while simulation the model takes all the values and its parameters from the simulink data dictionary.
SIGNAL RESOLUTION AND PROPAGATION FOR INPUTS AND OUTPUTS-


For signal resolution, double click on signal and then right click on it, go to properties and select resolve to simulink signal.
For propagation,double click on signal and then right click on it, go to properties and select show propagated signal.
The inputs and output signal are resolved so the signals will take the values from SLDD and pass them to the logical blocks. Otherwise it may take some junk values, if it is unresolved.
MODEL ADVISOR REPORT-

Code generation-

/*
* File: vehicle_direction.c
*
* Code generated for Simulink model 'vehicle_direction'.
*
* Model version : 1.11
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Mon May 30 15:36:38 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "vehicle_direction.h"
#include "vehicle_direction_private.h"
/* Exported data definition */
/* Definition for custom storage class: ExportToFile */
boolean_T Vehicle_Direction_Indicator[3];/* '<S2>/Signal Conversion' */
/* Const memory section */
/* Definition for custom storage class: Const */
const int16_T LeftTurn_RoadSign = -120;/* Referenced by: '<S2>/Constant1' */
const int16_T Left_Turn_AngularLimit = -120;/* Referenced by: '<S3>/Constant2' */
const int16_T RightTurn_RoadSign = 30; /* Referenced by: '<S2>/Constant' */
const int16_T Right_Turn_AngularLimit = 30;/* Referenced by: '<S3>/Constant' */
const int16_T Straight_Drive_Steering_Angle = 0;/* Referenced by: '<S3>/Constant1' */
const int16_T Straight_RoadSign = 0; /* Referenced by: '<S2>/Constant2' */
/* Real-time model */
static RT_MODEL_vehicle_direction_T vehicle_direction_M_;
RT_MODEL_vehicle_direction_T *const vehicle_direction_M = &vehicle_direction_M_;
/* Model step function */
void vehicle_direction_step(void)
{
/* local block i/o variables */
int16_T Vehicle_Turn_Status;
/* Outputs for Atomic SubSystem: '<Root>/Subsystem' */
/* Switch: '<S3>/Switch' incorporates:
* Constant: '<S4>/Constant'
* Constant: '<S5>/Constant'
* Inport: '<Root>/SteeringWheel_YawDegreeInput'
* RelationalOperator: '<S4>/Compare'
* RelationalOperator: '<S5>/Compare'
* Switch: '<S3>/Switch1'
*/
if (SteeringWheel_YawDegreeInput > 0) {
/* Switch: '<S3>/Switch' incorporates:
* Constant: '<S3>/Constant'
*/
Vehicle_Turn_Status = Right_Turn_AngularLimit;
} else if (SteeringWheel_YawDegreeInput == 0) {
/* Switch: '<S3>/Switch1' incorporates:
* Constant: '<S3>/Constant1'
* Switch: '<S3>/Switch'
*/
Vehicle_Turn_Status = Straight_Drive_Steering_Angle;
} else {
/* Switch: '<S3>/Switch' incorporates:
* Constant: '<S3>/Constant2'
* Switch: '<S3>/Switch1'
*/
Vehicle_Turn_Status = Left_Turn_AngularLimit;
}
/* End of Switch: '<S3>/Switch' */
/* SignalConversion: '<S2>/Signal Conversion' incorporates:
* Constant: '<S2>/Constant'
* Constant: '<S2>/Constant1'
* Constant: '<S2>/Constant2'
* Inport: '<Root>/CameraInput_RoadSign'
* Logic: '<S2>/Logical Operator'
* Logic: '<S2>/Logical Operator1'
* Logic: '<S2>/Logical Operator2'
* RelationalOperator: '<S2>/Relational Operator'
* RelationalOperator: '<S2>/Relational Operator1'
* RelationalOperator: '<S2>/Relational Operator2'
*/
Vehicle_Direction_Indicator[0] = ((Vehicle_Turn_Status == RightTurn_RoadSign) &&
CameraInput_RoadSign);
Vehicle_Direction_Indicator[1] = ((Vehicle_Turn_Status == LeftTurn_RoadSign) &&
CameraInput_RoadSign);
Vehicle_Direction_Indicator[2] = ((Vehicle_Turn_Status == Straight_RoadSign) &&
CameraInput_RoadSign);
/* End of Outputs for SubSystem: '<Root>/Subsystem' */
}
/* Model initialize function */
void vehicle_direction_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void vehicle_direction_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
