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.

here, is model based on given requirement
Main Model: Highway Lane Assist


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 |


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

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 |
SLDD creation:: based on following given signal we create sldd and link it with model
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 |


To configure AUTOSAR components in the AUTOSAR dictionary and generate AUTOSAR compliant Code, in The
Under App Section, AUTOSAR component Designer is Selected.

AUTOSAR dictionary can be accessed under code mappings - AUTOSAR SW Component section.

so, In AUTOSAR Dictionary first i chosed XML options and Specifying the package paths.

- Sender receiver interfaces(SRIf) is configured next.
- A total of eight sender receiver interfaces will be created as there are four inputs and four outputs for the main
subsystem 'Lane_Change_Assistance' - each sender receiver interfaces is prefixed with SRIf_
- The corresponding Data Element(DE_) of each SRIf is also renamed with DE_.



After Configuring XML options, SRIf, sender and receiver ports the runnable are configured next.
two runnable are created one for the intialization event and another for the timing event


After configure all required data in AUTOSAR dictionary , the Inports and Outports of the developed model are
mapped to their corresponding receiver/sender ports and data element.


So, here we can see that code mapping are updated and validated as the final step to make sure all ports are
mapped correctly.

- So, after generate AUTOSAR dictionary we need to check Model advisor report.
- here we are checking model advisor for the Modeling Standards For MAB(Mathworks Advisory Board)
- so we can see that we passed all the checks without any failure and i also tried to reduce no. of warnings.

Model Advisor Report for MAB Guidelines:

- Autosar Compliant Code generation:
- For generating AUTOSAR Code we need to go into AUTOSAR tab
- where we find "Quick start" option which we need to select for AUTOSAR Code generation.

click on NEXT >>> NEXT >>> NEXT......




The quick start option will automatically manage model configuration settings to generate code.
the code generation folder will contain generated .c, .h, .ARXML Files



AUTOSAR C CODE:::
/*
2 * File: project2.c
3 *
4 * Code generated for Simulink model 'project2'.
5 *
6 * Model version : 1.26
7 * Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
8 * C/C++ source code generated on : Fri Oct 28 19:57:36 2022
9 *
10 * Target selection: autosar.tlc
11 * Embedded hardware selection: Intel->x86-64 (Windows64)
12 * Code generation objectives:
13 * 1. Execution efficiency
14 * 2. RAM efficiency
15 * Validation result: Not run
16 */
17
18 #include "project2.h"
19
20 /* Named constants for Chart: '<S3>/Chart' */
21 #define IN_Condition1 ((uint8)1U)
22 #define IN_Condition2 ((uint8)2U)
23
24 /* Named constants for Chart: '<S4>/Chart' */
25 #define IN_Condotion1 ((uint8)1U)
26 #define IN_Condotion2 ((uint8)2U)
27
28 /* Block signals and states (default storage) */
29 DW rtDW;
30
31 /* Model step function */
32 void Project2_Step(void)
33 {
34 sint32 rtb_Highway_Display_Mode_1;
35 sint32 rtb_Highway_Display_Mode_3;
36 sint32 rtb_Lane_Display_Mode_1;
37 sint32 rtb_Lane_Display_Mode_2;
38 sint32 rtb_Lane_Display_Mode_3;
39 sint32 rtb_Lane_Display_Mode_4;
40 sint32 tmp_0;
41 uint8 tmp;
42
43 /* Chart: '<S3>/Chart' incorporates:
44 * Inport: '<Root>/Enable_Display'
45 * Inport: '<Root>/Highway_Input_Signal'
46 * Inport: '<Root>/Input_Switch'
47 */
48 if (rtDW.is_active_c3_project2 == 0U) {
49 rtDW.is_active_c3_project2 = 1U;
50 rtDW.is_c3_project2 = IN_Condition1;
51 rtb_Highway_Display_Mode_1 = 232;
52 rtb_Highway_Display_Mode_3 = 41;
53 } else if (rtDW.is_c3_project2 == IN_Condition1) {
54 rtb_Highway_Display_Mode_1 = 232;
55 rtb_Highway_Display_Mode_3 = 41;
56 if ((Rte_IRead_Project2_Step_Rp_Highway_Input_Signal_DE_Display_Module_1() ==
57 1) && (Rte_IRead_Project2_Step_Rp_Enable_Display_DE_Display_Module_1() ==
58 1) &&
59 (Rte_IRead_Project2_Step_Rp_Input_Switch_DE_Display_Module_1() == 1)) {
60 rtDW.is_c3_project2 = IN_Condition2;
61 rtb_Highway_Display_Mode_1 = 213;
62 rtb_Highway_Display_Mode_3 = 9;
63 }
64 } else {
65 /* case IN_Condition2: */
66 rtb_Highway_Display_Mode_1 = 213;
67 rtb_Highway_Display_Mode_3 = 9;
68 if ((Rte_IRead_Project2_Step_Rp_Highway_Input_Signal_DE_Display_Module_1() ==
69 1) && (Rte_IRead_Project2_Step_Rp_Enable_Display_DE_Display_Module_1() ==
70 0) &&
71 (Rte_IRead_Project2_Step_Rp_Input_Switch_DE_Display_Module_1() == 1)) {
72 rtDW.is_c3_project2 = IN_Condition1;
73 rtb_Highway_Display_Mode_1 = 232;
74 rtb_Highway_Display_Mode_3 = 41;
75 }
76 }
77
78 /* End of Chart: '<S3>/Chart' */
79
80 /* Chart: '<S4>/Chart' incorporates:
81 * Inport: '<Root>/Enable_Display'
82 * Inport: '<Root>/Input_Switch'
83 * Inport: '<Root>/Lane_Input_Signal'
84 */
85 if (rtDW.is_active_c1_project2 == 0U) {
86 rtDW.is_active_c1_project2 = 1U;
87 rtDW.is_c1_project2 = IN_Condotion1;
88 rtb_Lane_Display_Mode_1 = 132;
89 rtb_Lane_Display_Mode_2 = 185;
90 rtb_Lane_Display_Mode_3 = 54;
91 rtb_Lane_Display_Mode_4 = 67;
92 } else if (rtDW.is_c1_project2 == IN_Condotion1) {
93 rtb_Lane_Display_Mode_1 = 132;
94 rtb_Lane_Display_Mode_2 = 185;
95 rtb_Lane_Display_Mode_3 = 54;
96 rtb_Lane_Display_Mode_4 = 67;
97 if ((Rte_IRead_Project2_Step_Rp_Lane_Input_Signal_DE_Display_Module_1() == 6)
98 && (Rte_IRead_Project2_Step_Rp_Enable_Display_DE_Display_Module_1() == 1)
99 && (Rte_IRead_Project2_Step_Rp_Input_Switch_DE_Display_Module_1() == 1))
100 {
101 rtDW.is_c1_project2 = IN_Condotion2;
102 rtb_Lane_Display_Mode_1 = 127;
103 rtb_Lane_Display_Mode_2 = 248;
104 rtb_Lane_Display_Mode_3 = 186;
105 rtb_Lane_Display_Mode_4 = 84;
106 }
107 } else {
108 /* case IN_Condotion2: */
109 rtb_Lane_Display_Mode_1 = 127;
110 rtb_Lane_Display_Mode_2 = 248;
111 rtb_Lane_Display_Mode_3 = 186;
112 rtb_Lane_Display_Mode_4 = 84;
113 if ((Rte_IRead_Project2_Step_Rp_Lane_Input_Signal_DE_Display_Module_1() == 6)
114 && (Rte_IRead_Project2_Step_Rp_Enable_Display_DE_Display_Module_1() == 0)
115 && (Rte_IRead_Project2_Step_Rp_Input_Switch_DE_Display_Module_1() == 1))
116 {
117 rtDW.is_c1_project2 = IN_Condotion1;
118 rtb_Lane_Display_Mode_1 = 132;
119 rtb_Lane_Display_Mode_2 = 185;
120 rtb_Lane_Display_Mode_3 = 54;
121 rtb_Lane_Display_Mode_4 = 67;
122 }
123 }
124
125 /* End of Chart: '<S4>/Chart' */
126
127 /* Switch: '<S2>/Switch' incorporates:
128 * Inport: '<Root>/Highway_Input_Signal'
129 * Switch: '<S2>/Switch1'
130 * Switch: '<S2>/Switch2'
131 * Switch: '<S2>/Switch3'
132 */
133 tmp_0 = Rte_IRead_Project2_Step_Rp_Highway_Input_Signal_DE_Display_Module_1();
134 if (tmp_0 > 0) {
135 tmp = (uint8)rtb_Highway_Display_Mode_1;
136 } else {
137 tmp = (uint8)rtb_Lane_Display_Mode_1;
138 }
139
140 /* End of Switch: '<S2>/Switch' */
141
142 /* Outport: '<Root>/Highway_Display_Mode_1' */
143 Rte_IWrite_Project2_Step_Highway_Display_Mode_1_Highway_Display_Mode_1(tmp);
144
145 /* Switch: '<S2>/Switch1' */
146 if (tmp_0 > 0) {
147 tmp = 183U;
148 } else {
149 tmp = (uint8)rtb_Lane_Display_Mode_2;
150 }
151
152 /* Outport: '<Root>/Highway_Display_Mode_2' */
153 Rte_IWrite_Project2_Step_Highway_Display_Mode_2_Highway_Display_Mode_2(tmp);
154
155 /* Switch: '<S2>/Switch2' */
156 if (tmp_0 > 0) {
157 tmp = (uint8)rtb_Highway_Display_Mode_3;
158 } else {
159 tmp = (uint8)rtb_Lane_Display_Mode_3;
160 }
161
162 /* Outport: '<Root>/Highway_Display_Mode_3' */
163 Rte_IWrite_Project2_Step_Highway_Display_Mode_3_Highway_Display_Mode_3(tmp);
164
165 /* Switch: '<S2>/Switch3' */
166 if (tmp_0 > 0) {
167 tmp = 94U;
168 } else {
169 tmp = (uint8)rtb_Lane_Display_Mode_4;
170 }
171
172 /* Outport: '<Root>/Highway_Display_Mode_4' */
173 Rte_IWrite_Project2_Step_Highway_Display_Mode_4_Highway_Display_Mode_4(tmp);
174 }
175
176 /* Model initialize function */
177 void Project2_Init(void)
178 {
179 /* (no initialization code required) */
180 }
181
182 /*
183 * File trailer for generated code.
184 *
185 * [EOF]
186 */
187
CONCLUSION:
- Highway Lane Assistant developed in MATLAB Simulink as per MBD guidelines.
- Code Generation Profile is Autosar Coder.
- Simulink Data Dictionary created for the model & linked to the model.
- All the input & output signals mapped into the Autosar Editor.
- Model Advisor Report is Generated & this will be followed by Code Generation.
- All the important Files like model, Code Report, SLDD file, Model Advisor report are Attached.