Project 1 (Mini Project on Vehicle Direction Detection
# Aim:
To create the vehicle direction determinationmodel according to the given requirements.
# Theory:
Identifying the direction of the vehicle is one of the important abd diverse feature in autonomous driving and advanced driver assistance features. The particular sub- feature of identifying the direction of the vehicle is basically indentifying the direction the vehicle is taking based on the camera input.
The camera reads the roa sign and stores them into its memory with unique values foe a left turn, right turn and straight drive. Depending on the direction it is taking, the final indication if he is driving in the recommonded direction or not.
Vehicle direction determination can also be coupled alongside features like GPS systems to identify whether the vehicle is reachung its destination in an optimized manner. This sub-feature can also be used along with Lane deteection,Highway Warning,Ramp Entry/ Exit Wring Way Detection.
# 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).

# SLDD:

- In a modelling tab, Go to link to library, create new Data Dictionary.
- Add in the same folder where model is stored.
- Go to model configuration, in design data edit the signals or parameters.
# Steps for generating a code:
1. In model configuration solver is set to fixed step solver(discrete non continuous)with 0.01 sample time.
2. Code generation setting is set to embedded coder(ert.tlc).
3. Right click on the subsystem and treated it as a automic subsystem.
# Model advisor check:
- In model advisor, Go to By task.
- Click on Modelling standards for MAB. Check fail condition, if any resolve it.
- Once the fail conditions are zero the genarate report.

# Code generation:
/*
* File: Vehicle.c
*
* Code generated for Simulink model 'Vehicle'.
*
* Model version : 1.20
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Fri Apr 1 13:48:31 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "Vehicle.h"
#include "Vehicle_private.h"
/* Exported data definition */
/* Definition for custom storage class: ExportToFile */
boolean_T Vehicle_Direction_Indicator[3];/* '
/* Const memory section */
/* Definition for custom storage class: Const */
const int16_T LeftTurn_RoadSign = -120;/* Referenced by: '
const int16_T Left_Turn_AngularLimit = -120;/* Referenced by:
* '
* '
*/
const int16_T RightTurn_RoadSign = 30; /* Referenced by: '
const int16_T Right_Turn_AngularLimit = 30;/* Referenced by:
* '
* '
*/
const int16_T Straight_Drive_Steering_Angle = 0;/* Referenced by:
* '
* '
*/
const int16_T Straight_RoadSign = 0; /* Referenced by: '
/* Real-time model */
static RT_MODEL_Vehicle_T Vehicle_M_;
RT_MODEL_Vehicle_T *const Vehicle_M = &Vehicle_M_;
/* Model step function */
void Vehicle_step(void)
{
/* local block i/o variables */
int16_T Vehicle_Turn_Status;
/* Switch: '
* Constant: '
* Constant: '
* Constant: '
* Inport: '
* RelationalOperator: '
* RelationalOperator: '
* RelationalOperator: '
* Switch: '
* Switch: '
*/
if (SteeringWheel_YawDegreeinput == Right_Turn_AngularLimit) {
/* Switch: '
* Constant: '
*/
Vehicle_Turn_Status = Right_Turn_AngularLimit;
} else if (SteeringWheel_YawDegreeinput == Left_Turn_AngularLimit) {
/* Switch: '
* Constant: '
* Switch: '
*/
Vehicle_Turn_Status = Left_Turn_AngularLimit;
} else if (SteeringWheel_YawDegreeinput == Straight_Drive_Steering_Angle) {
/* Switch: '
* Constant: '
* Switch: '
* Switch: '
*/
Vehicle_Turn_Status = Straight_Drive_Steering_Angle;
} else {
/* Switch: '
* Constant: '
* Switch: '
* Switch: '
*/
Vehicle_Turn_Status = 0;
}
/* End of Switch: '
/* SignalConversion: '
* Constant: '
* Constant: '
* Constant: '
* Inport: '
* Logic: '
* Logic: '
* Logic: '
* RelationalOperator: '
* RelationalOperator: '
* RelationalOperator: '
*/
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);
}
/* Model initialize function */
void Vehicle_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void Vehicle_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/