Challenge

Project 1 (Mini Project on Vehicle Direction Detection

Project: Vehicle Direction Determination

Aim: Develop a MATLAB Simulink model to determine the direction of a vehicle based on camera input.

Description: The system compares the yaw rate of the steering wheel with predefined angular values for left turn, right turn, and straight drive. It also considers input from a camera to detect road signs. By using switch and logical operator blocks, the system determines the vehicle's direction and provides a direction indicator.

Model: The MATLAB Simulink model consists of two subsystems: one for steering wheel input comparison and another for road sign comparison.

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

Execution:

In Requirment 1 SteeringWheel_YawDegreeInput is compeard with all three Calibration values. In first switch block if the input value id greter thea 30, then output Vehicle_Turn_Status is become 30. If the input value is equal to zero then the switch 2 is get active and the Vehicle_Turn_Status value is become 0.

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

Execution:

In Requirment 2 Vehicle_Turn_Status value is compeard with all three Calibration values. After that the value is compaired with camera input signal using AND Gate. So here if both input signels is High the AND gate give the output signal High. Using OR gate we transfer that signal to the output.

Signal Propogation :-

Requirement Taging :

SLDD creation:

Model Settings:

Model Advisor Report Ganeration:

Code Ganeration Report:

Code :-

/*
* Event Support License -- for demonstration use and event support. Not
* for government, research, commercial, or other organizational use.
*
* File: Project_1.c
*
* Code generated for Simulink model 'Project_1'.
*
* Model version : 1.10
* Simulink Coder version : 9.9 (R2023a) 19-Nov-2022
* C/C++ source code generated on : Tue Jul 4 20:21:49 2023
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "Project_1.h"
#include "rtwtypes.h"
#include "Project_1_private.h"
#include "Project_1__Function.h"
/* Exported data definition */
/* Const memory section */
/* Definition for custom storage class: Const */
const int16_T LeftTurn_RoodSign = -120;/* Referenced by: '<S1>/Constant1' */
const int16_T Left_Turn_AngularLimit = -120;/* Referenced by: '<S2>/Constant1' */
const int16_T RightTurn_RoodSign = 30; /* Referenced by: '<S1>/Constant' */
const int16_T Right_Turn_AngularLimit = 30;/* Referenced by: '<S2>/Constant' */
const int16_T Straight_RoodSign = 0; /* Referenced by: '<S1>/Constant2' */
const int16_T Straith_Drive_Steering_Angle = 0;/* Referenced by: '<S2>/Constant2' */
/* Real-time model */
static RT_MODEL_Project_1_T Project_1_M_;
RT_MODEL_Project_1_T *const Project_1_M = &Project_1_M_;
/* Model step function */
void Project_1_step(void)
{
/* local block i/o variables */
int16_T Vehical_Turn_Status;
/* Switch: '<S2>/Switch' incorporates:
* Inport: '<Root>/Steeringwheel_YawDegreeInput'
* Switch: '<S2>/Switch1'
*/
if (Steeringwheel_YawDegreeInput > 30) {
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant'
*/
Vehical_Turn_Status = Right_Turn_AngularLimit;
} else if (Steeringwheel_YawDegreeInput >= 0) {
/* Switch: '<S2>/Switch1' incorporates:
* Constant: '<S2>/Constant2'
* Switch: '<S2>/Switch'
*/
Vehical_Turn_Status = Straith_Drive_Steering_Angle;
} else {
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant1'
* Switch: '<S2>/Switch1'
*/
Vehical_Turn_Status = Left_Turn_AngularLimit;
}
/* End of Switch: '<S2>/Switch' */
/* Logic: '<S1>/Logical Operator3' incorporates:
* Constant: '<S1>/Constant'
* Constant: '<S1>/Constant1'
* Constant: '<S1>/Constant2'
* Inport: '<Root>/CameraInput_RoadSign'
* Logic: '<S1>/Logical Operator'
* Logic: '<S1>/Logical Operator1'
* Logic: '<S1>/Logical Operator2'
* RelationalOperator: '<S1>/Equal'
* RelationalOperator: '<S1>/Equal1'
* RelationalOperator: '<S1>/Equal2'
*/
Vehical_Direction_Indicator = (((Vehical_Turn_Status == RightTurn_RoodSign) &&
CameraInput_RoadSign) || ((Vehical_Turn_Status == LeftTurn_RoodSign) &&
CameraInput_RoadSign) || ((Vehical_Turn_Status == Straight_RoodSign) &&
CameraInput_RoadSign));
}
/* Model initialize function */
void Project_1_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void Project_1_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/

Result: The developed model accurately determines the vehicle's direction based on camera input and steering wheel yaw rate. It can be integrated with other driver assistance features and enhance overall driving safety.

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.