Challenge

Project 1 (Mini Project on Vehicle Direction Detection

Project-1 (Mini Project on Vehicle Direction Detection)

Objective:

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

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

-

-

Overall model for vehicle direction detection:

Vehicle_Direction_Logic subsystem:

Requirement 1:

Requirement 2:

SLDD File creation:

Initially all the input,output signals,calibration values should be get declared for their datatypes,values,storage classes,dimensions,minimum & maximum values and units and link with the model to get access when the model gets simulated.

After declared all the datas in the SLDD file it looks like as shown below,

Working of model:

Requirement 1-

The steering yaw rate degree is compared with the three different cases with switch blocks in Requirement1 subsystem as,

  • If the steering yaw degree is greater than or equal to 30 degree,the output from switch is given by the 'Right_Turn_AngularLimit' value assigned in SLDD file.
  • If steering yaw degree is less than 30 degree means,the system goes for another comparision with Switch1 for not equal to 0.
  • If the steering angle is not equal to 0 means the output from switch as 'Left_Turn_AngularLimit' value as given in model.
  • If the steering angle is equal to zero means the output from switch as 'Straight_Drive_Steering_Angle'.

Requirement 2-

The output from requirement1 subsystem is compared with the camera Right_Turn_Roadsign,Left_Turn_Roadsign and Straight_Road sign with relational operator(==) and the output from all three relational operators are given to three logical AND blocks for getting the corrent output sign as Vehicle_Direction_Indicator sign.

These outputs are displayed in display block as,

Signals resolving:

Here the primary input signals,SteeringWheel_YawDegreeInput and CameraInput_RoadSign are resolved from the SLDD file created by configuring as shown below,

Signal Propagation:

The propagation of these input signal into the subsystems are shown as,

Like this we can propagate the primary signals over any section of the models.

Model Advisor check:

Here its checked for the MAB,JMAB and MISRA C2012 standards using model advisor check tool.

The results are as shown below,

The report is attachrd with this project submission.

Requirement Tagging:

Here both requirement subsystems are tagged with the excel sheet as shown below,

The file is attached with this drive link:https://docs.google.com/spreadsheets/d/1Au5Gs3I_bT8rtvs58gxPTL4UECsCv3Ra/edit?usp=sharing&ouid=115154767933413412680&rtpof=true&sd=true

Results:

For 45 degree steering yaw angle:

The streering yaw degree given by initial value 45 degree,the result on vehicle direction indicator as,

From above result we can see that the Right_Turn indication is activated as 1.

For -120 degree steering yaw angle:

The steering yaw angle given as -120 degree.

The vehicle direction indication result shown as,

The Left_Turn indication gets activated as 1 and remaining signs are get 0.

For 0 degree steering yaw angle:

Now the steering angle changed to 0 degree.

It compared with camera sign correctly to get result for straight_Road driving as,

The Straight ride indication gets activated as 1 and other two get as 0.

Thus from these results we had justified our logic for vehicle direction detection based on steering yaw degree and from camera input signs.

Code generation:

The embedded code of C gets created as shown below,

*
* File: Vehicle_Direction_Logic.c
*
* Code generated for Simulink model 'Vehicle_Direction_Logic'.
*
* Model version : 1.23
* Simulink Coder version : 9.4 (R2020b) 29-Jul-2020
* C/C++ source code generated on : Fri Oct 8 11:13:50 2021
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/

#include "Vehicle_Direction_Logic.h"
#include "Vehicle_Direction_Logic_private.h"

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

/* Real-time model */
static RT_MODEL_Vehicle_Direction_Lo_T Vehicle_Direction_Logic_M_;
RT_MODEL_Vehicle_Direction_Lo_T *const Vehicle_Direction_Logic_M =
&Vehicle_Direction_Logic_M_;

/* Model step function */
void Vehicle_Direction_Logic_step(void)
{
int16_T rtb_Switch;

/* Outputs for Atomic SubSystem: '/Vehicle_Direction_Logic' */
/* Switch: '/Switch' incorporates:
* Constant: '/Constant'
* Constant: '/Constant2'
* Inport: '/In1'
* Switch: '/Switch1'
*/
if (SteeringWheel_YawDegreeInput >= 30) {
rtb_Switch = Right_Turn_AngularLimit;
} else if (SteeringWheel_YawDegreeInput != 0) {
/* Switch: '/Switch1' incorporates:
* Constant: '/Constant1'
*/
rtb_Switch = Left_Turn_AngularLimit;
} else {
rtb_Switch = Straight_Drive_Steering_Angle;
}

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

/* Outport: '/Vehicle_Direction_Indicator' incorporates:
* Constant: '/Constant'
* Constant: '/Constant1'
* Constant: '/Constant2'
* Inport: '/In2'
* Logic: '/AND'
* Logic: '/AND1'
* Logic: '/AND2'
* RelationalOperator: '/Relational Operator'
* RelationalOperator: '/Relational Operator1'
* RelationalOperator: '/Relational Operator2'
*/
Vehicle_Direction_Logic_Y.Vehicle_Direction_Indicator[0] = ((rtb_Switch ==
RightTurn_RoadSign) && CameraInput_RoadSign);
Vehicle_Direction_Logic_Y.Vehicle_Direction_Indicator[1] = ((rtb_Switch ==
LeftTurn_RoadSign) && CameraInput_RoadSign);
Vehicle_Direction_Logic_Y.Vehicle_Direction_Indicator[2] = ((rtb_Switch ==
Straight_RoadSign) && CameraInput_RoadSign);

/* End of Outputs for SubSystem: '/Vehicle_Direction_Logic' */
}

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

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

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

Note: Model file,sldd file,madel advisor report are attached with this submission.

Thank you

Submitted by,

Praveen Kumar L V,

Date:8/10/2021.

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.