Challenge

Project 2-Highway Assistant-Lane Changing Assistant

AIM :

To develop a Simulink model to develop one specific requirement of Highway Assistant – Lane Changing Assistant algorithm. 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.

Objective of Main Project :

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.

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

THEORY :

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.

Simulation :

There are some steps to be followed to develop the model of Highway Assistant–Lane Changing feature. They are mainly as follows;

Step-1 - Develop the Simulink data library for the model from the given data :

Under modelling, Link to data dictionary enables us to create a new SLDD for our model. Otherwise, in the modelling tab select the model properties option, where a pop up appears. Then, select new and give the name of the SLDD. After providing its name deselect the enable model access to base workspace option and click apply and OK and open the SLDD file.

The SLDD is designed based on the data given below:

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

The following Simulink data dictionary is created based on the data of the input, local and output signals given above in the design data option.

Step-2 - Change the model settings to AUTOSAR compliance changes (changing the system target file to autosar.tlc) :

There are some steps to be followed to develop the model of Highway Assistant–Lane Changing feature. First, changed the model settings to AUTOSAR compliance changes. AUTOSAR compliance settings includes solver type to be changed to Fixed-step and discrete (no continuous states) and fixed step size to 0.01s. Under the code generation the target file is changed to autosar.tlc file. For changing the settings to AUTOSAR compliance changes, first click on the modelling tab and go to model configuration parameters and do the following changes.

Step-3 - Develop the Simulink model :

Here, the Simulink model is created based on the given requirements along with the given data of the input, local and output signals, by taking into consideration the MBD guidelines. Based on the given requirements, separate subsystems are made for requirement 1, requirement 2 and requirement 3.

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

Here, the signals “Highway_Input_Signal”, “Enable_Display” and “Input_Switch” are given as input signals to a chart block and the output signals taken from the chart are “Highway_Display_Mode_1”, “Highway_Display_Mode_2”, “Highway_Display_Mode_3” and “Highway_Display_Mode_4”.

The stateflow logic is given below;

Here, the Condition 1 is taken as the first state with the entry conditions Highway_Display_Mode_1 = 232, Highway_Display_Mode_2 = 183, Highway_Display_Mode_3 = 41 and Highway_Display_Mode_4 = 94. When the transition conditions are [(Highway_Input_Signal == 1) && (Enable_Display == 1) && (Input_Switch == 1)], then it switches to the second state with Condition 2 with the entry conditions Highway_Display_Mode_1 = 213, Highway_Display_Mode_2 = 183, Highway_Display_Mode_3 = 9 and Highway_Display_Mode_4 = 94. When the transition conditions are [(Highway_Input_Signal == 1) && (Enable_Display == 0) && (Input_Switch == 1)], it reverts back to the first state.

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

Here, the signals “Enable_Display”, “Input_Switch” and “Lane_Input_Signal” are given as input signals to a chart block and the output signals taken from the chart are “Lane_Display_Mode_1”, “Lane_Display_Mode_2”, “Lane_Display_Mode_3” and “Lane_Display_Mode_4”.

The stateflow logic is given below;

Here, the Condition 3 is taken as the first state with the entry conditions Lane_Display_Mode_1 = 132, Lane_Display_Mode_2 = 185, Lane_Display_Mode_3 = 54 and Lane_Display_Mode_4 = 67. When the transition conditions are [(Lane_Input_Signal == 6) && (Enable_Display == 1) && (Input_Switch == 1)], then it switches to the second state with Condition 4 with the entry conditions Lane_Display_Mode_1 = 127, Lane_Display_Mode_2 = 248, Lane_Display_Mode_3 = 186 and Lane_Display_Mode_4 = 84. When the transition conditions are [(Lane_Input_Signal == 6) && (Enable_Display == 0) && (Input_Switch == 1)], it reverts back to the first state.

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

Here, the subsystem is created as per the requirement given above, where the signals “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”. Also, the signals “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”. Then, the signals “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”. Lastly, the signals “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”.

Determine resolved signals and propagate signals in the model :

Step-4 - Model Advisory Check for MAB standards :

In the modelling tab, first select the Model Advisor window. Under Model Advisor window, choose by task and select modeling standards for MAB and select run selected checks option on the right.

After the checks, a report will be developed showing the pass, fail and warnings for the model. The report shown below indicates that 130 checks has been passed, 0 had failed failed and there are 14 warnings present in the model. So, the model is now ready, taking into considerations the MBD and MAAB guidelines. The model advisory report is given below;

Step-5 : Open Autosar Dictionary to update the Ports, Interfaces and Data elements :

First, from the apps tab, select the Autosar component. It opens a window with the Code mappings for Autosar SW Component option in the window. Then, click on the Code Mappings - AUTOSAR Component option, which open a drop down window below giving the options for port mappings;

Then, click on the Autosar dictionary option to open it. In the Autosar dictionary window, select the XML option and it is filled selectively as shown below;

After filling the necessary options, select the Internal DataConstraints Export option and click apply to save changes. Then, create an excel sheet file with the details of the following sender, reciever, S-R interfaces, data elements and runnables details as given below;

After creating the excel sheet with following details, add the S-R interfaces one by one for both the 4 inport and 4 outport signals, where they are prefixed with SRIf_ as given below;

After adding the S-R interfaces, save the changes. Then, after saving changes, add the respective data elements to the particular S-R interfaces, where they are prefixed with DE_ as given below;

After adding the corresponding data elements and saving them, then map the reciever ports of the 4 inport signals, where they are prefixed with Rp_ as shown below;

After mapping and saving the reciever ports, add the following sender ports of the 4 outport signals, where they are prefixed with Pp_ as given below;

After mapping and saving the sender ports, then add the runnables. Here, two runnables are added, one as an Init event and the other as a Timing event.

Then, click apply to save changes. After adding all the sender ports, reciever ports, S-R interfaces, data elements and runnables, then also map them in the Code Mappings - AUTOSAR Component option in the main window as given below;

After mapping all the ports, click on the tick option in the Code Mappings - AUTOSAR Component option for validating the whole model.

Step-6 : Code generation using AUTOSAR Coder :

At last, code generation is done using AUTOSAR Coder. In the apps tab, Autosar component is selected which opens the Autosar code generation options as given below;

Here, the generate code is selected, which generates the code generation report, that is selected by clicking on open report. The code generation is done as .c files and .h files.

CONCLUSION :

A Simulink model for the Highway Assistant–Lane Changing feature was developed with the given requirements and the model advisory check for the model was done and the results showed zero failed conditions and less than 15 warnings for MAB standards. Also, AUTOSAR Port mapping is also achieved. The model advisory report and AUTOSAR generated code is generated as .c and .h files for the model are attached with this report.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.