Challenge

Project 1 (Mini Project on Vehicle Direction Detection

The objective of the Mini Project:

  1. Development of MATLAB Simulink model as per requirement.
  2. Tag the requirements to the Simulink model; tagging requirements 1 & requirement 2 to their corresponding subsystems is fine.
  3. MBD compliant changes, Data Dictionary creation & code generation is added advantage, and that is not the scope of this project.
  4. 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.
  5. Choose sample time for all signals as 0.01s

TASK:

we have to perform tasks according to the given requirements-

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 a 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 & the 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 a local signal from requirement 1 (Signal Name: Vehicle_Turn_Status) & an input signal from the 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 an output signal (Signal Name: Vehicle_Direction_Indicator).

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

The camera reads the road signs & stores them into 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.

To, create a model follow the steps done below-

STEP1-

create sldd_file-

all the input and outputs calibration parameters are saved in SLDD so while simulation the model takes all the values and its parameter from the Simulink data dictionary.

how to create sldd_file-

first, go to modeling tag> click on a link to data dictionary> then click on new and name the file >ok.

STEP-2

DESIGN THE MODEL ACCORDING TO THE GIVEN REQUIREMENTS -

This main model subsystem that having two inputs SteeringWheel_yawDegreeInput and CameraInput_RoadSign entering into the Vehicle Detection Determination subsystem and outputting Vehicle_Direction_Indicator.

THERE ARE TWO REQUIREMENTS DESIGNED IN THE MODEL

REQUIREMENT1--

The subsystem of 1 Requirement-

REQUIREMENT-2

STEP-3 REQUIREMENT TAGGING-

all requirements are tagged in order for a better understanding anyone who is reviewing the model or who is trying to update the model can get a clear idea of what logic is used in the system from the requirement manager we can see what are all tagged and description

1. firstly I wrote all requirements in a word file then I selected my first requirement then I return in the model select my first subsystem right clicked on it then goto requirement and link to selection in word my subsystem box is highlighted and linked in this way I link my second subsystem with my requirement 2

STEPS-4 Signal Resolving

signal resolution for input and output:

the input and output signals are resolved so the signals will take the values from sldd and pass them to the logical blocks otherwise it may take some junk values it is unresolved

to propagate the signal-

step-4

Model update:

the model update is done by ctrl+d this is done to check for any static error, if there are no errors coming the model is working fine with any error

simulation:

the model is simulated too for checking for errors and warning

Configuration:

various configuration parameters are updated as per code generation the solver type should be fixed for code generation.

STEP-5

Model Advisory Report:

by running the model advisor tool I can see commonly made mmodelingerrores.

I go in modeling and click on model advisor than their selected by-product in that select MAB and run selected check I got the following result is passed successfully.

Creation Of MIL(the model in the loop) and SIL(software in loop) test.

FOR THE CREATION OF A TEST HARNESS WE USE THE FOLLOWING PROCESS

Creation Of MIL(the model in the loop)

  • IN a subsystem block we click on test harness, for creating harness click subsystem name"Vehicle_Direction'.

After clicking Vehicle_direction one block parameter is open, where we can change the required parameter. here we change the input parameter instead of the signal builder block to get desired output

completing all processes we get one new model of test harness which is the Simulink model itself

the below sample model of the test harness, here we are able to see the left side of the input signal builder is added.

Adding the signal builder input in the model, here we add the sum block and scope block to verify the

model in the loop test(MIL). for this when we run the model we got desired output.

by clicking the signal builder block we Import an excel file. there we have given the input, simulation time, and various directions of the vehicle

  • input
  • Left_turn
  • Right_turn
  • Round_turn

through that excel sheet, we got the signal builder waveform which is shown below.

here we can clearly see the input and direction of the WAVEFORM

  • Left_turn
  • Right_turn
  • Round_turn

Creation Of SIL(the Software in the loop):

Same procedure we repeat again which we are using in MIL testing

completing all processes we get one new model of test harness which is the Simulink model itself

Code Generation:

for this code generation, I go into the apps tab then the embedded coder I chose c code and build

that has been attached to the code window.

CODE -

/*
* File: Vehicle_Direction.c
* Code generated for Simulink model 'Vehicle_Direction'.
* Model version: 1.24
* Simulink Coder version : 9.3 (R2020a) 18-Nov-2019
* C/C++ source code generated on : Mon Aug 15 01:14:39 2022
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "Vehicle_Direction.h"
#include "Vehicle_Direction_private.h"
/* Exported data definition */
/* Const memory section */
/* Definition for custom storage class: Const */
const int16_T LeftTurn_AngularLimit = -120;/* Referenced by: '<S2>/Constant2' */
const int16_T LeftTurn_RoadSign = -120;/* Referenced by: '<S3>/Constant1' */
const int16_T RightTurn_AngularLimit = 30;/* Referenced by: '<S2>/Constant' */
const int16_T RightTurn_RoadSign = 30; /* Referenced by: '<S3>/Constant' */
const int16_T Straight_Drive_Steering_Angle = 0;/* Referenced by: '<S2>/Constant1' */
const int16_T Straight_RoadSign = 0; /* Referenced by: '<S3>/Constant2' */
/* External outputs (root outports fed by signals with default storage) */
ExtY_Vehicle_Direction_T Vehicle_Direction_Y;
/* Real-time model */
RT_MODEL_Vehicle_Direction_T Vehicle_Direction_M_;
RT_MODEL_Vehicle_Direction_T *const Vehicle_Direction_M = & Vehicle_Direction_M_;
/* Model step function */
void Vehicle_Direction_step(void)
{
/* local block i/o variables */
int16_T Vehicle_Turn_Status;
/* Outputs for Atomic SubSystem: '<Root>/Vehicle_Direction' */
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant'
* Constant: '<S2>/Constant2'
* Constant: '<S4>/Constant'
* Constant: '<S5>/Constant'
* RelationalOperator: '<S4>/Compare'
* RelationalOperator: '<S5>/Compare'
* Switch: '<S2>/Switch1'
*/
if (SteeringWheel_YawDegreeInput > 0) {
Vehicle_Turn_Status = RightTurn_AngularLimit;
}
else if (SteeringWheel_YawDegreeInput > 0) {
/* Switch: '<S2>/Switch1' incorporates:
* Constant: '<S2>/Constant1'
*/
Vehicle_Turn_Status = Straight_Drive_Steering_Angle;
}
else
{
Vehicle_Turn_Status = LeftTurn_AngularLimit;
}
/* End of Switch: '<S2>/Switch' */
/* Outport: '<Root>/Vehicle_Direction_Indicator' incorporates:
* Constant: '<S3>/Constant'
Constant: '<S3>/Constant1'
* Constant: '<S3>/Constant2'
* Logic: '<S3>/AND'
* Logic: '<S3>/AND1'
* Logic: '<S3>/AND2'
* RelationalOperator: '<S3>/Relational_Operator'
* RelationalOperator: '<S3>/Relational_Operator1'
* RelationalOperator: '<S3>/Relational_Operator2'
*/
Vehicle_Direction_Y.Vehicle_Direction_Indicator[0] = ((Vehicle_Turn_Status ==RightTurn_RoadSign) && CameraInput_RoadSign);
Vehicle_Direction_Y.Vehicle_Direction_Indicator[1] = ((Vehicle_Turn_Status ==LeftTurn_RoadSign) &&
CameraInput_RoadSign);
Vehicle_Direction_Y.Vehicle_Direction_Indicator[2] = ((Vehicle_Turn_Status==Straight_RoadSign) &&
CameraInput_RoadSign);
/* End of Outputs for SubSystem: '<Root>/Vehicle_Direction' */
}
/* Model initialize function */
void Vehicle_Direction_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void Vehicle_Direction_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.