Challenge

Project 1 (Mini Project on Vehicle Direction Detection

AIM: To create the model Vehicle Direction Determination as per given requirements.

OBJECTIVES:

  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

THEORY:

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.

PROCEDURE:

* Create a Simulink model as shown below. Where, the Output shows

* Inside the "Vehicle_Direction_Detection" Subsystem, there are 2 more subsystems created as shown.

* Subsystem - Requirement_1:

- Steering wheel input as yaw rate (Signal name: SteeringWheel_YawDegreeInput) is the input for this system.

- It is compared against 3 angular values, one each for a left turn, right turn & straight drive i.e; 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 following the MAB guidelines for comparing and developing the logic for execution as shown below.

* Subsystem - Requirement_2:

- RoadSign signals are compared with the Vehicle_Turn_Status which is further compared with the logical and operator. The following signal is sent to 'Vehicle_Detection_Indicator' port.

- Go to and From blocks are used to follow the MAB guidlines.

* Tagging Requirement :

- The requirements asked is saved into a word file.

- Highlight the details which are to be linked in the word document, and right click the subsystem to be linked and go to requirements and select "link the selection from word".

* Add a new Simulink Data Dictionary and save data as shown below:

* Go to model properties and set the properties as shown below:

* Go to model advisor and select only modeling standards of MAB as shown below:

* Run the selected check and it will generate the report as shown below.

* Now going back to the simulink model, go to App tab and select embedded coder. Click on generate code which results in generating the code for the model desingned in the simulink.

-CODE:

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

#include "Mini_Project.h"
#include "Mini_Project_private.h"

/* Exported data definition */

/* Definition for custom storage class: ExportToFile */
boolean_T Vehicle_Direction_Indicator[3];/* '<S3>/Signal Conversion' */

/* ConstVolatile memory section */
/* Definition for custom storage class: ConstVolatile */
const volatile int16_T LeftTurn_RoadSign = -120;/* Referenced by: '<S3>/Constant1' */
const volatile int16_T Left_Turn_AngularLimit = -120;/* Referenced by: '<S2>/Constant1' */
const volatile int16_T RightTurn_RoadSign = 30;/* Referenced by: '<S3>/Constant' */
const volatile int16_T Right_Turn_AngularLimit = 30;/* Referenced by: '<S2>/Constant2' */
const volatile int16_T Straight_Drive_Steering_Angle = 0;/* Referenced by: '<S2>/Constant' */
const volatile int16_T Straight_RoadSign = 0;/* Referenced by: '<S3>/Constant2' */

/* Real-time model */
static RT_MODEL_Mini_Project_T Mini_Project_M_;
RT_MODEL_Mini_Project_T *const Mini_Project_M = &Mini_Project_M_;

/* Model step function */
void Mini_Project_step(void)
{
  /* local block i/o variables */
  int16_T Vehicle_Turn_Status;

  /* Switch: '<S2>/Switch1' incorporates:
   *  Constant: '<S4>/Constant'
   *  Constant: '<S5>/Constant'
   *  Inport: '<Root>/SteeringWheel_YawDegreeInput'
   *  RelationalOperator: '<S4>/Compare'
   *  RelationalOperator: '<S5>/Compare'
   *  Switch: '<S2>/Switch'
   */
  if (SteeringWheel_YawDegreeInput > 0) {
    /* Switch: '<S2>/Switch1' incorporates:
     *  Constant: '<S2>/Constant2'
     */
    Vehicle_Turn_Status = Right_Turn_AngularLimit;
  } else if (SteeringWheel_YawDegreeInput == 0) {
    /* Switch: '<S2>/Switch' incorporates:
     *  Constant: '<S2>/Constant'
     *  Switch: '<S2>/Switch1'
     */
    Vehicle_Turn_Status = Straight_Drive_Steering_Angle;
  } else {
    /* Switch: '<S2>/Switch1' incorporates:
     *  Constant: '<S2>/Constant1'
     *  Switch: '<S2>/Switch'
     */
    Vehicle_Turn_Status = Left_Turn_AngularLimit;
  }

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

  /* SignalConversion: '<S3>/Signal Conversion' incorporates:
   *  Constant: '<S3>/Constant'
   *  Constant: '<S3>/Constant1'
   *  Constant: '<S3>/Constant2'
   *  Inport: '<Root>/CameraInput_RoadSign'
   *  Logic: '<S3>/Logical Operator'
   *  Logic: '<S3>/Logical Operator1'
   *  Logic: '<S3>/Logical Operator2'
   *  RelationalOperator: '<S3>/Equal'
   *  RelationalOperator: '<S3>/Equal1'
   *  RelationalOperator: '<S3>/Equal2'
   */
  Vehicle_Direction_Indicator[0] = ((Vehicle_Turn_Status == RightTurn_RoadSign) &&
    CameraInput_RoadSign);
  Vehicle_Direction_Indicator[1] = ((Vehicle_Turn_Status == LeftTurn_RoadSign) &&
    CameraInput_RoadSign);
  Vehicle_Direction_Indicator[2] = ((Vehicle_Turn_Status == Straight_RoadSign) &&
    CameraInput_RoadSign);
}

/* Model initialize function */
void Mini_Project_initialize(void)
{
  /* (no initialization code required) */
}

/* Model terminate function */
void Mini_Project_terminate(void)
{
  /* (no terminate code required) */
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */

CONCLUSION:

Thus the model is created as per requirements mentioned, which is as per MAB guidlines and lastly a code is being generated for the model.

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.