Vehicle Direction Detection
Mini Project - Vehicle Direction Determination
Aim: To determine the direction of the vehicle in Simulink based on the requirements.
Objectives:
- Development of MATLAB Simulink model as per requirement.
- Tag the requirements to the Simulink model.
- MBD compliant changes, Data Dictionary creation & 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.
- Choose sample time for all signals as 0.01s
Overview:
Identifying the direction of the vehicle is one of the important & diverse features in Autonomous driving & Advanced Driver Assistance Features. This particular sub-feature of identifying the direction of the vehicle is basically identifying the direction the vehicle is taking based on the camera input.
The camera reads the road signs & stores them into its memory with unique values for a left turn, right turn & straight drive. Depending on the direction it is taking, the final indication is given to the driver – as an indication if he is driving in the recommended direction or not.
Vehicle Direction Determination can also be coupled alongside features like GPS systems to identify whether the vehicle is reaching its destination in an optimized manner. This sub-feature can also be used along with Lane Detection, Highway Warning, Ramp Entry / Exit in Wrong Way Detection etc.
MATLAB Model:
The below picture shows the Vehicle_Direction_Detection subsystem which takes inputs as SteeringWheel_YawDegreeInput and CameraInput_RoadSign giving Vehicle_Direction_Detection as output.
The output shows
1 0 0 for a right turn
0 1 0 for a left turn
0 0 1 for a straight drive and
0 0 0 if the camera input is 0

The below picture shows the two subsystems created based on the requirements provided where the Turn_Status subsystem takes SteeringWheel_YawDegreeInput as input and provide Vehicle_Turn_Status as output which is then provided as an input for the Direction_Indicator subsystem where the final output Vehicle_Direction_Indicator is obtained. The final output is 3x1 indicates whether the steering wheel is turning towards (i.e., right, left turn or straight drive).

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 a 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 & the output of this requirement is a local signal (Signal Name: Vehicle_Turn_Status).

Logic:
The Turn_Status subsystem is created based on Requirement-1. Here, the 3 angular values Right_Turn_AngularLimit, Left_Turn_AngularLimit, Straight_Drive_Steering_Angle are compared using a switch block against the input SteeringWheel_YawDegreeInput to detect in which direction the vehicle is turning i.e., Vehicle_Turn_Status

Requirement – 2:
- Keep this requirement as a separate subsystem. Inputs to this requirement are a local signal from requirement 1 (Signal Name: Vehicle_Turn_Status) & an input signal from the 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).

Logic:
The output Vehicle_Turn_Status from the Turn_Status subsystem is provided as the input along with the CameraInput_RoadSign confirming the occurrence of the respective road signs. Here, the Vehicle_Turn_Status value is compared using the relational operator blocks set to equal to with the specified RightTurn_RoadSign, LeftTurn_RoadSign, Straight_RoadSign values. The boolean output from these blocks is then given to the logical AND operator block to compare it with the boolean input CameraInput_RoadSign. The output obtained is 3x1 specifying in which direction the vehicle is turning i.e., either left, right turn or straight drive.

Creating SLDD for the above-developed model:
Signals & Calibration Data List:
The below table shows the input, output and calibration values with their respective signal, data type, dimension, min, max and initial values and units. The same was created in an SLDD file named Vehicle_Dir_Det_DD.sldd file.
|
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 |
- |
- |

Results:
The below pictures shows the output for various condition mentioned below:
SteeringWheel_YawDegreeInput = 0; CameraInput_RoadSign = 0; No Output

SteeringWheel_YawDegreeInput = 0; CameraInput_RoadSign = 1; Straight drive

SteeringWheel_YawDegreeInput = 30; CameraInput_RoadSign = 0; No Output

SteeringWheel_YawDegreeInput = 30; CameraInput_RoadSign = 1; Right Turn

SteeringWheel_YawDegreeInput = -120; CameraInput_RoadSign = 0; No Output

SteeringWheel_YawDegreeInput = -120; CameraInput_RoadSign = 1; Left Turn

Model Advisor:
The below pictures shows the steps to generate the Model Advisor report. The Vehicle_Direction_Detection subsystem block was selected for report generation by checking the necessary tasks and running them to check errors and warnings as shown below.


Code Generation:
Upon generating the Model Advisor report, the model was built (Cntrl+B) for code generation. The below pictures shows the code generated along with the code generation report and necessary .h and .c files.



Conclusions:
- The Simulink model with the specified subsystems is developed as per the given requirements.
- Created SLDD file as per the Signals and Calibration List.
- Model Advisor Report is generated.
- Code Generation steps are carried.