Challenge

Project 1 (Mini Project on Vehicle Direction Detection

AIM: Identifying the direction of the vehicle based on the camera input.

OBJECTIVE:

1. Development of Matlab Simulink model as per the requirement.

2. Tag the requirements to the Simulink mode; tagging requirement 1 and requirement 2 to the corresponding subsystem.

3. MBD-compliant changes, Data Dictionary creation, and code generation is added advantage.

4. If choosing code generation, the Storage class for input signals: ImportedExtern; the Storage class for output signal: Is export to file; the Storage class for local signals: is localizable; the Storage class for calibration signals: is Const.

5. Choose the sample time for all signals as 0.01s.

THEORY:

-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 the vehicle is basically identifying the direction the vehicle is taking based on the camera input.

-The camera reads the road signs & stores them in its memory with unique values for a left turn, right turn & straight drive. Depending on the direction it is taking, the 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 alongside 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

The model of the Vehicle detection is shown below:

The subsystem of the main block is shown below:

As per requirement 1, the following subsystem is shown:

As per Requirement 2 the corresponding subsystem is shown below:

The second step is now to build the subsystem according to the requirement 2 objectives. The output of subsystem 1 along with the Camerainput_roadsign is given as input to subsystem 2. Firstly the Vehicle_turn_status will be compared with the calibration values Right_tyrn_roadsign, Leftturn_roadsign, and Straight_roadsign using the compare to constant blocks. The output of each of these comparison values will go through logical operators AND which gives the final output called Vehicle_directionIndicator. The output can be displayed using a scope.

procedure:

1.Requirement 1 in the Word file is tagged to subsystem 1.

Select the text from word or any other data document by highlighting the text. Then, by right-clicking, select the requirement and tag the subsystem to the data file.

Similar steps are followed to tag the information related to the subsystem 2.

2.Creation of SLDD and linking it with the model:

Given signals and calibration data list;

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

-

-

Add all the signals and constants with units, initial value, minimum and maximum values, datatype of the signals as shown below.

3.The further step involves resolving all the signals and propagated:

Signal resolving:

Signal propagation:

4. Now, the solver configuration parameters are changed for Simulation and code generation.

For the code generation, embedded coder is selected as the target file:

Code Generation:

After selecting the target model as an Embedded coder, the building and generation of the code of the respective model has been done, the.C file of tVehicle_directionindicator model is shown below.

/*
* Academic License - for use in teaching, academic research, and meeting
* course requirements at degree granting institutions only. Not for
* government, commercial, or other organizational use.
* File: Diretion_detection.c
* Code generated for Simulink model 'Diretion_detection'.
* Model version : 1.7
* Simulink Coder version : 9.8 (R2022b) 13-May-2022
* C/C++ source code generated on : Fri Jan 13 12:42:44 2023
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "Diretion_detection.h"
#include "rtwtypes.h"
#include "Diretion_detection_private.h"
/* Exported data definition */
/* Definition for custom storage class: ExportToFile */
boolean_T Vehicle_directionIndicator; /* '<S3>/Logical Operator3' */
/* Const memory section */
/* Definition for custom storage class: Const */
const int16_T Left_turn_angle = -120;
/* Referenced by: '<S2>/Left_turnangle_value' */
const int16_T Leftturn_roadsign = -120;/* Referenced by: '<S3>/Constant2' */
const int16_T Right_turn_angle = 30;
/* Referenced by: '<S2>/Right_turnangle_value' */
const int16_T Rightturn_roadsign = 30; /* Referenced by: '<S3>/Constant' */
const int16_T Straight_drive_angle = 0;
/* Referenced by: '<S2>/Straight_driveangle_value' */
const int16_T Straight_roadsign = 0; /* Referenced by: '<S3>/Constant1' */
/* Real-time model */
static RT_MODEL_Diretion_detection_T Diretion_detection_M_;
RT_MODEL_Diretion_detection_T *const Diretion_detection_M =
&Diretion_detection_M_;
/* Model step function */
void Diretion_detection_step(void)
{
/* local block i/o variables */
int16_T Vehicle_turnstatus;
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S4>/Constant'
* Constant: '<S5>/Constant'
* Inport: '<Root>/Steeringwheel_yawdegreeInput'
* RelationalOperator: '<S4>/Compare'
* RelationalOperator: '<S5>/Compare'
* Switch: '<S2>/Switch1'
*/
if (Steeringwheel_yawdegreeinput > 0) {
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Right_turnangle_value'
*/
Vehicle_turnstatus = Right_turn_angle;
} else if (Steeringwheel_yawdegreeinput == 0) {
/* Switch: '<S2>/Switch1' incorporates:
* Constant: '<S2>/Straight_driveangle_value'
* Switch: '<S2>/Switch'
*/
Vehicle_turnstatus = Straight_drive_angle;
} else {
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Left_turnangle_value'
* Switch: '<S2>/Switch1'
*/
Vehicle_turnstatus = Left_turn_angle;
}
/* End of Switch: '<S2>/Switch' */
/* Logic: '<S3>/Logical Operator3' 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'
*/
Vehicle_directionIndicator = ((Camerainput_roadsign && (Rightturn_roadsign ==
Vehicle_turnstatus)) || (Camerainput_roadsign && (Straight_roadsign ==
Vehicle_turnstatus)) || (Camerainput_roadsign && (Leftturn_roadsign ==
Vehicle_turnstatus)));
}
/* Model initialize function */
void Diretion_detection_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void Diretion_detection_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
C:\Users\SRINATH H R\Desktop\MINI_PROJECT\Vehicle_direction_detection\Diretion_detection_ert_rtw\Diretion_detection.c
Ln111Col1
Model Advisor checks are performed according to the MAB guidelines:
Conclusion:
The model was vehicle direction detection was created according to the MAB guidelines and C code was generated to flash on the Embedded coder.
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.