Project 1 (Mini Project on Vehicle Direction Detection
1. Introduction
Objective:
The objective of this project is to develop a MATLAB Simulink model to determine the direction of a vehicle based on steering wheel input and road signs detected by a camera. This feature is critical for autonomous driving and advanced driver assistance systems (ADAS), enabling the vehicle to provide feedback to the driver regarding their driving direction.
Application Overview
Application:
The Vehicle Direction Determination system is designed to:
- Read steering wheel input as a yaw rate.
- Compare this input against predefined angular limits to determine if the vehicle is turning left, turning right, or driving straight.
- Verify the determined direction against road signs detected by a camera.
- Output an indicator to inform the driver if they are following the recommended direction based on road signs.
Integration:
This system can be integrated with other ADAS features like GPS systems for optimized routing, lane detection, highway warnings, and wrong-way detection at ramps.
System Requirements
Inputs:
- `SteeringWheel_YawDegreeInput`: The yaw rate of the steering wheel.
- `CameraInput_RoadSign`: A signal indicating the presence of road signs.
Calibration Parameters:
- `Right_Turn_AngularLimit`
- `Left_Turn_AngularLimit`
- `Straight_Drive_Steering_Angle`
- `RightTurn_RoadSign`
- `LeftTurn_RoadSign`
- `Straight_RoadSign`
Outputs:
- `Vehicle_Turn_Status`: Indicates the determined direction based on steering input.
- `Vehicle_Direction_Indicator`: Indicates whether the vehicle is following the recommended direction based on road signs.
Model Design
Subsystem 1: `Direction_Detection`
Purpose: Determines the direction the vehicle is turning based on the steering wheel input.
Components:
Input:
`SteeringWheel_YawDegreeInput`
Constants:
- `Right_Turn_AngularLimit`
- `Left_Turn_AngularLimit`
- `Straight_Drive_Steering_Angle`
Relational Operator Blocks:
Compare the yaw input against the angular limits.
Switch Blocks:
Determine the status of the vehicle turn based on the comparisons.
Output:
`Vehicle_Turn_Status`
Subsystem 2: `Direction_Indicator`
Purpose: Verifies the determined vehicle direction against road signs detected by the camera.
Components:
Inputs:
- `Vehicle_Turn_Status`
- `CameraInput_RoadSign`
Constants:
- `RightTurn_RoadSign`
- `LeftTurn_RoadSign`
- `Straight_RoadSign`
Relational Operator Blocks:
Compare `Vehicle_Turn_Status` with road sign constants.
Logical Operator Blocks:
Determine the final direction indicator based on comparisons.
Output:
`Vehicle_Direction_Indicator`
Implementation Steps
Step 1:
Create the Simulink Model
- Create a new Simulink model and save it as `VehicleDirectionDetermination`.
Step 2:
Define Signals and Parameters
- Initialize calibration parameters and input signals in the MATLAB workspace.
Step 3:
Build `Direction_Detection` Subsystem
- Add and configure blocks as per the design to determine the vehicle turn status.
Step 4:
Build `Direction_Indicator` Subsystem
- Add and configure blocks to verify vehicle direction against camera input.
Step 5:
Connect Subsystems
- Connect the subsystems in the main model, ensuring proper signal flow and data types.
Step 6:
Set Model Configuration Parameters
- Set the sample time to 0.01 seconds.
- Configure data types and initial values for all signals and parameters.
Step 7:
Verify and Run Simulation
- Check the model for errors.
- Run simulations to ensure the model behaves as expected with different input scenarios.
Generated Code :
/*
* File: Project_on_Vehicle_Direction_Detection.c
*
* Code generated for Simulink model 'Project_on_Vehicle_Direction_Detection'.
*
* Model version : 1.12
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Wed Oct 13 22:09:11 2021
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "Project_on_Vehicle_Direction_Detection.h"
#include "Project_on_Vehicle_Direction_Detection_private.h"
/* Real-time model */
static RT_MODEL_Project_on_Vehicle_D_T Project_on_Vehicle_Direction_M_;
RT_MODEL_Project_on_Vehicle_D_T *const Project_on_Vehicle_Direction_M =
&Project_on_Vehicle_Direction_M_;
/* Model step function */
void Project_on_Vehicle_Direction_Detection_step(void)
{
int32_T rtb_Vehicle_Turn_Status;
/* Switch: '<S3>/Switch' incorporates:
* Constant: '<S3>/Left_Turn_AngularLimit'
* Constant: '<S3>/Right_Turn_AngularLimit'
* Inport: '<Root>/SteeringWheel_YawDegreeInput'
* Switch: '<S3>/Switch1'
*/
if (SteeringWheel_YawDegreeInput > 25) {
rtb_Vehicle_Turn_Status = 30;
} else if (SteeringWheel_YawDegreeInput > 0) {
/* Switch: '<S3>/Switch1' incorporates:
* Constant: '<S3>/Straight_Drive_Steering_Angle'
*/
rtb_Vehicle_Turn_Status = 0;
} else {
rtb_Vehicle_Turn_Status = -120;
}
/* End of Switch: '<S3>/Switch' */
/* Logic: '<S2>/OR' incorporates:
* Constant: '<S2>/LeftTurn_RoadSign'
* Constant: '<S2>/RightTurn_RoadSign'
* Constant: '<S2>/Straight_RoadSign'
* Inport: '<Root>/CameraInput_RoadSign'
* Logic: '<S2>/Logical Operator'
* Logic: '<S2>/Logical Operator1'
* Logic: '<S2>/Logical Operator3'
* RelationalOperator: '<S2>/Relational Operator'
* RelationalOperator: '<S2>/Relational Operator1'
* RelationalOperator: '<S2>/Relational Operator2'
*/
Vehicle_Direction_Indicator = ((CameraInput_RoadSign &&
(rtb_Vehicle_Turn_Status == 30)) || (CameraInput_RoadSign &&
(rtb_Vehicle_Turn_Status == -120)) || (CameraInput_RoadSign &&
(rtb_Vehicle_Turn_Status == 0)));
}
/* Model initialize function */
void Project_on_Vehicle_Direction_Detection_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void Project_on_Vehicle_Direction_Detection_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*//*
* File trailer for generated code.
*
* [EOF]
*/
6. Expected Outputs
Vehicle_Turn_Status:
- Indicates `30` (degrees) for a right turn.
- Indicates `-120` (degrees) for a left turn.
- Indicates `0` (degrees) for straight driving.
Vehicle_Direction_Indicator:
- Outputs `1` (true) if the vehicle is following the direction indicated by the road sign.
- Outputs `0` (false) if the vehicle is not following the indicated direction.
7. Conclusion
The Vehicle Direction Determination system effectively identifies the direction of the vehicle using steering wheel input and camera-detected road signs. By integrating this system with other ADAS features, the vehicle can provide comprehensive feedback and warnings to the driver, enhancing safety and navigation accuracy.
8. Future Enhancements
- Integration with GPS: Use GPS data to further refine direction determination and optimize routes.
- Advanced Lane Detection: Combine with lane detection algorithms to enhance road safety.
- Real-time Calibration: Implement dynamic calibration adjustments based on real-time driving conditions.