All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
AIM: TO make the model for Vehicle Direction Detection OBJECTIVE: 1. To develop Vehicle Direction Detection feature as per the Requirement Document using MATLAB Simulink. 2. Follow all the MBD related processes: Requirement Tagging & Traceability, SLDD creation, Configuration Parameter changes, Model Advisor check…
Harika Bale
updated on 14 Sep 2021
AIM: TO make the model for Vehicle Direction Detection
OBJECTIVE:
1. To develop Vehicle Direction Detection feature as per the Requirement Document using MATLAB Simulink.
2. Follow all the MBD related processes: Requirement Tagging & Traceability, SLDD creation, Configuration Parameter changes, Model Advisor check & Code Generation
INTRODUCTION:
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 vehicle is basically identifying the direction the vehicle is taking based on the camera input.
Camera reads the road signs & stores into its memory with unique values for left turn, right turn & straight drive. Depending on the direction it is taking, 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 along - side 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.
SOLUTION:
There are certain requirements given in the problem, to develop the model for Vehicle Direction Detection. The following are the steps to be followed for creating Simulink Model
1. Create the Simulink Data Dictionary(SLDD format) from the given data list. Care should be taken while declaring the inputs and outputs.
SLDD file is attached for the reference.
2. As per Requirement -1:
Develop the blocks as per requirement
Inside the subsystem, logic is implemented using switch blocks as follows:
3. As per Requirement-2:
Develop the block
Inside the subsystem, logic is implemented using Logical Operator blocks:
Now run the model, we can see that there are no errors in the model:
Now check for Model Advisor and generate the report
file:///D:/Matlab%20Works/slprj/modeladvisor/vehicle_direction_detection/report_641.html
For the model, code generation is as follows:
vehicle_direction_detection main file code is :
*
* File: ert_main.c
*
* Code generated for Simulink model 'vehicle_direction_detection'.
*
* Model version : 1.3
* Simulink Coder version : 9.1 (R2019a) 23-Nov-2018
* C/C++ source code generated on : Tue Sep 14 18:58:48 2021
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives:
* 1. Execution efficiency
* 2. RAM efficiency
* Validation result: Not run
*/
#include <stddef.h>
#include <stdio.h> /* This ert_main.c example uses printf/fflush */
#include "vehicle_direction_detection.h" /* Model's header file */
#include "rtwtypes.h"
/*
* 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) {
return;
}
OverrunFlag = true;
/* Save FPU context here (if necessary) */
/* Re-enable timer or interrupt here */
/* Set model inputs here */
/* Step the model */
vehicle_direction_detection_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 */
vehicle_direction_detection_initialize();
/* Attach rt_OneStep to a timer or interrupt service routine with
* period 0.0002 seconds (the model's base sample time) 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 (1) {
/* Perform other application tasks here */
}
/* The option 'Remove error status field in real-time model data structure'
* is selected, therefore the following code does not need to execute.
*/
#if 0
/* Disable rt_OneStep() here */
#endif
return 0;
}
/*
* File trailer for generated code.
*
* [EOF]
*/
vehicle_direction_detection.c code is as follows:
And the .c code is :
/*
* File: vehicle_direction_detection.c
*
* Code generated for Simulink model 'vehicle_direction_detection'.
*
* Model version : 1.3
* Simulink Coder version : 9.1 (R2019a) 23-Nov-2018
* C/C++ source code generated on : Tue Sep 14 18:58:48 2021
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives:
* 1. Execution efficiency
* 2. RAM efficiency
* Validation result: Not run
*/
#include "vehicle_direction_detection.h"
/* External inputs (root inport signals with default storage) */
ExtU rtU;
/* External outputs (root outports fed by signals with default storage) */
ExtY rtY;
/* Model step function */
void vehicle_direction_detection_step(void)
{
int32_T tmp;
/* Switch: '<S1>/ Switch' incorporates:
* Constant: '<S1>/Left_Turn_AngularLimit'
* Constant: '<S1>/Right_Turn_AngularLimit'
* Inport: '<Root>/SteeringWheel_YawDegreeInput'
* Switch: '<S1>/Switch1 '
*/
if (rtU.SteeringWheel_YawDegreeInput > 0.0) {
tmp = 30;
} else if (rtU.SteeringWheel_YawDegreeInput > 0.0) {
/* Switch: '<S1>/Switch1 ' incorporates:
* Constant: '<S1>/Straight_Drive_Steering_Angle'
*/
tmp = 0;
} else {
tmp = -120;
}
/* End of Switch: '<S1>/ Switch' */
/* Outport: '<Root>/Vehicle_Direction_Indicator' incorporates:
* Inport: '<Root>/CameraInput_RoadSign'
* Logic: '<S2>/Logical Operator'
* Logic: '<S2>/Logical Operator3'
*/
rtY.Vehicle_Direction_Indicator = ((tmp != 0) || rtU.CameraInput_RoadSign);
}
/* Model initialize function */
void vehicle_direction_detection_initialize(void)
{
/* (no initialization code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
Similarly,
vehicle_direction_detection.h file code is:
/*
* File: vehicle_direction_detection.h
*
* Code generated for Simulink model 'vehicle_direction_detection'.
*
* Model version : 1.3
* Simulink Coder version : 9.1 (R2019a) 23-Nov-2018
* C/C++ source code generated on : Tue Sep 14 18:58:48 2021
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives:
* 1. Execution efficiency
* 2. RAM efficiency
* Validation result: Not run
*/
#ifndef RTW_HEADER_vehicle_direction_detection_h_
#define RTW_HEADER_vehicle_direction_detection_h_
#ifndef vehicle_direction_detection_COMMON_INCLUDES_
# define vehicle_direction_detection_COMMON_INCLUDES_
#include "rtwtypes.h"
#endif /* vehicle_direction_detection_COMMON_INCLUDES_ */
/* Macros for accessing real-time model data structure */
/* External inputs (root inport signals with default storage) */
typedef struct {
real_T SteeringWheel_YawDegreeInput;
/* '<Root>/SteeringWheel_YawDegreeInput' */
boolean_T CameraInput_RoadSign; /* '<Root>/CameraInput_RoadSign' */
} ExtU;
/* External outputs (root outports fed by signals with default storage) */
typedef struct {
boolean_T Vehicle_Direction_Indicator;
/* '<Root>/Vehicle_Direction_Indicator' */
} ExtY;
/* External inputs (root inport signals with default storage) */
extern ExtU rtU;
/* External outputs (root outports fed by signals with default storage) */
extern ExtY rtY;
/* Model entry point functions */
extern void vehicle_direction_detection_initialize(void);
extern void vehicle_direction_detection_step(void);
/*-
* The generated code includes comments that allow you to trace directly
* back to the appropriate location in the model. The basic format
* is <system>/block_name, where system is the system number (uniquely
* assigned by Simulink) and block_name is the name of the block.
*
* Use the MATLAB hilite_system command to trace the generated code back
* to the model. For example,
*
* hilite_system('<S3>') - opens system 3
* hilite_system('<S3>/Kp') - opens and selects block Kp which resides in S3
*
* Here is the system hierarchy for this model
*
* '<Root>' : 'vehicle_direction_detection'
* '<S1>' : 'vehicle_direction_detection/ Subsystem1'
* '<S2>' : 'vehicle_direction_detection/ Subsystem2'
*/
#endif /* RTW_HEADER_vehicle_direction_detection_h_ */
/*
* File trailer for generated code.
*
* [EOF]
*/
The code is generated and are attached for reference.
CONCLUSION: The model for Vehicle Direction Detection is completed and results are attached for reference.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Project 2-Highway Assistant-Lane Changing Assistant
AIM: To develop one specific requirement of Highway Assistant – Lane Changing Assistant algorithm. OBJECTIVE: This model must be developed in MATLAB Simulink per MBD guidelines. Code Generation Profile must be Autosar Coder. Simulink Data Dictionary must be created for the model & must be linked to…
20 Sep 2021 05:50 PM IST
Project 1- Traffic Jam Assistant Feature
AIM: To develop a single feature of Traffic Jam Assistant algorithm using MATLAB & SIMULINK. OBJECTIVE: 1. Model development as per MBD guidelines. 2. Creation of Simulink Data Dictionary (SLDD) file 3. Code Generation using Embedded Coder 4. Generate Model Advisor Report INTRODUCTION: Traffic Jam Assistant is one…
14 Sep 2021 07:04 PM IST
Project 1 (Mini Project on Vehicle Direction Detection
AIM: TO make the model for Vehicle Direction Detection OBJECTIVE: 1. To develop Vehicle Direction Detection feature as per the Requirement Document using MATLAB Simulink. 2. Follow all the MBD related processes: Requirement Tagging & Traceability, SLDD creation, Configuration Parameter changes, Model Advisor check…
14 Sep 2021 01:39 PM IST
Project 2 Thermal modeling of battery pack
AIM: To simulate 10cell series Lithium Ion battery model and to analyze thermal effects, life cycle performance at various temperatures, charge - discharge rates using MATLAB-SIMULINK. PROCEDURE: The following figure shows simulink model of 10 cells series Lithium-Ion battery model using an AC source with cyclic…
01 Sep 2021 05:20 AM IST
Related Courses
8 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.