Project 1 (Mini Project on Vehicle Direction Detection
Vehicle direction can be identified using ADAS features. In an autonomous driving system, based on the road sign, the vehicle steering can be twisted. As per the input, When Road shows 30, it takes a right turn, when the input is -120, the vehicle takes a left turn and when the road shows 0, the vehicle takes the straight road.
When the steering wheel input, Camera input is the same, accordingly the vehicle takes the turn.
MATLAB file is developed with the given requirements.

Two subsystems are developed based on the requirements given.
Requirement_1 is developed in the subsystem as shown below.
Inputs to the vehicle requirement are Camera input and Steering wheel input.

The vehicle inputs are compared with the parameters defined in the Data Dictionary.
Below is the data defined in the Data dictionary. SLDD file is as shown below.


Requirements_1 are defined as shown in the above subsystem as it is comparing each input with the Right turn angular limit, and then with the Left turn angular limit, etc, the output signal is shown as Vehicle Turn Status. Vehicle turn status is the local signal.
Vehicle requirement_2 is the subsystem that takes the vehicle turn status as one signal and camera input as another signal.
Camera input is the signal which is Boolean and gives the input of either 1 or 0. The subsystem is shown below.

The road sign is compared with the camera input signal. If the vehicle turn status is the same as the turn status given by the camera road signal, then the output is 1. After comparing the road sign with Vehicle turn status using the Relational operator, and then compared with camera input using the Logical operator.

Based on the input road signals, the vehicle directions are shown in the below table.
|
Steering Wheel Yaw Degree Input |
Camera Input Road Sign |
Signal Output |
Vehicle Direction |
|
30 |
1 |
100 |
Right Turn |
|
-120 |
1 |
010 |
Left Turn |
|
0 |
1 |
001 |
Straightway |
|
30 |
0 |
000 |
No Movement |
|
-120 |
0 |
000 |
No Movement |
|
0 |
0 |
000 |
No Movement |
To support the above MATLAB file, the SLDD file is developed.
And the Code is Generated.
While generating the Code, configurations are as shown below.

The target file is ert.tlc
And the code is generated using an Embedded coder.

An embedded coder is selected which made the code generation in the MATLAB file.
The embedded code is shown below.
/*
* Academic License - for use in teaching, academic research, and meeting
* course requirements at degree granting institutions only. Not for
* government, commercial, or other organizational use.
*
* File: ert_main.c
*
* Code generated for Simulink model 'prj_1'.
*
* Model version : 1.31
* Simulink Coder version : 9.7 (R2022a) 13-Nov-2021
* C/C++ source code generated on : Sun Oct 30 21:01:38 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include <stddef.h>
#include <stdio.h> /* This example main program uses printf/fflush */
#include "prj_1.h" /* Model header file */
/*
* Associating rt_OneStep with a real-time clock or interrupt service routine
* is what makes the generated code "real-time". The function rt_OneStep is
* always associated with the base rate of the model. Subrates are managed
* by the base rate from inside the generated code. Enabling/disabling
* interrupts and floating point context switches are target specific. This
* example code indicates where these should take place relative to executing
* the generated code step function. Overrun behavior should be tailored to
* your application needs. This example simply sets an error status in the
* real-time model and returns from rt_OneStep.
*/
void rt_OneStep(void);
void rt_OneStep(void)
{
static boolean_T OverrunFlag = false;
/* Disable interrupts here */
/* Check for overrun */
if (OverrunFlag) {
rtmSetErrorStatus(prj_1_M, "Overrun");
return;
}
OverrunFlag = true;
/* Save FPU context here (if necessary) */
/* Re-enable timer or interrupt here */
/* Set model inputs here */
/* Step the model */
prj_1_step();
/* Get model outputs here */
/* Indicate task complete */
OverrunFlag = false;
/* Disable interrupts here */
/* Restore FPU context here (if necessary) */
/* Enable interrupts here */
}
/*
* The example main function illustrates what is required by your
* application code to initialize, execute, and terminate the generated code.
* Attaching rt_OneStep to a real-time clock is target specific. This example
* illustrates how you do this relative to initializing the model.
*/
int_T main(int_T argc, const char *argv[])
{
/* Unused arguments */
(void)(argc);
(void)(argv);
/* Initialize model */
prj_1_initialize();
/* Attach rt_OneStep to a timer or interrupt service routine with
* period 0.01 seconds (base rate of the model) here.
* The call syntax for rt_OneStep is
*
* rt_OneStep();
*/
printf("Warning: The simulation will run forever. "
"Generated ERT main won't simulate model step behavior. "
"To change this behavior select the 'MAT-file logging' option.\n");
fflush((NULL));
while (rtmGetErrorStatus(prj_1_M) == (NULL)) {
/* Perform application tasks here */
}
/* Terminate model */
prj_1_terminate();
return 0;
}
/*
* File trailer for generated code.
*
* [EOF]
*/
Result:
- As per the requirements, two subsystems are developed.
- Requirements_1 and Requirement_2 are the subsystems developed with the given inputs.
- SLDD file is created.
- Code generation is done using Embedded coder
- The Vehicle status is based on the steering yaw rotation and Camera inputs.
|
Steering Wheel Yaw Degree Input |
Camera Input Road Sign |
Signal Output |
Vehicle Direction |
|
30 |
1 |
100 |
Right Turn |
|
-120 |
1 |
010 |
Left Turn |
|
0 |
1 |
001 |
Straight way |
|
30 |
0 |
000 |
No Movement |
|
-120 |
0 |
000 |
No Movement |
|
0 |
0 |
000 |
No Movement |