Project 1- Traffic Jam Assistant Feature
Traffic Jam Assistant Feature
Ans:
AIM:
The primary aim of implementing the Traffic Jam Assistant feature is to develop a model-based algorithm in MATLAB Simulink that simulates a small but critical part of the Traffic Jam Assistant system, specifically focusing on the Instrument Panel Cluster (IPC) display functionality. This project seeks to:
- Familiarize with model-based development (MBD) concepts in the MATLAB Simulink environment.
- Implement a simplified portion of the Traffic Jam Assistant logic, allowing the display of relevant information in traffic jam conditions.
- Adhere to MBD guidelines for code generation, simulation, and verification, including creating a Simulink Data Dictionary, generating an Advisor Report, and generating code using Embedded Coder.
- Ensure that the model correctly processes input signals, performs signal comparison, and generates output signals based on specified requirements, enabling a realistic representation of the Traffic Jam Assistant system's behavior.
Introduction to the Feature:
Please refer the file Picture1.png
Traffic Jam Assistant is one of the most common feature in Advanced Driver Assistance System. Traffic Jam Assistant helps the driver arrive more relaxed at their destination, even in dense traffic or in traffic jams. As a partially automated comfort function, the system takes over the longitudinal & lateral guidance of the vehicle. This means that the car can drive off, accelerate & brake automatically, as well as steer the vehicle within certain constraints. The driver has to permanently supervise the system & be ready to take over the complete control of the vehicle at any time.
Traffic Jam Assistant system helps to avoid rear end collisions in dense traffic conditions & traffic jams. In Traffic jams, the vehicle takes over driving off, acceleration, braking and steering within same lane.
Basic Working Principle:
Traffic Jam Assistant is based on the sensors and the functionality of the Adaptive Cruise Control (ACC) with stop & go and Lane Keeping Support (LKS). When ACC ‘Stop & Go’ is turned ON, the Traffic Jam Assistant continuously analyses the speed of the surrounding vehicles and compares it with the own driving speed. If the system detects dense traffic or a traffic jam at speeds less than 60 kmph, the driver can activate the functionality by press of a button. The vehicle will now automatically follow the vehicle in front, takes over driving off, acceleration, braking and steering within same lane.
Information regarding the Traffic Jam Assistant will be available to be displayed to the driver in the Instrument Panel Cluster (IPC). The Algorithm which the students need to implement here in this project is predominantly based on IPC units.
Problem Statement:
To develop one specific requirement of Traffic Jam Assistant algorithm which would predominantly feature in the IPC algorithm.Please note that the whole Traffic Jam Assistant is a very huge algorithm & only one small part of the logic is implemented here. Idea is to familiarize with concepts of Model Based Development in MATLAB Environment. The Project must be done keeping in mind the following processes & steps.
- This model must be developed in MATLAB Simulink as per MBD guidelines.
- Code Generation Profile must be in Embedded Coder.
- Simulink Data Dictionary must be created for the model & must be linked to the model.
- Model Advisor Report is mandatory & this will be followed by Code Generation.
Input Signals:
|
Name of the Signal |
Data Type |
Range |
|
Input_Voltage |
uint8 |
0 - 255 |
|
Input_Switch |
boolean |
0 – 1 |
|
Enable_Display |
uint8 |
0 - 255 |
Output Signal:
|
Name of the Signal |
Data Type |
Range |
|
Output_Display |
uint8 |
0 - 255 |
Calibration Signals:
|
Name of the Signal |
Data Type |
Range |
Initial Value |
|
VOLTAGE_MINIMUM_RANGE |
uint8 |
0 – 255 |
30 |
|
VOLTAGE_MAXIMUM_RANGE |
uint8 |
0 – 255 |
50 |
|
OFF_MODE |
uint8 |
0 – 255 |
2 |
|
ON_MODE |
uint8 |
0 – 255 |
1 |
|
STANDBY_MODE |
uint8 |
0 – 255 |
3 |
|
INTERRUPT_1 |
boolean |
0 – 1 |
1 |
|
INTERRUPT_2 |
boolean |
0 - 1 |
1 |
|
NO_DISPLAY |
uint8 |
0 – 255 |
0 |
Local Signal:
|
Name of the Signal |
Data Type |
Range |
|
Optimum_Voltage |
boolean |
0 - 1 |
SLDD file:
Please refer the file traffic_sldd.png
Matlab Model:
Please refer the file Traffic_1.png
- This is our matlab model for traffic jam assistance.
- we have input as Enable display, input voltage and input switch.
- The signal processed through the subsystem will be given in the output display.
- the input signals are resolved and the output signal is resolved.
Traffic jam Assistance Subsystem:
Please refer the file Traffic_2.png
- Inside the Traffic Jam Assistance subsytem we have inputs as enable display, input voltage and input switch and output as output display
- the input voltage is passed through the requirment_1 subsystem and output as optimum voltage too the display unit.
- now lets discuss about the requirement 1 system and Display unit in brief
Requirement No 1:
Please refer the file Traffic_3.png
- Input Signal “Input_Voltage” is compared against voltage values “VOLTAGE_MINIMUM_RANGE” & “VOLTAGE_MAXIMUM_RANGE”.
- Incoming input signal “Input_Voltage” must be greater than – equal to “VOLTAGE_MINIMUM_RANGE” and less than – equal to “VOLTAGE_MAXIMUM_RANGE”.
- Output signal from here is “Optimum_Voltage” which will be one of the inputs to the subsystem “DisplayUnit”.
Requirement No 2 (DisplayUnit Subsystem):
Please refer the file Traffic_4.png
- Input Signals are “Optimum_Voltage”, “Input_Switch”,“Enable_Display”. Signal “Enable_Display” must be saturated between the range 0 – 7. Output signal from the subsystem is “Output_Display”.
- Input Signal “Enable_Display” is compared against pre – defined set of values in a multiport switch. Total data ports in the multiport switch is 5.
- Multiport switch inputs 1 & 2 is connected to calibration signal “ON_MODE”, Multiport switch inputs 3 & 4 is connected to calibration signal “OFF_MODE” while Multiport switch input 5 is connected to calibration signal “STANDBY_MODE”.
- The output from Multiport switch is connected to the first input port of the Switch block. The third input port of the Switch block is connected to the calibration signal “NO_DISPLAY”.
- Meanwhile NOT value of input signal “Input_Switch” is compared in an AND gate against input signal “Optimum_Voltage” and the output from comparing if calibration signals “INTERRUPT_1” & “INTERRUPT_2” are equal. The output of the AND gate is the second input of the switch block.
- The output from the switch block is “Output_Display”.
Model Advisor Check:
- Click on the modelling option availabe in the file menu > select the advisor check available> system selector >Traffic_Jam_Assitance > OK > click the by task box > click the show report after run > Generate report
Code Generation:
- In Configuration Parameters: enable “Support Floating Numbers” under Code Generation settings.
- Use Embedded Coder to generate the code.
- click on the modelling option availabe in the file menu > model setting > code generation > select grt_rtw > OK
/*
* trffic_jam_assistence.c
*
* Trial License - for use to evaluate programs for possible purchase as
* an end-user only.
*
* Code generation for model "trffic_jam_assistence".
*
* Model version : 1.1
* Simulink Coder version : 24.2 (R2024b) 21-Jun-2024
* C source code generated on : Sat Oct 19 14:38:15 2024
*
* Target selection: grt.tlc
* Note: GRT includes extra infrastructure and instrumentation for prototyping
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "trffic_jam_assistence.h"
#include "rtwtypes.h"
#include "trffic_jam_assistence_private.h"
/* Block signals (default storage) */
B_trffic_jam_assistence_T trffic_jam_assistence_B;
/* External outputs (root outports fed by signals with default storage) */
ExtY_trffic_jam_assistence_T trffic_jam_assistence_Y;
/* Real-time model */
static RT_MODEL_trffic_jam_assistenc_T trffic_jam_assistence_M_;
RT_MODEL_trffic_jam_assistenc_T *const trffic_jam_assistence_M =
&trffic_jam_assistence_M_;
/* Model step function */
void trffic_jam_assistence_step(void)
{
uint8_T tmp;
/* Logic: '<S3>/Logical Operator' incorporates:
* Constant: '<S3>/Constant'
* Constant: '<S3>/Constant1'
* Inport: '<Root>/Input_Voltage'
* RelationalOperator: '<S3>/Relational Operator'
* RelationalOperator: '<S3>/Relational Operator1'
*/
trffic_jam_assistence_B.Optimum_Voltage = ((Input_Voltage >=
trffic_jam_assistence_P.VOLTAGE_MINIMUM_RANGE) || (Input_Voltage <=
trffic_jam_assistence_P.VOLTAGE_MAXIMUM_RANGE));
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant'
* Constant: '<S2>/Constant4'
* Inport: '<Root>/Input_Switch'
* Logic: '<S2>/NOT'
* RelationalOperator: '<S2>/Equal'
* Sum: '<S2>/Add'
*/
if ((trffic_jam_assistence_B.Optimum_Voltage + (uint32_T)!Input_Switch) +
(uint32_T)(trffic_jam_assistence_P.INTERRUPT_1 ==
trffic_jam_assistence_P.INTERRUPT_2) > 0U) {
/* Saturate: '<S2>/Saturation' incorporates:
* Inport: '<Root>/Enable_Display'
*/
if (Enable_Display <= 1) {
tmp = Enable_Display;
} else {
tmp = 1U;
}
/* MultiPortSwitch: '<S2>/Index Vector' incorporates:
* Saturate: '<S2>/Saturation'
*/
if (tmp == 1) {
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant1'
*/
trffic_jam_assistence_B.Output_Display = trffic_jam_assistence_P.OFF_MODE;
} else {
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant3'
*/
trffic_jam_assistence_B.Output_Display =
trffic_jam_assistence_P.STANDBY_MODE;
}
/* End of MultiPortSwitch: '<S2>/Index Vector' */
} else {
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant5'
*/
trffic_jam_assistence_B.Output_Display = trffic_jam_assistence_P.NO_DISPLAY;
}
/* End of Switch: '<S2>/Switch' */
/* Outport: '<Root>/Output_Display' */
trffic_jam_assistence_Y.Output_Display =
trffic_jam_assistence_B.Output_Display;
/* Matfile logging */
rt_UpdateTXYLogVars(trffic_jam_assistence_M->rtwLogInfo,
(&trffic_jam_assistence_M->Timing.taskTime0));
/* signal main to stop simulation */
{ /* Sample time: [0.2s, 0.0s] */
if ((rtmGetTFinal(trffic_jam_assistence_M)!=-1) &&
!((rtmGetTFinal(trffic_jam_assistence_M)-
trffic_jam_assistence_M->Timing.taskTime0) >
trffic_jam_assistence_M->Timing.taskTime0 * (DBL_EPSILON))) {
rtmSetErrorStatus(trffic_jam_assistence_M, "Simulation finished");
}
}
/* Update absolute time for base rate */
/* The "clockTick0" counts the number of times the code of this task has
* been executed. The absolute time is the multiplication of "clockTick0"
* and "Timing.stepSize0". Size of "clockTick0" ensures timer will not
* overflow during the application lifespan selected.
* Timer of this task consists of two 32 bit unsigned integers.
* The two integers represent the low bits Timing.clockTick0 and the high bits
* Timing.clockTickH0. When the low bit overflows to 0, the high bits increment.
*/
if (!(++trffic_jam_assistence_M->Timing.clockTick0)) {
++trffic_jam_assistence_M->Timing.clockTickH0;
}
trffic_jam_assistence_M->Timing.taskTime0 =
trffic_jam_assistence_M->Timing.clockTick0 *
trffic_jam_assistence_M->Timing.stepSize0 +
trffic_jam_assistence_M->Timing.clockTickH0 *
trffic_jam_assistence_M->Timing.stepSize0 * 4294967296.0;
}
/* Model initialize function */
void trffic_jam_assistence_initialize(void)
{
/* Registration code */
/* initialize real-time model */
(void) memset((void *)trffic_jam_assistence_M, 0,
sizeof(RT_MODEL_trffic_jam_assistenc_T));
rtmSetTFinal(trffic_jam_assistence_M, 10.0);
trffic_jam_assistence_M->Timing.stepSize0 = 0.2;
/* Setup for data logging */
{
static RTWLogInfo rt_DataLoggingInfo;
rt_DataLoggingInfo.loggingInterval = (NULL);
trffic_jam_assistence_M->rtwLogInfo = &rt_DataLoggingInfo;
}
/* Setup for data logging */
{
rtliSetLogXSignalInfo(trffic_jam_assistence_M->rtwLogInfo, (NULL));
rtliSetLogXSignalPtrs(trffic_jam_assistence_M->rtwLogInfo, (NULL));
rtliSetLogT(trffic_jam_assistence_M->rtwLogInfo, "tout");
rtliSetLogX(trffic_jam_assistence_M->rtwLogInfo, "");
rtliSetLogXFinal(trffic_jam_assistence_M->rtwLogInfo, "");
rtliSetLogVarNameModifier(trffic_jam_assistence_M->rtwLogInfo, "rt_");
rtliSetLogFormat(trffic_jam_assistence_M->rtwLogInfo, 0);
rtliSetLogMaxRows(trffic_jam_assistence_M->rtwLogInfo, 0);
rtliSetLogDecimation(trffic_jam_assistence_M->rtwLogInfo, 1);
/*
* Set pointers to the data and signal info for each output
*/
{
static void * rt_LoggedOutputSignalPtrs[] = {
&trffic_jam_assistence_Y.Output_Display
};
rtliSetLogYSignalPtrs(trffic_jam_assistence_M->rtwLogInfo,
((LogSignalPtrsType)rt_LoggedOutputSignalPtrs));
}
{
static int_T rt_LoggedOutputWidths[] = {
1
};
static int_T rt_LoggedOutputNumDimensions[] = {
1
};
static int_T rt_LoggedOutputDimensions[] = {
1
};
static boolean_T rt_LoggedOutputIsVarDims[] = {
0
};
static void* rt_LoggedCurrentSignalDimensions[] = {
(NULL)
};
static int_T rt_LoggedCurrentSignalDimensionsSize[] = {
4
};
static BuiltInDTypeId rt_LoggedOutputDataTypeIds[] = {
SS_UINT8
};
static int_T rt_LoggedOutputComplexSignals[] = {
0
};
static RTWPreprocessingFcnPtr rt_LoggingPreprocessingFcnPtrs[] = {
(NULL)
};
static const char_T *rt_LoggedOutputLabels[] = {
"Output_Display" };
static const char_T *rt_LoggedOutputBlockNames[] = {
"trffic_jam_assistence/Output_Display" };
static RTWLogDataTypeConvert rt_RTWLogDataTypeConvert[] = {
{ 0, SS_UINT8, SS_UINT8, 0, 0, 0, 1.0, 0, 0.0 }
};
static RTWLogSignalInfo rt_LoggedOutputSignalInfo[] = {
{
1,
rt_LoggedOutputWidths,
rt_LoggedOutputNumDimensions,
rt_LoggedOutputDimensions,
rt_LoggedOutputIsVarDims,
rt_LoggedCurrentSignalDimensions,
rt_LoggedCurrentSignalDimensionsSize,
rt_LoggedOutputDataTypeIds,
rt_LoggedOutputComplexSignals,
(NULL),
rt_LoggingPreprocessingFcnPtrs,
{ rt_LoggedOutputLabels },
(NULL),
(NULL),
(NULL),
{ rt_LoggedOutputBlockNames },
{ (NULL) },
(NULL),
rt_RTWLogDataTypeConvert
}
};
rtliSetLogYSignalInfo(trffic_jam_assistence_M->rtwLogInfo,
rt_LoggedOutputSignalInfo);
/* set currSigDims field */
rt_LoggedCurrentSignalDimensions[0] = &rt_LoggedOutputWidths[0];
}
rtliSetLogY(trffic_jam_assistence_M->rtwLogInfo, "yout");
}
/* block I/O */
(void) memset(((void *) &trffic_jam_assistence_B), 0,
sizeof(B_trffic_jam_assistence_T));
/* external outputs */
trffic_jam_assistence_Y.Output_Display = 0U;
/* Matfile logging */
rt_StartDataLoggingWithStartTime(trffic_jam_assistence_M->rtwLogInfo, 0.0,
rtmGetTFinal(trffic_jam_assistence_M),
trffic_jam_assistence_M->Timing.stepSize0, (&rtmGetErrorStatus
(trffic_jam_assistence_M)));
}
/* Model terminate function */
void trffic_jam_assistence_terminate(void)
{
/* (no terminate code required) */
}
Ouput:
- now lets run the simulation by connecting source and sink blocks.
- by giving 1 as enable display the display is on, and 50 as input voltage and turning on the switch by giving value as 1.
- the output is displayed as 0, which means the 'stop and go' is turned OFF and vehilce is free to ride and there is no traffic Jam ahead.
Justification:
The Traffic Jam Assistant feature is a crucial component of Advanced Driver Assistance Systems (ADAS), designed to enhance driver comfort and safety in dense traffic conditions. By implementing a simplified portion of this feature in MATLAB Simulink, the project provides hands-on experience with Model-Based Development (MBD) techniques, which are widely used in automotive systems engineering. This project serves as an introduction to developing ADAS algorithms, with a focus on the Instrument Panel Cluster (IPC) display logic.
Key justifications for this project include:
- Introduction to ADAS Development: This project helps in understanding the fundamental concepts of ADAS and how such systems assist drivers by partially automating driving tasks in traffic jams.
- Hands-On MBD Practice: Working in MATLAB Simulink aligns with industry standards for model-based development, including code generation and verification processes using Embedded Coder.
- System Safety and Comfort: Implementing logic for accurate display feedback in traffic conditions ensures that drivers receive reliable information, which is essential for system safety and comfort.
- Simplified Scope for Learning: By focusing on a specific IPC-related requirement, the project allows for manageable complexity while demonstrating essential ADAS functionality.
Summary:
The project involves developing a portion of the Traffic Jam Assistant algorithm using MATLAB Simulink, with a focus on the Instrument Panel Cluster (IPC). It aims to enhance understanding of Model-Based Development in automotive systems by implementing logic that processes various input signals and generates an appropriate display output.
The core tasks include:
- Comparing input voltage against specified ranges to determine an "Optimum_Voltage" condition.
- Processing this condition along with other inputs, such as "Input_Switch" and "Enable_Display," to control the display output using logic gates, multiport switches, and calibration values.
- Generating code in Embedded Coder, linking a Simulink Data Dictionary, and producing a Model Advisor Report to ensure adherence to MBD guidelines.
The project serves as a foundational exercise in developing and understanding ADAS functionalities, with a focus on traffic jam scenarios where the system can assist in braking, accelerating, and steering while displaying relevant information to the driver.