Project 1 (Mini Project on Vehicle Direction Detection
Advanced Driver Assistance Systems (ADAS):-Advanced Driver Assistance Systems (ADAS) provides recognition and tracking information to onboard safety systems to detect driver drowsiness, lane departure warning, collision avoidance and protective features to avoid accidents and enhance the driving experience.
ADAS uses camera-based sensors that allow the car to and helps the driver to be better aware of the driving environment. Cameras are installed outside the vehicle, mainly at the top, front, back, sides to capture the images of various objects and traffic sign-language like street, road signs, vehicles, pedestrians and other objects.

The information captured by ADAS cameras is quickly analyzed by supporting software and used to trigger a response by the vehicle to improve safety – such as automatic emergency braking, lane departure warning, driver awake and alert monitoring, blind spot alerts, etc.
Essential safety-critical ADAS applications include:-
- Pedestrian detection/avoidance
- Lane departure warning/correction
- Traffic sign recognition
- Automatic emergency braking
- Blind spot detection
- Vehicle Direction Detection
ADAS prevents the kinds of accidents caused by driver error. It’s well documented that lack of attention for a while or sudden object appearance are the leading causes of accidents in cars taking many lives across the world.
ADAS and self-driving cars are not the same thing. In autonomous vehicles the control is fully granted to machine from self-driving to handling or steering and braking. The driver does not control anything, it can drive itself in the right direction following the right path and traffic rules without colliding any object.
Aim:- To create a Simulink Model of Vehicle Direction Detection model based on given requirements.
Objective:-
- 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.
Model Description:-
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.


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 File:-

Requirement & Tagging:-

Configuration Parameter Changes:-
a) Solver Settings:-

b)Diagnostics -> Data Validity:-

c)Diagnostics -> Connectivity:-

d)Code Generation:-

Model Advisor:- Modelling Standards for MAB checks.

Code:-

/*
* File: Vehicle_Direction_Detection_SM.c
*
* Code generated for Simulink model 'Vehicle_Direction_Detection_SM'.
*
* Model version : 1.2
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Sat May 21 18:50:06 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "Vehicle_Direction_Detection_SM.h"
#include "Vehicle_Direction_Detection_SM_private.h"
/* 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_;
static void rate_scheduler(void);
/*
* This function updates active task flag for each subrate.
* The function is called at model base rate, hence the
* generated code self-manages all its subrates.
*/
static void rate_scheduler(void)
{
/* Compute which subrates run during the next base time step. Subrates
* are an integer multiple of the base rate counter. Therefore, the subtask
* counter is reset when it reaches its limit (zero means run).
*/
(Vehicle_Direction_Detection__M->Timing.TaskCounters.TID[1])++;
if ((Vehicle_Direction_Detection__M->Timing.TaskCounters.TID[1]) > 99) {/* Sample time: [0.01s, 0.0s] */
Vehicle_Direction_Detection__M->Timing.TaskCounters.TID[1] = 0;
}
}
/* Model step function */
void Vehicle_Direction_Detection_SM_step(void)
{
int32_T rtb_Vehicle_Turn_Status;
if (Vehicle_Direction_Detection__M->Timing.TaskCounters.TID[1] == 0) {
/* Outputs for Atomic SubSystem: '/VehicleDirectionDetectionLogic' */
/* Outputs for Atomic SubSystem: '/Reqirement1' */
/* Switch: '/Switch' incorporates:
* Constant: '/Left_Turn_AngularLimit'
* Constant: '/Right_Turn_AngularLimit'
* Constant: '/Straight_Drive_Steering_Angle'
* Inport: '/SteeringWheel_YawDegreeInput'
* RelationalOperator: '/Relational Operator'
* RelationalOperator: '/Relational Operator1'
* RelationalOperator: '/Relational Operator2'
* Switch: '/Switch1'
* Switch: '/Switch2'
*/
if (Right_Turn_AngularLimit == SteeringWheel_YawDegreeInput) {
rtb_Vehicle_Turn_Status = Right_Turn_AngularLimit;
} else if (Left_Turn_AngularLimit == SteeringWheel_YawDegreeInput) {
/* Switch: '/Switch1' incorporates:
* Constant: '/Left_Turn_AngularLimit'
*/
rtb_Vehicle_Turn_Status = Left_Turn_AngularLimit;
} else if (Straight_Drive_Steering_Angle == SteeringWheel_YawDegreeInput) {
/* Switch: '/Switch2' incorporates:
* Constant: '/Straight_Drive_Steering_Angle'
* Switch: '/Switch1'
*/
rtb_Vehicle_Turn_Status = Straight_Drive_Steering_Angle;
} else {
/* Switch: '/Switch1' incorporates:
* Constant: '/Constant'
* Switch: '/Switch2'
*/
rtb_Vehicle_Turn_Status = 0;
}
/* End of Switch: '/Switch' */
/* End of Outputs for SubSystem: '/Reqirement1' */
/* Outputs for Atomic SubSystem: '/Requirement2' */
/* Logic: '/OR' incorporates:
* Constant: '/LeftTurn_RoadSign'
* Constant: '/RightTurn_RoadSign'
* Constant: '/Straight_RoadSign'
* Inport: '/CameraInput_RoadSign'
* Logic: '/AND'
* Logic: '/AND1'
* Logic: '/AND2'
* RelationalOperator: '/Relational Operator'
* RelationalOperator: '/Relational Operator1'
* RelationalOperator: '/Relational Operator2'
*/
Vehicle_Direction_Indicator = ((CameraInput_RoadSign &&
(rtb_Vehicle_Turn_Status == RightTurn_RoadSign)) || (CameraInput_RoadSign &&
(rtb_Vehicle_Turn_Status == LeftTurn_RoadSign)) || (CameraInput_RoadSign &&
(rtb_Vehicle_Turn_Status == Straight_RoadSign)));
/* End of Outputs for SubSystem: '/Requirement2' */
/* End of Outputs for SubSystem: '/VehicleDirectionDetectionLogic' */
}
rate_scheduler();
}
/* Model initialize function */
void Vehicle_Direction_Detection_SM_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void Vehicle_Direction_Detection_SM_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
Result:-A Simulink Model of Vehicle Direction Detection model based on given requirements has been created successfully.