All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Aim - Designing High-way Assistant Lane changing Assistant feature using Model Based Development in MATLAB - Simulink environment. Software used - MATLAB R2020a Objectives - This model must be developed in MATLAB Simulink per MBD guidelines. Code Generation target file must be Autosar Coder. Simulink Data Dictionary…
Shivani Shekhar Sonar
updated on 18 Nov 2021
Aim - Designing High-way Assistant Lane changing Assistant feature using Model Based Development in MATLAB - Simulink environment.
Software used - MATLAB R2020a
Objectives -
Introduction -
The Highway Assistant supports the driver and takes over the longitudinal and lateral guidance of the vehicle in monotonous driving situations on highways. The partially automated function can automatically start, accelerate, brake as well as steer the vehicle to a certain extent. The driver has to permanently supervise the system and be ready to take over the complete control of the vehicle at any time.Drivers are taught to assess surrounding traffic before changing lanes by checking their rearview and side mirrors and looking over each shoulder. However, even for those who follow this sequence of checks, the vehicle's blind spot – the area alongside and just behind the vehicle – is a constant source of danger and often the cause of serious accidents. Even vehicles approaching quickly from behind can pose a risk. To make changing lanes safer, this feature has been developed.
How does it work?
Now we will design this ADAS feature in MATLAB - simulink environment with concepts of Autosar Software Component Development.
The model would look like this -
The given signals are-
Input Signals:
Name of the Signal |
Data Type |
Range |
Highway_Input_Signal |
uint8 |
0 - 255 |
Enable_Display |
uint8 |
0 – 255 |
Input_Switch |
uint8 |
0 – 255 |
Lane_Input_Signal |
uint8 |
0 - 255 |
Local Signals:
Name of the Signal |
Data Type |
Range |
Highway_Display_Mode_1 |
uint8 |
0 - 255 |
Highway_Display_Mode_2 |
uint8 |
0 – 255 |
Highway_Display_Mode_3 |
uint8 |
0 – 255 |
Highway_Display_Mode_4 |
uint8 |
0 – 255 |
Lane_Display_Mode_1 |
uint8 |
0 – 255 |
Lane_Display_Mode_2 |
uint8 |
0 – 255 |
Lane_Display_Mode_3 |
uint8 |
0 – 255 |
Lane_Display_Mode_4 |
uint8 |
0 – 255 |
Output Signals:
Name of the Signal |
Data Type |
Range |
Display_Mode_1 |
uint8 |
0 - 255 |
Display_Mode_2 |
uint8 |
0 – 255 |
Display_Mode_3 |
uint8 |
0 – 255 |
Display_Mode_4 |
uint8 |
0 - 255 |
We will create all these signals in the SLDD. Firstly, click on the link to data dictionary option and name the sldd file as per our choice.
SLDD file - https://drive.google.com/file/d/1wrLjJYtogKK25RDT3muiwO5Z3yKBs8MG/view?usp=sharing
Now we will design the model as per the given requirements.
Requirement No 1 [Highway_DisplayUnit]:
Inputs to this particular subsystem are “Highway_Input_Signal”, “Enable_Display”, “Input_Switch”. These three input signals, when assigned to a particular value will give output signals of specific value. The output signals are “Highway_Display_Mode_1”, “Highway_Display_Mode_2”, “Highway_Display_Mode_3”, “Highway_Display_Mode_4”. The requirement must be implemented in the form of a Stateflow logic.
Condition |
Action |
Highway_Input_Signal = 1 Enable_Display = off Input_Switch = on |
Highway_Display_Mode_1 = 232 Highway_Display_Mode_2 = 183 Highway_Display_Mode_3 = 41 Highway_Display_Mode_4 = 94 |
Highway_Input_Signal = 1 Enable_Display = on Input_Switch = on |
Highway_Display_Mode_1 = 213 Highway_Display_Mode_2 = 183 Highway_Display_Mode_3 = 9 Highway_Display_Mode_4 = 94 |
Requirement 1 looks like this -
The chart has a state diagram like this -
And the symbol pane for this stateflow will be -
Requirement No 2 [Lane_DisplayUnit]:
Inputs to this particular subsystem are “Enable_Display”, “Input_Switch”, “Lane_Input_Signal”. These three input signals, when assigned to a particular value will give output signals of specific value. The output signals are “Lane_Display_Mode_1”, “Lane_Display_Mode_2”, “Lane_Display_Mode_3”, “Lane_Display_Mode_4”. The requirement must be implemented in the form of Stateflow logic.
Condition |
Action |
Lane_Input_Signal= 6 Enable_Display = off Input_Switch = on |
Lane_Display_Mode_1 = 132 Lane_Display_Mode_2 = 185 Lane_Display_Mode_3 = 54 Lane_Display_Mode_4 = 67 |
Lane_Input_Signal= 6 Enable_Display = on Input_Switch = on |
Lane_Display_Mode_1 = 127 Lane_Display_Mode_2 = 248 Lane_Display_Mode_3 = 186 Lane_Display_Mode_4 = 84 |
Requirement 2 looks like this -
The chart looks like this -
And the symbol pane for this stateflow will be -
Requirement No 3:
Signals coming from both subsystems “Highway_Display_Mode_1” & “Lane_Display_Mode_1” are given as inputs to a switch block which will have input signal “Highway_Input_Signal” given as 2nd input to the switch block. Corresponding output from this particular switch block is output signal “Display_Mode_1”.
Signals coming from both subsystems “Highway_Display_Mode_2” & “Lane_Display_Mode_2” are given as inputs to a switch block which will have input signal “Highway_Input_Signal” given as 2nd input to the switch block. Corresponding output from this particular switch block is output signal “Display_Mode_2”.
Signals coming from both subsystems “Highway_Display_Mode_3” & “Lane_Display_Mode_3” are given as inputs to a switch block which will have input signal “Highway_Input_Signal” given as 2nd input to the switch block. Corresponding output from this particular switch block is output signal “Display_Mode_3”.
Signals coming from both subsystems “Highway_Display_Mode_4” & “Lane_Display_Mode_4” are given as inputs to a switch block which will have input signal “Highway_Input_Signal” given as 2nd input to the switch block. Corresponding output from this particular switch block is output signal “Display_Mode_4”.
Requirement 3 looks like this -
After designing all the requirements the subsystem looks like this-
where the Lane_Displayunit(req2) is the enabled subsystem and it is only enabled when it is equal to 6 .
The overall Highway Assistant – Lane Changing Assistant will look like this-
Code Generation Settings-
Autosar Port Mapping-
Now successfull validation report window will be pop up as shown,
This is how the model looks after the Autosar Validation and model changed to Autosar compliant model.
Model Advisor Report-
Model Advisory Report - https://drive.google.com/file/d/1m5IBUKcBEB2qfw3xEI9eTbjdNhK-kSab/view?usp=sharing
Now the model is ready to generate the code.
Steps for code generation-
The code will be generated as follows-
/*
* File: HighwayLane_assistant.c
*
* Code generated for Simulink model 'HighwayLane_assistant'.
*
* Model version : 1.29
* Simulink Coder version : 9.3 (R2020a) 18-Nov-2019
* C/C++ source code generated on : Wed Nov 17 18:48:18 2021
*
* Target selection: autosar.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "HighwayLane_assistant.h"
#include "HighwayLane_assistant_private.h"
/* Named constants for Chart: '/Chart' */
#define HighwayLane_assi_IN_Condition_1 ((uint8)1U)
#define HighwayLane_assi_IN_Condition_2 ((uint8)2U)
/* Block signals (default storage) */
B_HighwayLane_assistant_T HighwayLane_assistant_B;
/* Block states (default storage) */
DW_HighwayLane_assistant_T HighwayLane_assistant_DW;
/* Model step function */
void HighwayLane_assistant_Step(void)
{
sint32 rtb_Highway_Display_Mode_1;
sint32 rtb_Highway_Display_Mode_3;
float64 tmp;
sint32 tmp_0;
/* Chart: '/Chart' incorporates:
* Inport: '/Enable_Display'
* Inport: '/Highway_Input_Signal'
* Inport: '/Input_Switch'
*/
if (HighwayLane_assistant_DW.is_active_c3_HighwayLane_assist == 0U) {
HighwayLane_assistant_DW.is_active_c3_HighwayLane_assist = 1U;
HighwayLane_assistant_DW.is_c3_HighwayLane_assistant =
HighwayLane_assi_IN_Condition_1;
rtb_Highway_Display_Mode_1 = 232;
rtb_Highway_Display_Mode_3 = 41;
} else if (HighwayLane_assistant_DW.is_c3_HighwayLane_assistant ==
HighwayLane_assi_IN_Condition_1) {
if ((Rte_IRead_HighwayLane_assistant_Step_Highway_Input_Signal_Highway_Input_Signal
() == 1) &&
(Rte_IRead_HighwayLane_assistant_Step_Enable_Display_Enable_Display() ==
1) && (Rte_IRead_HighwayLane_assistant_Step_Input_Switch_Input_Switch()
== 1)) {
HighwayLane_assistant_DW.is_c3_HighwayLane_assistant =
HighwayLane_assi_IN_Condition_2;
rtb_Highway_Display_Mode_1 = 213;
rtb_Highway_Display_Mode_3 = 9;
} else {
rtb_Highway_Display_Mode_1 = 232;
rtb_Highway_Display_Mode_3 = 41;
}
} else {
/* case IN_Condition_2: */
if ((Rte_IRead_HighwayLane_assistant_Step_Highway_Input_Signal_Highway_Input_Signal
() == 1) &&
(Rte_IRead_HighwayLane_assistant_Step_Enable_Display_Enable_Display() ==
0) && (Rte_IRead_HighwayLane_assistant_Step_Input_Switch_Input_Switch()
== 1)) {
HighwayLane_assistant_DW.is_c3_HighwayLane_assistant =
HighwayLane_assi_IN_Condition_1;
rtb_Highway_Display_Mode_1 = 232;
rtb_Highway_Display_Mode_3 = 41;
} else {
rtb_Highway_Display_Mode_1 = 213;
rtb_Highway_Display_Mode_3 = 9;
}
}
/* End of Chart: '/Chart' */
/* Outputs for Enabled SubSystem: '/Enabled Subsystem' incorporates:
* EnablePort: '/Enable'
*/
/* RelationalOperator: '/Compare' incorporates:
* Constant: '/Constant'
* Inport: '/Lane_Input_Signal'
*/
if (Rte_IRead_HighwayLane_assistant_Step_Lane_Input_Signal_Lane_Input_Signal()
== 6) {
/* Chart: '/Chart' incorporates:
* Inport: '/Enable_Display'
* Inport: '/Input_Switch'
*/
if (HighwayLane_assistant_DW.is_active_c1_HighwayLane_assist == 0U) {
HighwayLane_assistant_DW.is_active_c1_HighwayLane_assist = 1U;
HighwayLane_assistant_DW.is_c1_HighwayLane_assistant =
HighwayLane_assi_IN_Condition_1;
HighwayLane_assistant_B.Lane_Display_Mode_1 = 132.0;
HighwayLane_assistant_B.Lane_Display_Mode_2 = 185.0;
HighwayLane_assistant_B.Lane_Display_Mode_3 = 54.0;
HighwayLane_assistant_B.Lane_Display_Mode_4 = 67.0;
} else if (HighwayLane_assistant_DW.is_c1_HighwayLane_assistant ==
HighwayLane_assi_IN_Condition_1) {
if ((Rte_IRead_HighwayLane_assistant_Step_Enable_Display_Enable_Display() ==
1) && (Rte_IRead_HighwayLane_assistant_Step_Input_Switch_Input_Switch
() == 1)) {
HighwayLane_assistant_DW.is_c1_HighwayLane_assistant =
HighwayLane_assi_IN_Condition_2;
HighwayLane_assistant_B.Lane_Display_Mode_1 = 127.0;
HighwayLane_assistant_B.Lane_Display_Mode_2 = 248.0;
HighwayLane_assistant_B.Lane_Display_Mode_3 = 186.0;
HighwayLane_assistant_B.Lane_Display_Mode_4 = 84.0;
} else {
HighwayLane_assistant_B.Lane_Display_Mode_1 = 132.0;
HighwayLane_assistant_B.Lane_Display_Mode_2 = 185.0;
HighwayLane_assistant_B.Lane_Display_Mode_3 = 54.0;
HighwayLane_assistant_B.Lane_Display_Mode_4 = 67.0;
}
} else {
/* case IN_Condition_2: */
if ((Rte_IRead_HighwayLane_assistant_Step_Enable_Display_Enable_Display() ==
0) && (Rte_IRead_HighwayLane_assistant_Step_Input_Switch_Input_Switch
() == 1)) {
HighwayLane_assistant_DW.is_c1_HighwayLane_assistant =
HighwayLane_assi_IN_Condition_1;
HighwayLane_assistant_B.Lane_Display_Mode_1 = 132.0;
HighwayLane_assistant_B.Lane_Display_Mode_2 = 185.0;
HighwayLane_assistant_B.Lane_Display_Mode_3 = 54.0;
HighwayLane_assistant_B.Lane_Display_Mode_4 = 67.0;
} else {
HighwayLane_assistant_B.Lane_Display_Mode_1 = 127.0;
HighwayLane_assistant_B.Lane_Display_Mode_2 = 248.0;
HighwayLane_assistant_B.Lane_Display_Mode_3 = 186.0;
HighwayLane_assistant_B.Lane_Display_Mode_4 = 84.0;
}
}
/* End of Chart: '/Chart' */
}
/* End of RelationalOperator: '/Compare' */
/* End of Outputs for SubSystem: '/Enabled Subsystem' */
/* Switch: '/Switch' incorporates:
* Inport: '/Highway_Input_Signal'
* Switch: '/Switch1'
* Switch: '/Switch2'
* Switch: '/Switch3'
*/
tmp_0 =
Rte_IRead_HighwayLane_assistant_Step_Highway_Input_Signal_Highway_Input_Signal
();
if (tmp_0 > 0) {
tmp = rtb_Highway_Display_Mode_1;
} else {
tmp = HighwayLane_assistant_B.Lane_Display_Mode_1;
}
/* End of Switch: '/Switch' */
/* Outport: '/Display_Mode_1' */
Rte_IWrite_HighwayLane_assistant_Step_Display_Mode_1_Display_Mode_1(tmp);
/* Switch: '/Switch1' */
if (tmp_0 > 0) {
tmp = 183.0;
} else {
tmp = HighwayLane_assistant_B.Lane_Display_Mode_2;
}
/* Outport: '/Display_Mode_2' */
Rte_IWrite_HighwayLane_assistant_Step_Display_Mode_2_Display_Mode_2(tmp);
/* Switch: '/Switch2' */
if (tmp_0 > 0) {
tmp = rtb_Highway_Display_Mode_3;
} else {
tmp = HighwayLane_assistant_B.Lane_Display_Mode_3;
}
/* Outport: '/Display_Mode_3' */
Rte_IWrite_HighwayLane_assistant_Step_Display_Mode_3_Display_Mode_3(tmp);
/* Switch: '/Switch3' */
if (tmp_0 > 0) {
tmp = 94.0;
} else {
tmp = HighwayLane_assistant_B.Lane_Display_Mode_4;
}
/* Outport: '/Display_Mode_4' */
Rte_IWrite_HighwayLane_assistant_Step_Display_Mode_4_Display_Mode_4(tmp);
}
/* Model initialize function */
void HighwayLane_assistant_Init(void)
{
/* (no initialization code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
The link for this model is -
https://drive.google.com/file/d/1aUU5fQibIDjyRfyEs2yki60cUV3Eyglx/view?usp=sharing
Conclusion - One of the ADAS features Highway Assistant – Lane Changing Assistant's small algorithm is successfully implemented in the simulink model using MBD. All the supported images have been attached and the successfully Autosar validation is done followed by the successfull model advisor report. After the model advisor check successfully code has been generated in the selected target file. And the code has been attached. And the model is attached in .slx form.
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 1
Aim : To design and develop the converters from given table in MATLAB-Simulink. Software Used : MATLAB 2020a From the table I have chosen to design the projects 5, 12 and 13 which are SEPIC in CCM, Buck-Boost Converter in CCM and Cuk converter in CCM respectively. Now I will start designing the chosen converters in their…
27 Jan 2022 04:41 PM IST
Project 2-Highway Assistant-Lane Changing Assistant
Aim - Designing High-way Assistant Lane changing Assistant feature using Model Based Development in MATLAB - Simulink environment. Software used - MATLAB R2020a Objectives - This model must be developed in MATLAB Simulink per MBD guidelines. Code Generation target file must be Autosar Coder. Simulink Data Dictionary…
18 Nov 2021 08:10 AM IST
Week 7 State of charge estimation
1.Simulate the 3 test cases from harness dashboard and write a detailed report on the results - Lithium-ion battery packs are the widely used energy storage systems in electric vehicles. The battery management system (BMS) is responsible for safe operation, performance, and battery life under diverse charge-discharge and…
24 Sep 2021 08:35 AM IST
Project 1- Traffic Jam Assistant Feature
Aim - To develop one specific requirement of Traffic Jam Assistant algorithm using MATLAB and Simulink. Software used - MATLAB - R2020a Traffic Jam Assistant Feature 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…
19 Sep 2021 06:33 PM 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.