Project 1 (Mini Project on Vehicle Direction Detection
Aim:- To create a Simulink model of Vehicle Direction Detection as per the given Requirement data.
Blocks used:- a) constant b) input c) output d) logical operator e) switch f) mux
Procedure:-
For requirement 1:- If the input is >=30 the vehicle will take the Right turn because the initial value is 30, else If the input is not equal to zero (~=0) the vehicle left_turn, else stright_drive (if the input is equal to zero).The input yaw rate is given to the middle port of the switch, and the threshold value is 30. If the input is greater than threshold value then the switch will takes the True condition (Right_Turn_AngularLimit) else false condition. In the second switch the threshold value is zero, if the threshold value is not equal to zero then the switch will takes the true condition (Left_Turn_AngularLimit) else takes the false condition (Sitight_Drive steering_Angle). This output from the second switch is given as a false condition to the first switch. And the output for the Requirement_1 is 'Vehicle_Turn_Status'.
For requirement 2:- it is compared that the "Vehicle_Turn_Status" (Output of Requirement_1) with "RoadSign" and an input signal from camera to get the Vehicle Direction indicaton.After comparision with "Vehicle_Turn_Status" if each of them is found equal, then each of the three corresponding output is compared against the camera input signal, by using the 'logical OR' Blocks will get the true case and to take only one among them as output, the 'Mux' block is used.And the final output from the Vehicle_Detection Model will indicates the vehicle_Direction indication.Next by adding the SLDD_file to the model and by loading the calibration values and input/output values are defined.By running the simulation will get the vehicle direction.
Result:-
- The signs are in the way that Right, Left and Straight respectively.
- As the output is boolean, If we get the output as (0,0,1), Then the vehicle is moving in the straight drive.
- After running the simulation, we can clearly see that the vehicle is moving the straight direction.
Conclusion:-
Autonomous vehicles consists of various Advance Driver-Assistance System (ADAS) features. Vehicle Driection Detection is one the features of the vehicles. Hence, created an Simulink model of Vehicle Direction Detection as per the Requirement data.
/*
* File: model.c
*
* Code generated for Simulink model 'model'.
*
* Model version : 1.1
* Simulink Coder version : 9.7 (R2022a) 13-Nov-2021
* C/C++ source code generated on : Sat Oct 8 15:10:20 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "model.h"
#include "rtwtypes.h"
/* Exported data definition */
/* Const memory section */
/* Definition for custom storage class: Const */
const int16_T LeftTurn_RoadSign = -120;/* Referenced by: '<S5>/Constant' */
const int16_T Left_Turn_AngularLimit = -120;/* Referenced by: '<S2>/Constant1' */
const int16_T RightTurn_RoadSign = 30; /* Referenced by: '<S4>/Constant' */
const int16_T Right_Turn_AngularLimit = 30;/* Referenced by: '<S2>/Constant' */
const int16_T Straight_Drive_Steering_Angle = 0;/* Referenced by: '<S2>/Constant2' */
const int16_T Straight_RoadSign = 0; /* Referenced by: '<S6>/Constant' */
/* External inputs (root inport signals with default storage) */
ExtU_model_T model_U;
/* External outputs (root outports fed by signals with default storage) */
ExtY_model_T model_Y;
/* Real-time model */
static RT_MODEL_model_T model_M_;
RT_MODEL_model_T *const model_M = &model_M_;
/* Model step function */
void model_step(void)
{
int16_T rtb_Switch;
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant'
* Constant: '<S2>/Constant2'
* Inport: '<Root>/SteeringWheel_YawDegreeInput'
* Switch: '<S2>/Switch1'
*/
if (model_U.SteeringWheel_YawDegreeInput >= 30.0) {
rtb_Switch = Right_Turn_AngularLimit;
} else if (model_U.SteeringWheel_YawDegreeInput != 0.0) {
/* Switch: '<S2>/Switch1' incorporates:
* Constant: '<S2>/Constant1'
*/
rtb_Switch = Left_Turn_AngularLimit;
} else {
rtb_Switch = Straight_Drive_Steering_Angle;
}
/* End of Switch: '<S2>/Switch' */
/* Outport: '<Root>/Vehicle_Direction_Indicator' incorporates:
* Constant: '<S4>/Constant'
* Constant: '<S5>/Constant'
* Constant: '<S6>/Constant'
* Inport: '<Root>/CameraInput_RoadSign'
* Logic: '<S3>/Logical Operator'
* Logic: '<S3>/Logical Operator1'
* Logic: '<S3>/Logical Operator2'
* RelationalOperator: '<S4>/Compare'
* RelationalOperator: '<S5>/Compare'
* RelationalOperator: '<S6>/Compare'
*/
model_Y.Vehicle_Direction_Indicator[0] = ((rtb_Switch == RightTurn_RoadSign) ||
model_U.CameraInput_RoadSign);
model_Y.Vehicle_Direction_Indicator[1] = ((rtb_Switch == LeftTurn_RoadSign) ||
model_U.CameraInput_RoadSign);
model_Y.Vehicle_Direction_Indicator[2] = ((rtb_Switch == Straight_RoadSign) ||
model_U.CameraInput_RoadSign);
}
/* Model initialize function */
void model_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void model_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
