Challenge

Project 1 (Mini Project on Vehicle Direction Detection

Mini Project - Vehicle Direction Determination

Objective:

The objectives of this project are-

  • Development of a MBD compliant MATLAB Simulink model as per requirement.
  • Tag the requirements to the Simulink model; the requirement 1 & requirement 2 are to be tagged with their corresponding subsystems .
  • Creation of Data Dictionary & code generation for the Simulink model.

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.

Development of Simulink Model:

The inputs to the model are the Steering wheel input as yaw rate (Signal name: SteeringWheel_YawDegreeInput) and a camera input (Signal Name: CameraInput_RoadSign), which indicates the occurrence of any road signs.

The camera reads the oncoming road signs and stores the values for right turn, left turn and straight drives. These values are compared with the movement of the vehicle and notified to the driver.

The output of the model is Vehicle direction indicator which is a boolean signal. This signal specifies whether the vehicle is turning right, left or going straight.

The Simulink model is built as follows-

This is the top layer of the model. It contains the two subsystems for Requirement-1 and Requirement-2. The block diagram of the inside of Vehicle_Direction subsystem is shown below-

Requirement – 1 :

  • In the Requirement-1 subsystem, the input is the Steering wheel angular input given as yaw rate (Signal name: SteeringWheel_YawDegreeInput). 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.
  • The comparison logic is achieved using switch blocks. The output of the subsystem is the vehicle turn status which is signal a local signal (Signal Name: Vehicle_Turn_Status).

The figure of the Requirement_1 subsystem is shown below-

This subsystem is then tagged with ‘Requirement-1’ in the word document stating the model requirements. Signals are also resolved and propagated.

Requirement – 2:

  • In the Requirement_2 subsystem, two inputs are one in the local signal coming out of Requiement_1 subsystem (Signal Name: Vehicle_Turn_Status) and another is the camera input (Signal Name: CameraInput_RoadSign) which indicates the road signs coming in way of the vehicle.
  • The signal Vehicle_Turn_Status is compared against calibration values for right turn, left turn and straight (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.
  • The final output achieved after comparing the signals will give the indication of the vehicle direction (Signal Name: Vehicle_Direction_Indicator).

The block diagram of the Requirement_2 subsystem is shown below-

The subsystem is then tagged with the requirements word document. The signals inside are also resolved and propagated.

This completes the Simulink model.

Signals & Calibration Data List:

Given signals and calibration data are tabulated below.

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

-

-

It is directed -

  • For 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.
  • And to choose sample time for all signals as 0.01s.

These instructions are followed and the Simulink data dictionary is build and linked with the model. The snapshot is added below-

Model Advisor :

In the model settings, the fixed step discrete solver is selected with sample time 0.01 seconds. The code generation settings are adjusted to ‘ert.tlc’ target file with language ‘C’.

The model is then checked in the Model advisor for MBD compliance. The guidelines selected for this purpose is MAB . A snapshot is attached below.

The checks are run and the report is generated.

C-Code:

The C-code for the model is generated using the Embedded Coder up in the MATLAB. The generated code is attached below.

/*

* File: Mini_project_VDD.c

*

* Code generated for Simulink model 'Mini_project_VDD'.

*

* Model version : 1.18

* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020

* C/C++ source code generated on : Thu Jan 20 14:32:34 2022

*

* Target selection: ert.tlc

* Embedded hardware selection: Intel->x86-64 (Windows64)

* Code generation objectives: Unspecified

* Validation result: Not run

*/

#include "Mini_project_VDD.h"

#include "Mini_project_VDD_private.h"

/* External outputs (root outports fed by signals with default storage) */

ExtY_Mini_project_VDD_T Mini_project_VDD_Y;

/* Real-time model */

static RT_MODEL_Mini_project_VDD_T Mini_project_VDD_M_;

RT_MODEL_Mini_project_VDD_T *const Mini_project_VDD_M = &Mini_project_VDD_M_;

/* Model step function */

void Mini_project_VDD_step(void)

{

/* local block i/o variables */

int16_T Vehicle_Turn_Status;

/* Switch: '<S2>/Switch' incorporates:

* Constant: '<S2>/Constant'

* Constant: '<S2>/Constant1'

* Constant: '<S2>/Constant2'

* Inport: '<Root>/SteeringWheel_YawDegreeInput'

* RelationalOperator: '<S2>/Relational Operator'

* RelationalOperator: '<S2>/Relational Operator1'

* RelationalOperator: '<S2>/Relational Operator2'

* Switch: '<S2>/Switch1'

* Switch: '<S2>/Switch2'

*/

if (SteeringWheel_YawDegreeInput == Right_Turn_AngularLimit) {

/* Switch: '<S2>/Switch' incorporates:

* Constant: '<S2>/Constant3'

*/

Vehicle_Turn_Status = Right_Turn_AngularLimit;

} else if (SteeringWheel_YawDegreeInput == Left_Turn_AngularLimit) {

/* Switch: '<S2>/Switch1' incorporates:

* Constant: '<S2>/Constant6'

* Switch: '<S2>/Switch'

*/

Vehicle_Turn_Status = Left_Turn_AngularLimit;

} else if (SteeringWheel_YawDegreeInput == Straight_Drive_Steering_Angle) {

/* Switch: '<S2>/Switch2' incorporates:

* Constant: '<S2>/Constant5'

* Switch: '<S2>/Switch'

* Switch: '<S2>/Switch1'

*/

Vehicle_Turn_Status = Straight_Drive_Steering_Angle;

} else {

/* Switch: '<S2>/Switch' incorporates:

* Constant: '<S2>/Constant4'

* Switch: '<S2>/Switch1'

* Switch: '<S2>/Switch2'

*/

Vehicle_Turn_Status = 0;

}

/* End of Switch: '<S2>/Switch' */

/* Outport: '<Root>/Vehicle_Direction_Indicator' incorporates:

* Constant: '<S3>/Constant'

* Constant: '<S3>/Constant1'

* Constant: '<S3>/Constant2'

* Inport: '<Root>/CameraInput_RoadSign'

* Logic: '<S3>/AND'

* Logic: '<S3>/AND1'

* Logic: '<S3>/AND2'

* RelationalOperator: '<S3>/Relational Operator'

* RelationalOperator: '<S3>/Relational Operator1'

* RelationalOperator: '<S3>/Relational Operator2'

*/

Mini_project_VDD_Y.Vehicle_Direction_Indicator[0] = ((RightTurn_RoadSign ==

Vehicle_Turn_Status) && CameraInput_RoadSign);

Mini_project_VDD_Y.Vehicle_Direction_Indicator[1] = ((LeftTurn_RoadSign ==

Vehicle_Turn_Status) && CameraInput_RoadSign);

Mini_project_VDD_Y.Vehicle_Direction_Indicator[2] = ((Straight_RoadSign ==

Vehicle_Turn_Status) && CameraInput_RoadSign);

}

/* Model initialize function */

void Mini_project_VDD_initialize(void)

{

/* (no initialization code required) */

}

/* Model terminate function */

void Mini_project_VDD_terminate(void)

{

/* (no terminate code required) */

}

/*

* File trailer for generated code.

*

* [EOF]

*/

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.

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.