Challenge

Project 1 (Mini Project on Vehicle Direction Detection

Aim Of The Project: Identifying the direction of the vehicle based on the camera input

Ojective:

  1. Development of MATLAB Simulink model as per requirement.
  2. Tag the requirements to the Simulink model; tagging requirement 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.

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 takingbased 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

Development of the Target Model:

As per the requirement as shown below the target model has been developed:

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

  • 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 (SignalName: Vehicle_Direction_Indicator.)

The Overall Model of Vehicle Direction Detection is shown below:

The Subsystem of the main model by addition of signal convection block is shown below:

The Subsystem of the main model is shown below

As per Requirement 1, the corresponding subsystem is shown below:
1. The first step in building the model is the understand the requirements and select the right blocks. We will be building a subsystem satisfying the Requirement-1 objectives. We give an input named 'SteeringWheel_YawDegreeInput' which is nothing but the yaw rate of the steering wheel. This value will be compared with 3 angular values for the left turn, right turn, and straight drive to say which specific direction the steering wheel is turning towards and we use the switch blocks to achieve this. This subsystem is shown below.

From the above image, we can see that the yaw rate input is compared with the 'Right_Turn_AngularLimit' which is 30. If the input is equal to or greater than 30, then the Right-Turn value will be passed. If not the output of the second switch will be passed. Now, if theinput is less than 30, it passes to the second switch condition, here if the input is not equal to 0, then the Left_Turn value is passed, or else the Straight_Drive value will be passed.

As per Requirement 2, the corresponding subsystem is shown below:

2.We will now build a subsystem satisfying the Requirement-2 objectives. The output of the first subsystem 'Vehicle_Turn_Status' is given as an input along with the 'CameraInput_RoadSign' to the second subsystem. First, the 'Vehicle_Turn_Status' will be compared with calibration values RightTurn_RoadSign, LeftTurn_RoadSign, Straight_RoadSign using the 'compare to constant blocks'. The output of each of these comparison values will go through logical operators 'AND' which will give us the final output called theVehicle_Direction_Indicator'. The subsystem is shown below

From the above image, we can see that the input from the previous subsystem will be compared with3 'compare to constant blocks'and the output of which will be compared with the camera input using the logical operators. The AND signal will give us the selected output required and it will be collected using the 'Mux' block. The output can be displayed using the display block. The final model of the 'Vehicle_Direction_Detection' is shown below.

Procedures:

1. Tagging of the Requirement with the Model:

The requirement is written in MS-Word which is then tagged with each subsystem as shown below:

2. Linking the Model with SLDD

By taking reference data we made sldd file .

3. Resolving and Propagating the Signal at various stages:

All the input and output signals are resolved at their origin and they are propagated at the corresponding stages as shown below

4. Changes in Configuration parameters for simulation and code generationFor Simulation the Solver Setting
choosen are as follows:

For Code Generation, the embedded coder is as target file as shown below:

Code Generation:
After selecting the target model as Embedded Coder, the building and generation of the Code of the respective model has been done, the .C file of the Vehicle_Direction_Detection model is shown below:

vehicaldirection_detection.c
/*
* File: vehicaldirection_detection.c
*
* Code generated for Simulink model 'vehicaldirection_detection'.
*
* Model version : 1.8
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Sat May 14 16:16:21 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/

#include "vehicaldirection_detection.h"
#include "vehicaldirection_detection_private.h"
/* Exported data definition */
/* Const memory section */
/* Definition for custom storage class: Const */
const int16_T LeftTurn_RoadSign = -120;/* Referenced by: '/Constant1' */
const int16_T Left_Turn_AngularLimit = -120;/* Referenced by: '/Constant2' */
const real_T RightTurn_RoadSign = 30.0;/* Referenced by: '/Constant' */
const int16_T Right_Turn_AngularLimit = 30;/* Referenced by: '/Constant' */

const real_T Straight_Drive_Steering_Angle = 0.0;/* Referenced by: '/Constant1' */
const int16_T Straight_RoadSign = 0; /* Referenced by: '/Constant2' */
/* External outputs (root outports fed by signals with default storage) */
ExtY_vehicaldirection_detecti_T vehicaldirection_detection_Y;
/* Real-time model */
static RT_MODEL_vehicaldirection_det_T vehicaldirection_detection_M_;
RT_MODEL_vehicaldirection_det_T *const vehicaldirection_detection_M =
&vehicaldirection_detection_M_;
/* Model step function */
void vehicaldirection_detection_step(void)
{
real_T rtb_Vehicle_Turn_Status;
/* Outputs for Atomic SubSystem: '/Subsystem' */
/* Switch: '/Switch1' incorporates:
* Constant: '/Constant2'
* Constant: '/Constant'
* Inport: '/SteeringWheel_YawDegreeInput'
* RelationalOperator: '/Compare'
*/
if (SteeringWheel_YawDegreeInput == 0) {
/* Switch: '/Switch' incorporates:
* Constant: '/Constant'
* Constant: '/Constant1'
* Constant: '/Constant'
* RelationalOperator: '/Compare'
*/
if (SteeringWheel_YawDegreeInput > 0) {
rtb_Vehicle_Turn_Status = Right_Turn_AngularLimit;
} else {
rtb_Vehicle_Turn_Status = Straight_Drive_Steering_Angle;
}
/* End of Switch: '/Switch' */
} else {
rtb_Vehicle_Turn_Status = Left_Turn_AngularLimit;
}
/* End of Switch: '/Switch1' */
/* Outport: '/Vehicle_Direction_Indicator' incorporates:
* Constant: '/Constant'
* Constant: '/Constant1'
* Constant: '/Constant2'
* Inport: '/CameraInput_RoadSign'
* Logic: '/AND'
* Logic: '/AND1'

Model Advisor Report:
The model advisor report following the MAAB,

go to model advisor select first option and choose system hierarchy. click on ok.

select modelling stand for MAB

after we perform MIL & SIL testing .

MIL : here we take a signal builder as input and components under testing is subsystem and ouput is outport and here before signal importing a data in singnal builder has two input associated stearing wheel yaw input and second cameraroad sign . its done importing a excel sheet data we get 3 inputs which is compared with ouputs .

similarly we done as sil test to perform just only diffrence is that change in block parameter setting kept as atomic and change the advance setting setting as software -Inloop testing.

SCOPE RESULT :

CONCLUSION :

Atonomous vehical driving assist the advance feature of vehical hence we create a model . we develpoed model as per MAB gauidelines and given requirents and also performs Model - inloop testing as well as Software in-loop testing.

NOTE - All Project Files Are included In Attached zip File.

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.