Challenge

Project 1 (Mini Project on Vehicle Direction Detection

Mini Project - Vehicle Direction Determination

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.01s

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.

The input to system is Steering Wheel Yaw Degree Input given as Yaw rate (Signal name: SteeringWheel_YawDegreeInput) and input from camera (Signal Name: CameraInput_RoadSign) which confirms the occurrence of a road sign.

A Camera reads the road signs and stored into the memory unique values for left turn, right turn and straight drive. Depending upon the vehicle direction the final indication given to driven on the dashboard from the the outport sig (Signal Name: Vehicle_Direction_Indicator).

Development of the Simulink Model: -

The main subsystem ‘Vehicle_Direction_Subsytem’ along with inputs Steering Wheel Yaw Degree Input and Camera Input Road Sign and output is Vehicle Direction Indicator is shown below.

The main subsystem is further subdivided into 2 more subsystems which are requirement 1 & requirement 2

Requirement 1

In the Requirement 1 subsystem, the input Steering Wheel Yaw Degree Input is fed to input subsystem and this value compared against 3 angular signals Right Turn Angular Limit, Left Turn Angular Limit, Straight Drive Steering Angle to specify specific direction to turn steering angle.

the input Steering Wheel Yaw Degree Input is fed to input subsystem and this value compared against 3 angular signals Right Turn Angular Limit, Left Turn Angular Limit, Straight Drive Steering Angle using relational operator == and if sig same then it goes to switch and out as Right Turn Road Sign, Left Turn Road Sign, Straight Road Sign resply.

Then at end output is generate as Vehicle turn status which is fed to input for Requirement 2 subsytem.

Requirement 2

The requirement 2 subsystem has 2 inputs, one from requirement1 and other is from camera input from road signs. Firstly, the Vehicle turn status is compare in the relational operator == with Right Turn Road Sign, Left Turn Road Sign, Straight Road Sign.

The values from == operator & input from camera (Signal Name: CameraInput_RoadSign) are input for AND gate and AND gate shows true as input only when there both inputs are same.

Next to that is a MUX which takes multi-input and give multi output but with right signal. Next this out connect to signal conversion block to rename the sig as Vehicle Direction Indicator.

Creating Data Dictionary: -

For creating data dictionary, we have to click on link to data dictionary option in the modelling tab from MATLAB software, then add new SLDD file and add different signals and parameter values into the SLDD file.

After this an SLDD is created and in that we have to addd signals and parameters values which are given in requirements

Block Parameter and Configration Settings: -

Make sure that Solver setting is at Fixed step with sample time as 0.01 which is given in the question, and code generation part is done using embedded coder setting in which we have to select ert.tlc for coder.

Tagging and Traceability: -

Every subsystem is link to word file by then Requirement tagging option and it shows in below fig.

Model Advisor check: -

To check the model form is according to MAB guidelines or not we have to test it under Model Advisor check in Modelling option. In that specifically Task check block under which Modelling Guidelines for MAB option we have to test our model.

From this a report is created in which complete detail about our Simulink model and if any warning or error is present then it shows in that report by help of that we can easily remove those errors.

Generated HTML report file: -

After these we can proceed for code generation.

C code Generation: -

Code is created using built a code from Embedded code option under APPS tab in software, which generate a code and its subsequent file which stores in same location where our Simulink model is saved.

VehicleDirection.c

/*

* File: VehicleDirection.c

*

* Code generated for Simulink model 'VehicleDirection'.

*

* Model version : 1.5

* Simulink Coder version : 9.3 (R2020a) 18-Nov-2019

* C/C++ source code generated on : Mon Jan 24 20:40:33 2022

*

* Target selection: ert.tlc

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

* Code generation objectives: Unspecified

* Validation result: Not run

*/

#include "VehicleDirection.h"

#include "VehicleDirection_private.h"

/* Exported data definition */

/* Definition for custom storage class: ExportToFile */

boolean_T Vehicle_Direction_Indicator[3];/* '<S3>/Signal Conversion' */

/* Const memory section */

/* Definition for custom storage class: Const */

const int16_T LeftTurn_RoadSign = -120;/* Referenced by: '<S3>/Constant1' */

const int16_T Left_Turn_AngularLimit = -120;/* Referenced by:

* '<S2>/Constant1'

* '<S2>/Constant4'

*/

const int16_T RightTurn_RoadSign = 30; /* Referenced by: '<S3>/Constant' */

const int16_T Right_Turn_AngularLimit = 30;/* Referenced by:

* '<S2>/Constant'

* '<S2>/Constant3'

*/

const int16_T Straight_Drive_Steering_Angle = 0;/* Referenced by:

* '<S2>/Constant2'

* '<S2>/Constant5'

*/

const int16_T Straight_RoadSign = 0; /* Referenced by: '<S3>/Constant2' */

/* Real-time model */

RT_MODEL_VehicleDirection_T VehicleDirection_M_;

RT_MODEL_VehicleDirection_T *const VehicleDirection_M = &VehicleDirection_M_;

/* Model step function */

void VehicleDirection_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'

* Constant: '<S2>/Constant3'

* 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) {

Vehicle_Turn_Status = Right_Turn_AngularLimit;

} else if (SteeringWheel_YawDegreeInput == Left_Turn_AngularLimit) {

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

* Constant: '<S2>/Constant4'

*/

Vehicle_Turn_Status = Left_Turn_AngularLimit;

} else if (SteeringWheel_YawDegreeInput == Straight_Drive_Steering_Angle) {

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

* Constant: '<S2>/Constant5'

* Switch: '<S2>/Switch1'

*/

Vehicle_Turn_Status = Straight_Drive_Steering_Angle;

} else {

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

* Constant: '<S2>/Constant6'

* Switch: '<S2>/Switch2'

*/

Vehicle_Turn_Status = 0;

}

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

/* SignalConversion: '<S3>/Signal Conversion' 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'

*/

Vehicle_Direction_Indicator[0] = (CameraInput_RoadSign && (Vehicle_Turn_Status

== RightTurn_RoadSign));

Vehicle_Direction_Indicator[1] = (CameraInput_RoadSign && (Vehicle_Turn_Status

== LeftTurn_RoadSign));

Vehicle_Direction_Indicator[2] = (CameraInput_RoadSign && (Vehicle_Turn_Status

== Straight_RoadSign));

}

/* Model initialize function */

void VehicleDirection_initialize(void)

{

/* (no initialization code required) */

}

/* Model terminate function */

void VehicleDirection_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.