Project 2-Highway Assistant-Lane Changing Assistant
Highway Assistant – Lane Changing Assistant
Aim:
To create a Highway assistant and Lane changing Assitant feature using Matlab and simulink and to Address the Problem Statement.
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 |

Simulink Model:

- This is out model for Highway lane Changing Assistance.
- This model is created as per the objectives.
- we have 4 inputs as highway input signal, enable display, input switch and lane input signal.
- we also have 4 display modes as output.

- Inside the Highway lane changing assistance system we have highway display mode, lane display mode and display mode.
- Each subsystems are created as per the objectives.
- The highway Display mode is particularly for automated driving.
- the lane display mode is used to keeping the vehicle on the lane even when cruised.
- the Display mode provides the appropriate mode.
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”.

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



AutoSAR Mapping:

- the first step we do starts with model configuration.
- file > model settings > model configuration > Code Generation > select system target file as autosar.tlc by selecting browse option.
- task bar > apps > Autosar component > we will get the map shortcut in the bottom of the simulink screen.

- on the code mapping press on the configuration icon.
Step 2: Configure Autosar Dictionary
- click on the configure autosar dictionary icon, we will get a dialog box to configure the autosar dictionary.

- These are the areas where we are about to make changes.
- we will be start with XML options.

- first we will start with XML option and make the necessary changes.

- now while working on sender reciever interface, we will start with deleting the previous data and importing new data.
- as per the objectives we will assign the input and output starting with SRIf.
- for adding we use the "+" icon.

- now we are adding the data elements.
- as per the objectives we add prefix as DE for the data elements repective of input and output.

- now we will add the reciever data.
- for that we have to select the reciever port in the dailog box.
- as per objectives we will aadd Rp as prefix to the variables.

- now we will add the sender data.
- for that we have to select the sender ports in the dailog box.
- as per objectives we will aadd Pp as prefix to the variables.

- and the next we will be checking up for the runnables.
- we will give the events as timing events,

- Next we will be opening to open Inports.
- and we will make the neccessary changes like port and Elements.
- and choose appropriate port as Rp_Input_A and element as DE_Input_A.

- Next we will be opening to open outports.
- and we will make the neccessary changes like port and Elements.
- and choose appropriate port as Pp_Output_A and element as DE_Output_A.
Output:
- after all the steps we select the 'tick' options below the functions option.
- we will get an dialog box saying validation succeeded.
- which results that the model is changed to Autosar compliant model.
Code Generation : AutoSAR Coder
- Now we are going to generate the code out of the model.
- click on Autosar > Quick Start > click the neccessary options > the AutoSAR code will be generated.
/*
* File: P2_AS_HLA.c
*
* Code generated for Simulink model 'P2_AS_HLA'.
*
* Model version : 1.5
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Wed Mar 16 16:32:18 2022
*
* Target selection: autosar.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives:
* 1. Execution efficiency
* 2. RAM efficiency
* Validation result: Not run
*/
#include "P2_AS_HLA.h"
/* Named constants for Chart: '/Highway_Display_Mode_Logic' */
#define IN_Condtion_1 ((uint8_T)1U)
#define IN_Condtion_2 ((uint8_T)2U)
/* Block signals and states (default storage) */
DW rtDW;
/* Model step function */
void P2_AS_HLA_Step(void)
{
int32_T rtb_Highway_Display_Mode_1;
int32_T rtb_Highway_Display_Mode_3;
int32_T rtb_Lane_Display_Mode_1;
int32_T rtb_Lane_Display_Mode_2;
int32_T rtb_Lane_Display_Mode_3;
int32_T rtb_Lane_Display_Mode_4;
int32_T tmp_0;
uint8_T tmp;
/* {S!d24}Chart: '/Highway_Display_Mode_Logic' incorporates:
* Inport: '/Enable_Display'
* Inport: '/Highway_Input_Signal'
* Inport: '/Input_Switch'
*/
/*@>36dd*/if (/*@>7d18*/rtDW./*@>8322*/is_active_c3_P2_AS_HLA/*@>36db*/ == /*@>62cd*/0U) {
/*@>7d24*/rtDW./*@>8328*/is_active_c3_P2_AS_HLA/*@>36e5*/ = /*@>8216*/1U;
/*@>7d2a*/rtDW./*@>832b*/is_c3_P2_AS_HLA/*@>3714*/ = /*@>62e1*/IN_Condtion_1;
/*@>62f1*/rtb_Highway_Display_Mode_1/*@>3741*/ = /*@>821c*/232;
/*@>62f7*/rtb_Highway_Display_Mode_3/*@>3743*/ = /*@>8228*/41;
} else /*@>6017*/if (/*@>7d1e*/rtDW./*@>8325*/is_c3_P2_AS_HLA/*@>6016*/ == /*@>7d6c*/IN_Condtion_1) {
/*@>36e7*/if ((Rte_IRead_P2_AS_HLA_Step_Rp_Highway_Input_Signal_DE_Highway_Input_Signal()/*@>41c2*/ == /*@>6364*/1)/*@>41c1*/ && (Rte_IRead_P2_AS_HLA_Step_Rp_Enable_Display_DE_Enable_Display()/*@>41c7*/ == /*@>6365*/1)/*@>41c0*/ && (Rte_IRead_P2_AS_HLA_Step_Rp_Input_Switch_DE_Input_Switch()/*@>41cc*/ == /*@>6366*/1)) {
/*@>7d30*/rtDW./*@>832e*/is_c3_P2_AS_HLA/*@>36ea*/ = /*@>62d2*/IN_Condtion_2;
/*@>62fd*/rtb_Highway_Display_Mode_1/*@>3751*/ = /*@>8225*/213;
/*@>6303*/rtb_Highway_Display_Mode_3/*@>3753*/ = /*@>8231*/9;
} else {
/*@>62d3*/rtb_Highway_Display_Mode_1/*@>3702*/ = /*@>8219*/232;
/*@>62d9*/rtb_Highway_Display_Mode_3/*@>3704*/ = /*@>8222*/41;
}
/* case IN_Condtion_2: */
} else /*@>3716*/if ((Rte_IRead_P2_AS_HLA_Step_Rp_Highway_Input_Signal_DE_Highway_Input_Signal()/*@>41ae*/ == /*@>6361*/1)/*@>41ad*/ && (Rte_IRead_P2_AS_HLA_Step_Rp_Enable_Display_DE_Enable_Display()/*@>41b3*/ == /*@>6362*/0)/*@>41ac*/ && (Rte_IRead_P2_AS_HLA_Step_Rp_Input_Switch_DE_Input_Switch()/*@>41b8*/ == /*@>6363*/1)) {
/*@>7d36*/rtDW./*@>8331*/is_c3_P2_AS_HLA/*@>3719*/ = /*@>62e4*/IN_Condtion_1;
/*@>6309*/rtb_Highway_Display_Mode_1/*@>3761*/ = /*@>822e*/232;
/*@>630f*/rtb_Highway_Display_Mode_3/*@>3763*/ = /*@>8234*/41;
} else {
/*@>62e5*/rtb_Highway_Display_Mode_1/*@>3731*/ = /*@>821f*/213;
/*@>62eb*/rtb_Highway_Display_Mode_3/*@>3733*/ = /*@>822b*/9;
}
/* {E!d24}End of Chart: '/Highway_Display_Mode_Logic' */
/* {S!d26}Chart: '/Lane_Display_Logic' incorporates:
* Inport: '/Enable_Display'
* Inport: '/Input_Switch'
* Inport: '/Lane_Input_Signal'
*/
/*@>3795*/if (/*@>7d3c*/rtDW./*@>8334*/is_active_c1_P2_AS_HLA/*@>3793*/ == /*@>6318*/0U) {
/*@>7d48*/rtDW./*@>833a*/is_active_c1_P2_AS_HLA/*@>379d*/ = /*@>8237*/1U;
/*@>7d4e*/rtDW./*@>833d*/is_c1_P2_AS_HLA/*@>37cc*/ = /*@>632c*/IN_Condtion_1;
/*@>633c*/rtb_Lane_Display_Mode_1/*@>37f9*/ = /*@>823d*/132;
/*@>633f*/rtb_Lane_Display_Mode_2/*@>37fa*/ = /*@>8249*/185;
/*@>6342*/rtb_Lane_Display_Mode_3/*@>37fb*/ = /*@>8258*/54;
/*@>6345*/rtb_Lane_Display_Mode_4/*@>37fc*/ = /*@>8267*/67;
} else /*@>601c*/if (/*@>7d42*/rtDW./*@>8337*/is_c1_P2_AS_HLA/*@>601b*/ == /*@>7d6f*/IN_Condtion_1) {
/*@>379f*/if ((Rte_IRead_P2_AS_HLA_Step_Rp_Lane_Input_Signal_DE_Lane_Input_Signal()/*@>41ea*/ == /*@>636a*/1)/*@>41e9*/ && (Rte_IRead_P2_AS_HLA_Step_Rp_Enable_Display_DE_Enable_Display()/*@>41ef*/ == /*@>636b*/1)/*@>41e8*/ && (Rte_IRead_P2_AS_HLA_Step_Rp_Input_Switch_DE_Input_Switch()/*@>41f4*/ == /*@>636c*/1)) {
/*@>7d54*/rtDW./*@>8340*/is_c1_P2_AS_HLA/*@>37a2*/ = /*@>631d*/IN_Condtion_2;
/*@>6348*/rtb_Lane_Display_Mode_1/*@>3809*/ = /*@>8246*/127;
/*@>634b*/rtb_Lane_Display_Mode_2/*@>380a*/ = /*@>8255*/248;
/*@>634e*/rtb_Lane_Display_Mode_3/*@>380b*/ = /*@>8264*/186;
/*@>6351*/rtb_Lane_Display_Mode_4/*@>380c*/ = /*@>8270*/84;
} else {
/*@>631e*/rtb_Lane_Display_Mode_1/*@>37ba*/ = /*@>823a*/132;
/*@>6321*/rtb_Lane_Display_Mode_2/*@>37bb*/ = /*@>8243*/185;
/*@>6324*/rtb_Lane_Display_Mode_3/*@>37bc*/ = /*@>8252*/54;
/*@>6327*/rtb_Lane_Display_Mode_4/*@>37bd*/ = /*@>8261*/67;
}
/* case IN_Condtion_2: */
} else /*@>37ce*/if ((Rte_IRead_P2_AS_HLA_Step_Rp_Lane_Input_Signal_DE_Lane_Input_Signal()/*@>41d6*/ == /*@>6367*/1)/*@>41d5*/ && (Rte_IRead_P2_AS_HLA_Step_Rp_Enable_Display_DE_Enable_Display()/*@>41db*/ == /*@>6368*/0)/*@>41d4*/ && (Rte_IRead_P2_AS_HLA_Step_Rp_Input_Switch_DE_Input_Switch()/*@>41e0*/ == /*@>6369*/1)) {
/*@>7d5a*/rtDW./*@>8343*/is_c1_P2_AS_HLA/*@>37d1*/ = /*@>632f*/IN_Condtion_1;
/*@>6354*/rtb_Lane_Display_Mode_1/*@>3819*/ = /*@>824f*/132;
/*@>6357*/rtb_Lane_Display_Mode_2/*@>381a*/ = /*@>825e*/185;
/*@>635a*/rtb_Lane_Display_Mode_3/*@>381b*/ = /*@>826d*/54;
/*@>635d*/rtb_Lane_Display_Mode_4/*@>381c*/ = /*@>8273*/67;
} else {
/*@>6330*/rtb_Lane_Display_Mode_1/*@>37e9*/ = /*@>8240*/127;
/*@>6333*/rtb_Lane_Display_Mode_2/*@>37ea*/ = /*@>824c*/248;
/*@>6336*/rtb_Lane_Display_Mode_3/*@>37eb*/ = /*@>825b*/186;
/*@>6339*/rtb_Lane_Display_Mode_4/*@>37ec*/ = /*@>826a*/84;
}
/* {E!d26}End of Chart: '/Lane_Display_Logic' */
/* {S!d28}Switch: '/Switch' incorporates:
* Inport: '/Highway_Input_Signal'
* Switch: '/Switch1'
* Switch: '/Switch2'
* Switch: '/Switch3'
*/
/*@>6d82*/tmp_0/*@>6d84*/ = Rte_IRead_P2_AS_HLA_Step_Rp_Highway_Input_Signal_DE_Highway_Input_Signal();
/*@>6b84*/if (/*@>6d86*/tmp_0/*@>6979*/ != /*@>697d*/0) {
/*@>6b88*/tmp/*@>6b87*/ = /*@>697e*/(uint8_T)/*@>6980*/rtb_Highway_Display_Mode_1;
} else {
/*@>6b65*/tmp/*@>6b67*/ = /*@>6981*/(uint8_T)/*@>6983*/rtb_Lane_Display_Mode_1;
}
/* {E!d28}End of Switch: '/Switch' */
/* {S!d30}Outport: '/Display_Mode_1' */
Rte_IWrite_P2_AS_HLA_Step_Pp_Display_Mode_1_DE_Display_Mode_1(/*@>6b69*/tmp);
/* {S!d32}Switch: '/Switch1' */
/*@>6b89*/if (tmp_0/*@>6988*/ != /*@>698c*/0) {
/*@>6b8d*/tmp/*@>6b8c*/ = /*@>8276*/183U;
} else {
/*@>6b6d*/tmp/*@>6b6f*/ = /*@>698e*/(uint8_T)/*@>6990*/rtb_Lane_Display_Mode_2;
}
/* {S!d34}Outport: '/Display_Mode_2' */
Rte_IWrite_P2_AS_HLA_Step_Pp_Display_Mode_2_DE_Display_Mode_2(/*@>6b71*/tmp);
/* {S!d36}Switch: '/Switch2' */
/*@>6b8e*/if (tmp_0/*@>6995*/ != /*@>6999*/0) {
/*@>6b92*/tmp/*@>6b91*/ = /*@>699a*/(uint8_T)/*@>699c*/rtb_Highway_Display_Mode_3;
} else {
/*@>6b75*/tmp/*@>6b77*/ = /*@>699d*/(uint8_T)/*@>699f*/rtb_Lane_Display_Mode_3;
}
/* {S!d38}Outport: '/Display_Mode_3' */
Rte_IWrite_P2_AS_HLA_Step_Pp_Display_Mode_3_DE_Display_Mode_3(/*@>6b79*/tmp);
/* {S!d40}Switch: '/Switch3' */
/*@>6b93*/if (tmp_0/*@>69a4*/ != /*@>69a8*/0) {
/*@>6b97*/tmp/*@>6b96*/ = /*@>8279*/94U;
} else {
/*@>6b7d*/tmp/*@>6b7f*/ = /*@>69aa*/(uint8_T)/*@>69ac*/rtb_Lane_Display_Mode_4;
}
/* {S!d42}Outport: '/Display_Mode_4' */
Rte_IWrite_P2_AS_HLA_Step_Pp_Display_Mode_4_DE_Display_Mode_4(/*@>6b81*/tmp);
}
/* Model initialize function */
void P2_AS_HLA_Init(void)
{
/* (no initialization code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
RESULTS:
Thus the Highway assistant and Lane changing Assitant feature is created successfully using Matlab and simulink and the Problem Statement is also resolved
.