Project 1 (Mini Project on Vehicle Direction Detection
MINI PROJECT ON VEHICLE DIRECTION DETECTION
Aim: To identify the vehicle direction detection with using c code, html, MATLAB and camera input.
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.
OBJECTIVE OF MINI PROJECT:
- 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.01.
DESCRIPTION:
PROJECT MODEL:

REQUIREMENT 1:
For the requirement 1 inport is steering wheel yaw degree input it connects to three blocks of calibration values right turn angular limit, left turn angular limit ang straight drive steering angle by equal operator to justify the condition required by in input this equal operator is connected to the switch cases to check the conditions is true or false. Outport is named as the vehicle turn status.

REQUIREMENT 2:
For the requirement 2 input as getting from camera input and output from requirement 1 as vehicle turn status. In this subsystem as equal operator is used for justifying the input of right road sign, left road sign and straight road sign from camera inputs and the logical operator is used for the identify the required output is needed to vehicle to drive in specific direction by the camera input.

SLDD FILE:
The sldd file is created by the in-model explorer to data dictionary in the given requirement signals and parameters (calibration values).
Signals & Calibration Data List:
|
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 |
- |
- |

MODEL ADVISER:
By get the report of model advisor we need to select the modelling tab in that select the model advisor at the left corner,
After that select the entire system then click on by task in that select the modelling standard MAB option. Run the checks.


REQUIREMENT TAGGING:
- The requirement tagging of the model by selecting the word document.
- for requirement 1 select the(requirement1) word doc. right click on the requirement 1 system then select the link to word doc.

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).

- For requirement 2 select the(requirement2) word doc. right click on the requirement 2 system then select the link to word doc.

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).

SOLVER AND CODE GENERATION SETTING:
In modelling tab select the model setting in that choose solver setting to changes in slover step to fixed step.

In code generation setting select the code type to ert.tlc embedded c code.

Code generation
/*
* Event Support License -- for demonstration use and event support. Not
* for government, research, commercial, or other organizational use.
*
* File: vechile_dir_indication.c
*
* Code generated for Simulink model 'vechile_dir_indication'.
*
* Model version : 1.5
* Simulink Coder version : 9.9 (R2023a) 19-Nov-2022
* C/C++ source code generated on : Tue Jun 6 12:19:50 2023
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "vechile_dir_indication.h"
#include "rtwtypes.h"
#include "vechile_dir_indication_private.h"
/* Exported data definition */
/* Const memory section */
/* Definition for custom storage class: Const */
const int16_T Left_turn_angularlimit = -120;/* Referenced by:
* '<S2>/Constant1'
* '<S2>/Constant4'
*/
const int16_T Left_turn_roadsign = -120;/* Referenced by: '<S3>/Constant1' */
const int16_T Right_turn_angularlimit = 30;/* Referenced by:
* '<S2>/Constant'
* '<S2>/Constant3'
*/
const int16_T Right_turn_roadsign = 30;/* Referenced by: '<S3>/Constant' */
const int16_T Straight_drive_steering_angle = 0;/* Referenced by:
* '<S2>/Constant2'
* '<S2>/Constant5'
*/
const int16_T straight_roagsign = 0; /* Referenced by: '<S3>/Constant2' */
/* External outputs (root outports fed by signals with default storage) */
ExtY_vechile_dir_indication_T vechile_dir_indication_Y;
/* Real-time model */
static RT_MODEL_vechile_dir_indicati_T vechile_dir_indication_M_;
RT_MODEL_vechile_dir_indicati_T *const vechile_dir_indication_M =
&vechile_dir_indication_M_;
/* Model step function */
void vechile_dir_indication_step(void)
{
int32_T rtb_Vehicle_turn_status;
/* Switch: '<S2>/Switch3' incorporates:
* Constant: '<S2>/Constant'
* Constant: '<S2>/Constant1'
* Constant: '<S2>/Constant2'
* Constant: '<S2>/Constant3'
* Inport: '<Root>/steeringwheel_yawDegreeinput'
* RelationalOperator: '<S2>/Equal'
* RelationalOperator: '<S2>/Equal1'
* RelationalOperator: '<S2>/Equal2'
* Switch: '<S2>/Switch1'
* Switch: '<S2>/Switch2'
*/
if (steeringwheel_yawDegreeinput == Right_turn_angularlimit) {
rtb_Vehicle_turn_status = Right_turn_angularlimit;
} else if (steeringwheel_yawDegreeinput == Left_turn_angularlimit) {
/* Switch: '<S2>/Switch1' incorporates:
* Constant: '<S2>/Constant4'
*/
rtb_Vehicle_turn_status = Left_turn_angularlimit;
} else if (steeringwheel_yawDegreeinput == Straight_drive_steering_angle) {
/* Switch: '<S2>/Switch2' incorporates:
* Constant: '<S2>/Constant5'
* Switch: '<S2>/Switch1'
*/
rtb_Vehicle_turn_status = Straight_drive_steering_angle;
} else {
/* Switch: '<S2>/Switch1' incorporates:
* Constant: '<S2>/Constant6'
* Switch: '<S2>/Switch2'
*/
rtb_Vehicle_turn_status = 0;
}
/* End of Switch: '<S2>/Switch3' */
/* Outport: '<Root>/vehicle_direction_indicator' incorporates:
* Constant: '<S3>/Constant'
* Constant: '<S3>/Constant1'
* Constant: '<S3>/Constant2'
* Inport: '<Root>/camerainput_roadsign'
* Logic: '<S3>/Logical Operator'
* Logic: '<S3>/Logical Operator1'
* Logic: '<S3>/Logical Operator2'
* RelationalOperator: '<S3>/Equal'
* RelationalOperator: '<S3>/Equal1'
* RelationalOperator: '<S3>/Equal2'
*/
vechile_dir_indication_Y.vehicle_direction_indicator[0] =
((rtb_Vehicle_turn_status == Right_turn_roadsign) && camerainput_roadsign);
vechile_dir_indication_Y.vehicle_direction_indicator[1] =
((rtb_Vehicle_turn_status == Left_turn_roadsign) && camerainput_roadsign);
vechile_dir_indication_Y.vehicle_direction_indicator[2] =
((rtb_Vehicle_turn_status == straight_roagsign) && camerainput_roadsign);
}
/* Model initialize function */
void vechile_dir_indication_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void vechile_dir_indication_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
OUTPUT:
Hence the output of the model is getting in display block.
