Challenge

Project 1 - Vehicle Direction Detection

QUESTION

Mini Project – Vehicle Direction Determination

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.

Objective of Mini Project:

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

Requirement - 1:

  • Steering wheel input as yaw rate (Signal name: SteeringWheel_YawDegreelnput) 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 isturning 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 localsignal from requirement 1 (Signal Name: Vehicle_Turn_Status) & an input signal from camera (Signal Name: Cameralnput_Roadsign), which confirms the occurrence of aroad sign.
  • Signal Vehicle_Turn_Status is compared against calibration values (CalibrationValues: 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 (signal Name: Vehicle_Direction_Indicator).

ANSWER

# Aim

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

# General Overview

ADAS – Advanced Driver Assistance Systems

Vehicle Direction Detection

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 into its memory with unique values for the 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.

# Designing the MATLAB Simulink Model

The Overall Simulink model for Vehicle Direction Detection: -

The Subsystem of the main model: -

Subsystem 1 - Requirement 1

  • Steering wheel input as yaw rate (Signal name: SteeringWheel_YawDegreelnput) 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 isturning 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).

Subsystem 2 - Requirement 2

  • Keep this requirement as a separate subsystem. Inputs to this requirement are localsignal from requirement 1 (Signal Name: Vehicle_Turn_Status) & an input signal from camera (Signal Name: Cameralnput_Roadsign), which confirms the occurrence of aroad sign.
  • Signal Vehicle_Turn_Status is compared against calibration values (CalibrationValues: 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 (signal Name: Vehicle_Direction_Indicator).

Blocks used

Blocks used to create a model are

  1. Input Blocks: To provide the input signals.
  2. Output Blocks: To send the output signals.
  3. Constant Blocks: To define the calibration values.
  4. Logical operator Blocks: OR blocks are used to compare and the road signs with camera input and to get the Boolean output.
  5. Switch Blocks: To compare the input with the calibration values.
  6. Mux Block: To combine the signals.
  7. Display Block: To display the results.

# Procedure

  1. Requirement Tagging with the model

All the requirements are tagged in order for better understandability, 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 are tagged and the description.

Requirement-1

Requirement-2

  1. Developing SLDD and linking with model

All the input signals, output signals, calibration parameters are saved in SLDD so while simulation, the model takes all the values and its parameters from the Simulink Data Dictionary file. The signals and parameters are assigned the values as mentioned in the question itself.

  1. Signal resolution and Propagation

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

  1. Model update and Simulation

The Model update is done by CTRL+D. this is done to check for any static errors. If there are no errors, then the model is working fine.

  1. Changes in Configuration parameters for simulation and code generation

Right-click on main subsystem -> Block parameters(subsystem) -> Tick on Treat as atomic size -> model configuration-> solver (fixed step) -> sample time (0.01) -> code generation -> ert.tlc -> app (Embedded code) -> build (generate code).

# Results and Discussion

Simulation Analysis

After simulation of the model, the following results are appearing in the Display block which is connected to check whether the model is working as per the requirement or not:

Right Turn

Here the output of the display block is denoting that the Right Turn is executed which is because the initial value of the input signal SteeringWheel_YawDegreeInput is taken as 30 in the SLDD as shown below:

Left Turn

Straight Drive

As the output is boolean, if we get output as (1,0,0) then the vehicle is taking Right Turn. If the output is (0,1,0) then the vehicle is taking Left Turn. If the output is (0,0,1) then the vehicle is in Straight Drive.

Code Generation

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

/*

 * File: Vehicle_direction_detection.c

 *

 * Code generated for Simulink model 'Vehicle_direction_detection'.

 *

 * Model version                  : 1.44

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

 * C/C++ source code generated on : Wed Apr 13 14:44:49 2022

 *

 * Target selection: ert.tlc

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

 * Code generation objectives: Unspecified

 * Validation result: Not run

 */



#include "Vehicle_direction_detection.h"

#include "Vehicle_direction_detection_private.h"



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

ExtY_Vehicle_direction_detect_T Vehicle_direction_detection_Y;



/* Real-time model */

static RT_MODEL_Vehicle_direction_de_T Vehicle_direction_detection_M_;

RT_MODEL_Vehicle_direction_de_T *const Vehicle_direction_detection_M =

  &Vehicle_direction_detection_M_;



/* Model step function */

void Vehicle_direction_detection_step(void)

{

  int32_T rtb_Vehicle_Turn_Status;



  /* Outputs for Atomic SubSystem: '/Vehicle_Direction_Detection' */

  /* Switch: '/Switch' incorporates:

   *  Constant: '/RightTurn_AngularLimit'

   *  Constant: '/StraightDrive_SteeringAngle'

   *  Inport: '/SteeringWheel_YawDegreeInput'

   *  Switch: '/Switch1'

   */

  if (SteeringWheel_YawDegreeInput > 0) {

    rtb_Vehicle_Turn_Status = 30;

  } else if (SteeringWheel_YawDegreeInput != 0) {

    /* Switch: '/Switch1' incorporates:

     *  Constant: '/LeftTurn_AngularLimit'

     */

    rtb_Vehicle_Turn_Status = -120;

  } else {

    rtb_Vehicle_Turn_Status = 0;

  }



  /* End of Switch: '/Switch' */



  /* Outport: '/Vehicle_Direction_Indicator' incorporates:

   *  Constant: '/LeftTurn_RoadSign'

   *  Constant: '/RightTurn_RoadSign'

   *  Constant: '/StarightDrive_RoadSign'

   *  Inport: '/CameraInput_RoadSign'

   *  Logic: '/AND1'

   *  Logic: '/AND2'

   *  Logic: '/AND3'

   *  RelationalOperator: '/Relational Operator'

   *  RelationalOperator: '/Relational Operator1'

   *  RelationalOperator: '/Relational Operator2'

   */

  Vehicle_direction_detection_Y.Vehicle_Direction_Indicator[0] =

    (CameraInput_RoadSign || (rtb_Vehicle_Turn_Status == 30));

  Vehicle_direction_detection_Y.Vehicle_Direction_Indicator[1] =

    (CameraInput_RoadSign || (rtb_Vehicle_Turn_Status == -120));

  Vehicle_direction_detection_Y.Vehicle_Direction_Indicator[2] =

    (CameraInput_RoadSign || (rtb_Vehicle_Turn_Status == 0));



  /* End of Outputs for SubSystem: '/Vehicle_Direction_Detection' */

}



/* Model initialize function */

void Vehicle_direction_detection_initialize(void)

{

  /* (no initialization code required) */

}



/* Model terminate function */

void Vehicle_direction_detection_terminate(void)

{

  /* (no terminate code required) */

}



/*

 * File trailer for generated code.

 *

 * [EOF]

 */

# Model Advisory Report

The model advisor report following the MAAB, JMAAB and MISRA C guidelines is shown below: -

# Conclusion

The model corresponding to Vehicle Direction Detection is successfully implemented. All the complaint changes pertaining to MBD, requirement tagging, linking of the model to SLDD, Code generation and ultimately generation of the Model Advisor Report is presented with detailed analysis.

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.