Project 2-Highway Assistant-Lane Changing Assistant
Highway Assistant – Lane Changing Assistant
Introduction to the Feature:
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.
Basic Working Principle:
Highway Assistant is a partially automated driving function for a speed range of up to 180 km/h (112 mph) on highways. It combines the radar-based longitudinal guidance of Adaptive Cruise Control (ACC) with the video-based lateral guidance of lane keeping support in one system. Highway Assistant can be supplemented by an automatic lane change initiated and monitored by the driver in a speed range of 60 – 130 km/h (35 – 80 mph).
The lane Change Assistant works by using two mid-range radar sensors that are concealed in the rear bumper – one on the left, one on the right. These two sensors monitor the area alongside and behind the car. Powerful control software collates the sensor information to create a complete picture of all traffic in the area behind the vehicle.Whenever another vehicle approaches at speed from behind or is already present in the blind spot, a signal such as a warning light in the side mirror alerts the driver to the hazard. Should the driver still activate the turn signal with the intention of changing lanes, the system issues an additional acoustic and/or haptic warning.
Problem Statement:
To develop one specific requirement of Highway Assistant – Lane Changing Assistant algorithm. Please note that the whole Highway Assistant – Lane Changing Assistant is a very huge algorithm & only one small part of the logic is implemented here. Idea is to familiarize with concepts of Autosar Software Component Development in MATLAB Environment by following the Model Based Development guidelines. The Project must be done keeping in mind the following processes & steps.
- 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 the model.
- All the input & output signals must be mapped into the Autosar Editor.
- Model Advisor Report is mandatory & this will be followed by Code Generation.
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 |

sldd file was created according to the requirement.

main model was created according to the requirement.

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 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 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 |

advisory report was run according to the maab guidlines, 16 warnings, 0 error were extracted

warnings were reduced to 14.

system target file was selected as autosar.tlc

interfaces were created before ports.

receiver ports were created

sender ports were created.

runnables were created

xml options were created
which includes:
/SWC_Project_Highway_Assistant_pkg/DataTypes
/SWC_Project_Highway_Assistant_pkg/Interfaces
/SWC_Project_Highway_Assistant_pkg/DataTypes/ApplDataTypes
/SWC_Project_Highway_Assistant_pkg/DataTypes/SwBaseDataTypes
/SWC_Project_Highway_Assistant_pkg/DataTypes/DataTypeMappings
/SWC_Project_Highway_Assistant_pkg/DataTypes/constants
/SWC_Project_Highway_Assistant_pkg/DataTypes/DataTypeConstrs
/SWC_Project_Highway_Assistant_pkg/DataTypes/SystemConstants
/SWC_Project_Highway_Assistant_pkg/DataTypes/CompuMethods
/SWC_Project_Highway_Assistant_pkg/DataTypes/Units
/SWC_Project_Highway_Assistant_pkg/DataTypes/DataConstrs

inports mapping was done

outports mapping was done

functions intializing was done

autosar code generation was done.
1 /*
2 * File: SWC_Project_Highway_Assistant.c
3 *
4 * Code generated for Simulink model 'SWC_Project_Highway_Assistant'.
5 *
6 * Model version : 1.1
7 * Simulink Coder version : 9.3 (R2020a) 18-Nov-2019
8 * C/C++ source code generated on : Mon Jan 24 01:55:23 2022
9 *
10 * Target selection: autosar.tlc
11 * Embedded hardware selection: Intel->x86-64 (Windows64)
12 * Code generation objectives: Unspecified
13 * Validation result: Not run
14 */
15
16 #include "SWC_Project_Highway_Assistant.h"
17 #include "SWC_Project_Highway_Assistant_private.h"
18
19 /* Named constants for Chart: '<S1>/Chart' */
20 #define SWC_Project_Highway_IN_Action_1 ((uint8)1U)
21 #define SWC_Project_Highway_IN_Action_2 ((uint8)2U)
22
23 /* Named constants for Chart: '<S1>/Chart1' */
24 #define SWC_Project_Highway_IN_Action_3 ((uint8)1U)
25 #define SWC_Project_Highway_IN_Action_4 ((uint8)2U)
26
27 /* Block states (default storage) */
28 DW_SWC_Project_Highway_Assist_T SWC_Project_Highway_Assistan_DW;
29
30 /* Model step function */
31 void SWC_Project_Highway_Assistant100ms(void)
32 {
33 uint8 rtb_Highway_Display_Mode_1;
34 uint8 rtb_Lane_Display_Mode_1;
35 uint8 rtb_Lane_Display_Mode_2;
36 uint8 rtb_Highway_Display_Mode_3;
37 uint8 rtb_Lane_Display_Mode_3;
38 uint8 rtb_Lane_Display_Mode_4;
39 sint32 tmp;
40
41 /* Chart: '<S1>/Chart' incorporates:
42 * Inport: '<Root>/Enable_Display'
43 * Inport: '<Root>/Highway_Input_Signal'
44 * Inport: '<Root>/Input_Switch'
45 */
46 if (SWC_Project_Highway_Assistan_DW.is_active_c3_SWC_Project_Highwa == 0U) {
47 SWC_Project_Highway_Assistan_DW.is_active_c3_SWC_Project_Highwa = 1U;
48 SWC_Project_Highway_Assistan_DW.is_c3_SWC_Project_Highway_Assis =
49 SWC_Project_Highway_IN_Action_1;
50 rtb_Highway_Display_Mode_1 = 232U;
51 rtb_Highway_Display_Mode_3 = 41U;
52 } else if (SWC_Project_Highway_Assistan_DW.is_c3_SWC_Project_Highway_Assis ==
53 SWC_Project_Highway_IN_Action_1) {
54 if ((Rte_IRead_SWC_Project_Highway_Assistant100ms_Rp_Highway_Input_Signal_DE_Highway_Input_Signal
55 () == 1) &&
56 (Rte_IRead_SWC_Project_Highway_Assistant100ms_Rp_Enable_Display_DE_Enable_Display
57 () == 1) &&
58 (Rte_IRead_SWC_Project_Highway_Assistant100ms_Rp_Input_Switch_DE_Input_Switch
59 () == 1)) {
60 SWC_Project_Highway_Assistan_DW.is_c3_SWC_Project_Highway_Assis =
61 SWC_Project_Highway_IN_Action_2;
62 rtb_Highway_Display_Mode_1 = 213U;
63 rtb_Highway_Display_Mode_3 = 9U;
64 } else {
65 rtb_Highway_Display_Mode_1 = 232U;
66 rtb_Highway_Display_Mode_3 = 41U;
67 }
68 } else {
69 /* case IN_Action_2: */
70 if ((Rte_IRead_SWC_Project_Highway_Assistant100ms_Rp_Highway_Input_Signal_DE_Highway_Input_Signal
71 () == 1) &&
72 (Rte_IRead_SWC_Project_Highway_Assistant100ms_Rp_Enable_Display_DE_Enable_Display
73 () == 0) &&
74 (Rte_IRead_SWC_Project_Highway_Assistant100ms_Rp_Input_Switch_DE_Input_Switch
75 () == 1)) {
76 SWC_Project_Highway_Assistan_DW.is_c3_SWC_Project_Highway_Assis =
77 SWC_Project_Highway_IN_Action_1;
78 rtb_Highway_Display_Mode_1 = 232U;
79 rtb_Highway_Display_Mode_3 = 41U;
80 } else {
81 rtb_Highway_Display_Mode_1 = 213U;
82 rtb_Highway_Display_Mode_3 = 9U;
83 }
84 }
85
86 /* End of Chart: '<S1>/Chart' */
87
88 /* Chart: '<S1>/Chart1' incorporates:
89 * Inport: '<Root>/Enable_Display'
90 * Inport: '<Root>/Input_Switch'
91 * Inport: '<Root>/Lane_Input_Signal'
92 */
93 if (SWC_Project_Highway_Assistan_DW.is_active_c1_SWC_Project_Highwa == 0U) {
94 SWC_Project_Highway_Assistan_DW.is_active_c1_SWC_Project_Highwa = 1U;
95 SWC_Project_Highway_Assistan_DW.is_c1_SWC_Project_Highway_Assis =
96 SWC_Project_Highway_IN_Action_3;
97 rtb_Lane_Display_Mode_1 = 132U;
98 rtb_Lane_Display_Mode_2 = 185U;
99 rtb_Lane_Display_Mode_3 = 54U;
100 rtb_Lane_Display_Mode_4 = 67U;
101 } else if (SWC_Project_Highway_Assistan_DW.is_c1_SWC_Project_Highway_Assis ==
102 SWC_Project_Highway_IN_Action_3) {
103 if ((Rte_IRead_SWC_Project_Highway_Assistant100ms_Rp_Lane_Input_Signal_DE_Lane_Input_Signal
104 () == 6) &&
105 (Rte_IRead_SWC_Project_Highway_Assistant100ms_Rp_Enable_Display_DE_Enable_Display
106 () == 1) &&
107 (Rte_IRead_SWC_Project_Highway_Assistant100ms_Rp_Input_Switch_DE_Input_Switch
108 () == 1)) {
109 SWC_Project_Highway_Assistan_DW.is_c1_SWC_Project_Highway_Assis =
110 SWC_Project_Highway_IN_Action_4;
111 rtb_Lane_Display_Mode_1 = 127U;
112 rtb_Lane_Display_Mode_2 = 248U;
113 rtb_Lane_Display_Mode_3 = 186U;
114 rtb_Lane_Display_Mode_4 = 84U;
115 } else {
116 rtb_Lane_Display_Mode_1 = 132U;
117 rtb_Lane_Display_Mode_2 = 185U;
118 rtb_Lane_Display_Mode_3 = 54U;
119 rtb_Lane_Display_Mode_4 = 67U;
120 }
121 } else {
122 /* case IN_Action_4: */
123 if ((Rte_IRead_SWC_Project_Highway_Assistant100ms_Rp_Lane_Input_Signal_DE_Lane_Input_Signal
124 () == 6) &&
125 (Rte_IRead_SWC_Project_Highway_Assistant100ms_Rp_Enable_Display_DE_Enable_Display
126 () == 0) &&
127 (Rte_IRead_SWC_Project_Highway_Assistant100ms_Rp_Input_Switch_DE_Input_Switch
128 () == 1)) {
129 SWC_Project_Highway_Assistan_DW.is_c1_SWC_Project_Highway_Assis =
130 SWC_Project_Highway_IN_Action_3;
131 rtb_Lane_Display_Mode_1 = 132U;
132 rtb_Lane_Display_Mode_2 = 185U;
133 rtb_Lane_Display_Mode_3 = 54U;
134 rtb_Lane_Display_Mode_4 = 67U;
135 } else {
136 rtb_Lane_Display_Mode_1 = 127U;
137 rtb_Lane_Display_Mode_2 = 248U;
138 rtb_Lane_Display_Mode_3 = 186U;
139 rtb_Lane_Display_Mode_4 = 84U;
140 }
141 }
142
143 /* End of Chart: '<S1>/Chart1' */
144
145 /* Switch: '<S1>/Switch' incorporates:
146 * Inport: '<Root>/Highway_Input_Signal'
147 * Switch: '<S1>/Switch1'
148 * Switch: '<S1>/Switch2'
149 */
150 tmp =
151 Rte_IRead_SWC_Project_Highway_Assistant100ms_Rp_Highway_Input_Signal_DE_Highway_Input_Signal
152 ();
153 if (tmp > 0) {
154 /* Outport: '<Root>/Display_Mode_1' */
155 Rte_IWrite_SWC_Project_Highway_Assistant100ms_Pp_Display_Mode_1_DE_Display_Mode_1
156 (rtb_Highway_Display_Mode_1);
157 rtb_Lane_Display_Mode_2 = 183U;
158 } else {
159 /* Outport: '<Root>/Display_Mode_1' */
160 Rte_IWrite_SWC_Project_Highway_Assistant100ms_Pp_Display_Mode_1_DE_Display_Mode_1
161 (rtb_Lane_Display_Mode_1);
162 }
163
164 /* End of Switch: '<S1>/Switch' */
165
166 /* Outport: '<Root>/Display_Mode_2' */
167 Rte_IWrite_SWC_Project_Highway_Assistant100ms_Pp_Display_Mode_2_DE_Display_Mode_2
168 (rtb_Lane_Display_Mode_2);
169
170 /* Switch: '<S1>/Switch2' incorporates:
171 * Switch: '<S1>/Switch3'
172 */
173 if (tmp > 0) {
174 /* Outport: '<Root>/Display_Mode_3' */
175 Rte_IWrite_SWC_Project_Highway_Assistant100ms_Pp_Display_Mode_3_DE_Display_Mode_3
176 (rtb_Highway_Display_Mode_3);
177 rtb_Lane_Display_Mode_4 = 94U;
178 } else {
179 /* Outport: '<Root>/Display_Mode_3' */
180 Rte_IWrite_SWC_Project_Highway_Assistant100ms_Pp_Display_Mode_3_DE_Display_Mode_3
181 (rtb_Lane_Display_Mode_3);
182 }
183
184 /* Outport: '<Root>/Display_Mode_4' */
185 Rte_IWrite_SWC_Project_Highway_Assistant100ms_Pp_Display_Mode_4_DE_Display_Mode_4
186 (rtb_Lane_Display_Mode_4);
187 }
188
189 /* Model initialize function */
190 void SWC_Project_Highway_Assistant100msInit(void)
191 {
192 /* (no initialization code required) */
193 }
194
195 /*
196 * File trailer for generated code.
197 *
198 * [EOF]
199 */
200