Challenge

Project 1 (Mini Project on Vehicle Direction Detection

AIM - Identifying the direction of the vehicle using the camera inputs and Steering wheel input.

The objective of the 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 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

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 the 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 output signal (Signal Name: Vehicle_Direction_Indicator).

MODEL -

  • The block is the main block of the vehicle direction detection project, In this, we are giving two inputs namely steering wheel input and camera input with respect to road signs, and the final output is the Vehicle detection indicator.
  • The above blocks are inside the vehicle direction detection subsystem, which contains the requirement1 subsystem and requirement2 subsystem.

REQUIREMENT1-

  • Inside requirement1 block, as per the requirement1 given details,
  • 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.
  • Used switch blocks to compare & develop this requirement. Kept this requirement in a subsystem & the output of this requirement is a local signal (Signal Name: Vehicle_Turn_Status).

REQUIREMENT2 -

  • Inside requirement2 block, as per the requirement2 given details,
  • the Inputs to this requirement are a local signal output 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), using relational operator, if each of them is found equal, then each of the three corresponding output is compared against the camera input signal,
  • Using a logical OR operator block, output from relational operator and camera input is compared, and if any one of the inputs is true it will be sent to mux block and only one among them is finally given as output signal (Signal Name: Vehicle_Direction_Indicator).

Simulink data dictionary -

  • the input and output signals are specified in this SLDD with their datatype, min and max values defined.
  • the calibration values such as right turn left turn, straight drive steering angle, right turn road sign, left turn road sign, the straight road sign is been declared in the SLDD file with their initial values,datatype, storage class and min and max values .
  • These values will reflect while running the model.

REQUIREMENT TAGGING -

  • To Tag the requirement that the client gives us, requirements can be given in any form such as in word format, excel format, pdf format
  • In this question, the requirement was given directly on the website, so I have created a word document that contains the requirement details and I tagged them to my block.
  • In order to do requirement tagging, we have to open the requirement document that the client gave us and select the particular requirement.
  • after selecting the particular requirement, we have to come to the Simulink block where that selected requirement is implemented and right-click on that subsystems and go to requirements ----> link to selection in word.
  • In order to see the requirement, the client will go and right-click on that subsystem and go to requirements ---- tagged selection will appear there if he clicks on that, the document will open, with the requirement being selected.

CODE GENERATION -

  • In order to perform code generation, there are few steps to be done before generating a code.
  • we have set the substem as treat as an atomic system. to do that, we have to right click on the subsystem ----> block parameters -----> select treat as an atomic system.
  • The next step is to change the solver parameters, got to model properties and select the solver selection to fixed step.
  • In the dialogue block, we have to go to code generation and change the system target file to ert.tlc (embedded coder).

CODE -

/*
 * File: vehicle_direction_detection.c
 *
 * Code generated for Simulink model 'vehicle_direction_detection'.
 *
 * Model version                  : 1.3
 * Simulink Coder version         : 9.4 (R2020b) 29-Jul-2020
 * C/C++ source code generated on : Sat Sep 11 07:12:11 2021
 *
 * 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"

/* 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: '/Constant1' */
const int16_T RightTurn_RoadSign = 30; /* Referenced by: '/Constant' */
const int16_T Right_Turn_AngularLimit = 30;/* Referenced by: '/Constant' */
const int16_T Straight_Drive_Steering_Angle = 0;/* Referenced by: '/Constant2' */
const int16_T Straight_RoadSign = 0;   /* Referenced by: '/Constant2' */

/* External inputs (root inport signals with default storage) */
ExtU_vehicle_direction_detect_T vehicle_direction_detection_U;

/* 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)
{
  int16_T rtb_Vehicle_Turn_Status;

  /* Outputs for Atomic SubSystem: '/Vehicle_Direction_Detection' */
  /* Switch: '/Switch' incorporates:
   *  Constant: '/Constant'
   *  Constant: '/Constant2'
   *  Inport: '/SteeringWheel_YawDegreeInput'
   *  Switch: '/Switch1'
   */
  if (vehicle_direction_detection_U.SteeringWheel_YawDegreeInput >= 30.0) {
    rtb_Vehicle_Turn_Status = Right_Turn_AngularLimit;
  } else if (vehicle_direction_detection_U.SteeringWheel_YawDegreeInput != 0.0)
  {
    /* Switch: '/Switch1' incorporates:
     *  Constant: '/Constant1'
     */
    rtb_Vehicle_Turn_Status = Left_Turn_AngularLimit;
  } else {
    rtb_Vehicle_Turn_Status = Straight_Drive_Steering_Angle;
  }

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

  /* Outport: '/Vehicle_Direction_Indicator' incorporates:
   *  Constant: '/Constant'
   *  Constant: '/Constant1'
   *  Constant: '/Constant2'
   *  Inport: '/CameraInput_RoadSign'
   *  Logic: '/OR'
   *  Logic: '/OR1'
   *  Logic: '/OR2'
   *  RelationalOperator: '/Relational Operator'
   *  RelationalOperator: '/Relational Operator1'
   *  RelationalOperator: '/Relational Operator2'
   */
  vehicle_direction_detection_Y.Vehicle_Direction_Indicator[0] =
    ((rtb_Vehicle_Turn_Status == RightTurn_RoadSign) ||
     vehicle_direction_detection_U.CameraInput_RoadSign);
  vehicle_direction_detection_Y.Vehicle_Direction_Indicator[1] =
    ((rtb_Vehicle_Turn_Status == LeftTurn_RoadSign) ||
     vehicle_direction_detection_U.CameraInput_RoadSign);
  vehicle_direction_detection_Y.Vehicle_Direction_Indicator[2] =
    ((rtb_Vehicle_Turn_Status == Straight_RoadSign) ||
     vehicle_direction_detection_U.CameraInput_RoadSign);

  /* 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 ADVISOR -

RESULT -

MATLAB FILE - Click here

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.