Challenge

Project 1 (Mini Project on Vehicle Direction Detection

Aim: To create simulink Model and simulink Data dictionary for Vehicle direction detection.

Requirement 1: Determing the vehicle direction using steering wheel input as yaw rate which is input to the system . Yaw rate input is then compared against 3 angular values one for each right turn, left turn & straight drive and corrosponding calibration values are Right_Turn_AngularLimit, Left_Turn_AngularLimit & Straight_Drive_Steering_Angle respectively. Depending on these calibrations turning of steering wheel to which specific direction is determined. The output for this system will be the Vehicle_Turn_Status.

Simulink Model for Requirement1:

diagram1 : subsystem : Vehicle_Turn_Status

input : SteeringWheel_YawDegreeinput 

output: Vehicle_Turn_Status

Diagram 2: Inside subsystem,

Pseudo code:

if (SteeringWheel_YawDegreeInput>0)

       Right_Turn_AngularLimit = 30

else( SteeringWheel_YawDegreeInput <=0)

        if ( SteeringWheel_YawDegreeInput ==0)

              Straight_Drive_Steering_angle=0

        else(SteeringWheel_YawDegreeInput < 0)

                 Left_Turn_AngularLimit =-120

Requirement 2: Create another subsystem which has 2 input , where one input is from previous requirement signal output i.e Vehicle_Turn_Status along with another input from camera i.e CameraInput_RoadSign, which confirms the occurence road sign. Signal Vehicle_Turn_Status is compared against the Road signs i.e RightTurn_RoadSign, LeftTurn_RoadSign,Straight_RoadSign. If each of the them when compared to their corrosponsding road sign matches then the corrosponsing output is compared against camera input signal and the output of this is Vehicle_Direction_Indicator.

Simulink Model for Requirement2:

Diagram 3: Subsystem : Road_Sign

Input : a) Vehicle_Turn_Status b) CameraInput_RoadSign

output: Vehicle_Direction_Indicator

Diagram 4: 

Psuedo Code:

if(Vehicle_Turn_Status == RightTurn_RoadSign && CameraInput_RoadSign)

        Right Turn =1;

        Left Turn = 0;

        straight Turn = 0;

elseif (Vehicle_Turn_Status = LeftTurn_RoadSign && CameraInput_RoadSign) 

        Right Turn =0;

        Left Turn = 1;

        straight Turn = 0;

else 

        Right Turn =0;

        Left Turn = 0;

        straight Turn = 1;

Final Model: 

SLDD: 

 

I have used MatlabR2015 version so here i dont have any variable as localizable so i have assigned Vehicle_Turn_Status to Simulink Global and it works fine.

Output:

Case 1: SteeringWheel_YawDegreeInput= 10 && CameraInput_RoadSign =1.

Case 2: SteeringWheel_YawDegreeInput= 0 && CameraInput_RoadSign =1.

 Case3: SteeringWheel_YawDegreeInput= -5 && CameraInput_RoadSign =1.

Case 4: SteeringWheel_YawDegreeInput= 10 && CameraInput_RoadSign =0. whenever the CameraInput_RoadSign =0 , what ever the input is of SteeringWheel_YawDegreeInput, inthat case there is no turning.

 C code generation:

/*
* File: Vehicle_Direction_Detection.c
*
* Code generated for Simulink model 'Vehicle_Direction_Detection'.
*
* Model version : 1.16
* Simulink Coder version : 8.8 (R2015a) 09-Feb-2015
* C/C++ source code generated on : Sun Feb 13 16:33:33 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: 32-bit Generic
* Code generation objectives: Unspecified
* Validation result: Not run
*/

#include "Vehicle_Direction_Detection.h"
#include "Vehicle_Direction_Detection_private.h"

/* Exported data definition */

/* ConstVolatile memory section */
/* Definition for custom storage class: ConstVolatile */
const volatile int16_T LeftTurn_RoadSign = -120;
const volatile int16_T RightTurn_RoadSign = 30;
const volatile int16_T Straight_RoadSign = 0;

/* Block signals (auto storage) */
B_Vehicle_Direction_Detection_T Vehicle_Direction_Detection_B;

/* External outputs (root outports fed by signals with auto storage) */
ExtY_Vehicle_Direction_Detect_T Vehicle_Direction_Detection_Y;

/* Real-time model */
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)
{
/* Switch: '/Switch' incorporates:
* Constant: '/Right_Turn_AngularLimit'
* Constant: '/Straight_Drive_Steering_Angle'
* Inport: '/SteeringWheel_YawDegreeInput'
* Switch: '/Switch1'
*/
if (SteeringWheel_YawDegreeInput >
Vehicle_Direction_Detection_P.Switch_Threshold) {
Vehicle_Direction_Detection_B.Vehicle_Turn_Status =
Vehicle_Direction_Detection_P.Right_Turn_AngularLimit_Value;
} else if (SteeringWheel_YawDegreeInput != 0) {
/* Switch: '/Switch1' incorporates:
* Constant: '/Left_Turn_AngularLimit'
*/
Vehicle_Direction_Detection_B.Vehicle_Turn_Status =
Vehicle_Direction_Detection_P.Left_Turn_AngularLimit_Value;
} else {
Vehicle_Direction_Detection_B.Vehicle_Turn_Status =
Vehicle_Direction_Detection_P.Straight_Drive_Steering_Angle_V;
}

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

/* Outport: '/Vehicle_Direction_Indicator' incorporates:
* Constant: '/Constant'
* Constant: '/Constant'
* Constant: '/Constant'
* Inport: '/CameraInput_RoadSign'
* Logic: '/Left'
* Logic: '/Right'
* Logic: '/Straight'
* RelationalOperator: '/Compare'
* RelationalOperator: '/Compare'
* RelationalOperator: '/Compare'
*/
Vehicle_Direction_Detection_Y.Vehicle_Direction_Indicator[0] =
((Vehicle_Direction_Detection_B.Vehicle_Turn_Status == RightTurn_RoadSign) &&
CameraInput_RoadSign);
Vehicle_Direction_Detection_Y.Vehicle_Direction_Indicator[1] =
((Vehicle_Direction_Detection_B.Vehicle_Turn_Status == LeftTurn_RoadSign) &&
CameraInput_RoadSign);
Vehicle_Direction_Detection_Y.Vehicle_Direction_Indicator[2] =
((Vehicle_Direction_Detection_B.Vehicle_Turn_Status == Straight_RoadSign) &&
CameraInput_RoadSign);
}

/* Model initialize function */
void Vehicle_Direction_Detection_initialize(void)
{
/* Registration code */

/* initialize error status */
rtmSetErrorStatus(Vehicle_Direction_Detection_M, (NULL));

/* block I/O */
(void) memset(((void *) &Vehicle_Direction_Detection_B), 0,
sizeof(B_Vehicle_Direction_Detection_T));

/* external outputs */
(void) memset(&Vehicle_Direction_Detection_Y.Vehicle_Direction_Indicator[0], 0,
3U*sizeof(boolean_T));
}

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

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

Model Advisory Report:

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.