Challenge

Project 1 (Mini Project on Vehicle Direction Detection

AIM - To Identify the direction of vehice using Simulink Model.

The given condition from above question is as follows ,

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

So by analyzing above conditions and by analyzing behaviour of signals, we created first subsystem according to the conditions.

Above model is made up of Inport , Constant , Switch , and Outport blocks.

Signal SteeringWheel_YawDegreeInput is the input for this Model.

3 angular values, one each for left turn, right turn & straight drive are compared using Switch Blocks.

Output of our model is Vehicle_Turn_Status, and this will become input of our second Subsystem.

The Conditions for second Model are as follows ,

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

Above block is made of Inport,Constant,Outport,Logical Operators.

Vehicle_Turns_Status is Compared with RightTurn,LeftTurn and Straight_RodSign then signal CamaeraInput_RoadSide.

Then we Tagged 1 & 2 requirements

For this we developed SLDD File according the given conditions of Signals & Calibration Data .

Signals & Calibration Data List:

Signal / Calibration Name

Signal Type

Data Type

Dimension

Min

Max

Initial Value

Units

SteeringWheel_YawDegreeInput

Input

Int16

1

-180

180

-

Deg

CameraInput_RoadSign

Input

Boolean

1

0

1

-

-

Vehicle_Turn_Status

Local

Int16

1

-180

180

-

Deg

Right_Turn_AngularLimit

Calibration

Int16

[1 1]

-180

180

30

Deg

Left_Turn_AngularLimit

Calibration

Int16

[1 1]

-180

180

-120

Deg

Straight_Drive_Steering_Angle

Calibration

Int16

[1 1]

-180

180

0

Deg

RightTurn_RoadSign

Calibration

Int16

[1 1]

-180

180

30

LeftTurn_RoadSign

Calibration

Int16

[1 1]

-180

180

-120

Straight_RoadSign

Calibration

Int16

[1 1]

-180

180

0

Vehicle_Direction_Indicator

Output

Boolean

1

0

1

-

-

RESULT -

After connecting one subsystem to another as a input & combining them in a subsystem we get a model as follows,

Then we generated c code for this model ,

/*
 * File: Mini_Project.c
 *
 * Code generated for Simulink model 'Mini_Project'.
 *
 * Model version                  : 1.1
 * Simulink Coder version         : 9.5 (R2021a) 14-Nov-2020
 * C/C++ source code generated on : Tue Dec  7 21:38:53 2021
 *
 * 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"

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

/* 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)
{
  int32_T rtb_Switch;

  /* Switch: '<S2>/Switch' incorporates:
   *  Constant: '<S2>/Right_Turn_AngularLimit'
   *  Constant: '<S2>/Straight_Drive_Steering_AngleLimit'
   *  Inport: '<Root>/SteeringWheel_YawDegreeInput'
   *  Switch: '<S2>/Switch1'
   */
  if (SteeringWheel_YawDegreeInput > 0) {
    rtb_Switch = 30;
  } else if (SteeringWheel_YawDegreeInput > 0) {
    /* Switch: '<S2>/Switch1' incorporates:
     *  Constant: '<S2>/Left_Turn_AngularLimit'
     */
    rtb_Switch = -120;
  } else {
    rtb_Switch = 0;
  }

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

  /* Outport: '<Root>/Vehicle_Direction_Indicator' incorporates:
   *  Constant: '<S3>/LeftTurn_RoadSign'
   *  Constant: '<S3>/RightTurn_RoadSign'
   *  Constant: '<S3>/Straight_RoadSign'
   *  Inport: '<Root>/CameraInput_RoadSign'
   *  Logic: '<S3>/Logical Operator'
   *  Logic: '<S3>/Logical Operator1'
   *  Logic: '<S3>/Logical Operator2'
   *  Logic: '<S3>/Logical Operator3'
   *  RelationalOperator: '<S3>/Equal'
   *  RelationalOperator: '<S3>/Equal1'
   *  RelationalOperator: '<S3>/Equal2'
   */
  Mini_Project_Y.Vehicle_Direction_Indicator = ((CameraInput_RoadSign && (30 ==
    rtb_Switch)) || ((rtb_Switch == -120) && CameraInput_RoadSign) ||
    (CameraInput_RoadSign && (rtb_Switch == 0)));
}

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

The all related files are uploaded below.

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.