Project 2-Highway Assistant-Lane Changing Assistant
Aim:
Modelling a Highway Assistant feature-Lane Changing Assistant using MATLAB and Simulink in accordance with MAAB requirements, creating a Model Advisor Report, and generating code using AUTOSAR Coder.
Objective:
Model Development in MATLAB Simulink as per MAAB guidelines.
Code Generation using Autosar Coder.
Creation of Simulink Data Dictionary.
Mapping all the input & output signals into the Autosar Editor.
Generating Model Advisor Report.
Highway Assistant – Lane Changing Assistant:
In monotonous highway driving circumstances, the Highway Assistant assists the driver by taking over longitudinal and lateral vehicle direction. To a certain extent, the partially automated function may start, accelerate, brake, and steer the vehicle. The driver must constantly monitor the system and be prepared to take total control of the vehicle at any time.
Highway Assistant-Lane Changing Assistant
Drivers are trained to check their rear view and side mirrors, as well as look over each shoulder, before changing lanes. Even for those who adhere to this checklist, the car's blind spot - the region beside and immediately behind the vehicle – is a continual source of risk and is frequently the cause of catastrophic accidents. Vehicles approaching rapidly from behind might also be dangerous. This functionality was created to make changing lanes safer.
Basic Working Principle
Highway Assistant is a semi-automated driving capability for highway speeds of up to 180 km/h (112 mph). It combines Adaptive Cruise Control (ACCradar-based )'s longitudinal guiding with lane-keeping support's video-based lateral guidance in a single system. Highway Assistant can be augmented with a driver-initiated and monitored automated lane change at speeds ranging from 60 to 130 km/h (35 to 80 mph).The Lane Change Assistant works by concealing two mid-range radar sensors in the rear bumper — one on the left and one on the right. The region alongside and behind the automobile is monitored by these two sensors. The sensor data is combined by powerful control software to provide a comprehensive picture of all traffic in the region behind the vehicle. When another vehicle comes from behind at high speed or is already in the driver's blind spot, a signal such as a warning light in the side mirror warns the driver to the threat. If the motorist continues to use the turn signal with the purpose of changing lanes, the system will deliver 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:
The first step is the creation of the Simulink Data Dictionary File from the given calibration and signal data list.

SIMULINK MODEL

SUBSYSTEM HALCA

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.

HIGHWAY DISPLAY UNIT



LANE DISPLAY UNIT


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

Code Generation configuration parameters:
System target file is changed to autosar.tlc and solver is set Fixed step Discrete. Then under App, AUTOSAR component is selected. This will open Code Mapping - AUTOSAR SW Component. Using AUTOSAR directory, S-R interfaces along with receiver and sender ports are added.

For the Reciever port of the model, that is input, we will rename the port with the prefix "Rp_".

For the Sender port of the model, that is output, we will rename the port with the prefix "Pp_".

For the S-R Interfaces of the model, we will rename the port with the prefix "SRIf_".

For the Data Elements of the model, we will rename the port with the prefix "DE_".

Runnable:

AUTOSAR Validation:

AUTOSAR validation is successfully done.
Model advisor:
Model Advisor check is done for modelling standards for MAAB

REPORT GENERATED WITHOUT FAIL & ATTACHED

Code Generation:
* File: HALCA.c
* Code generated for Simulink model 'HALCA'.
* Model version : 1.40
* Simulink Coder version : 9.3 (R2020a) 18-Nov-2019
* C/C++ source code generated on : Fri Sep 17 17:38:01 2021
* 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 "HALCA.h"
/* Named constants for Chart: '/Highway_DisplayUnit_Logic' */
#define IN_Condition_1 ((uint8)1U)
#define IN_Condition_2 ((uint8)2U)
#define IN_Initstate ((uint8)3U)
/* Named constants for Chart: '/Lane_DisplayUnit_Logic' */
#define IN_Condition_2_k ((uint8)1U)
#define IN_Condition_3 ((uint8)2U)
/* Block signals and states (default storage) */
DW rtDW;
/* Model step function */
void HALCA_Step(void)
{
sint32 tmp;
sint32 tmp_0;
sint32 tmp_1;
/* Chart: '/Highway_DisplayUnit_Logic' incorporates:
* Inport: '/Enable_Display'
* Inport: '/Highway_Input_Signal'
* Inport: '/Input_Switch'
*/
if (rtDW.is_active_c3_HALCA == 0U) {
rtDW.is_active_c3_HALCA = 1U;
rtDW.is_c3_HALCA = IN_Initstate;
} else {
switch (rtDW.is_c3_HALCA) {
case IN_Condition_1:
rtDW.Highway_Display_Mode_1 = 232U;
rtDW.Highway_Display_Mode_2 = 183U;
rtDW.Highway_Display_Mode_3 = 41U;
rtDW.Highway_Display_Mode_4 = 94U;
break;
case IN_Condition_2:
rtDW.Highway_Display_Mode_1 = 213U;
rtDW.Highway_Display_Mode_2 = 183U;
rtDW.Highway_Display_Mode_3 = 9U;
rtDW.Highway_Display_Mode_4 = 94U;
break;
default:
/* case IN_Initstate: */
tmp = Rte_IRead_HALCA_Step_Rp_Highway_Input_Signal_DE_Highway_Input_Signal
();
tmp_0 = Rte_IRead_HALCA_Step_Rp_Enable_Display_DE_Input_Switch();
tmp_1 = Rte_IRead_HALCA_Step_Rp_Input_Switch_DE_Input_Switch();
if ((tmp == 1) && (tmp_0 == 1) && (tmp_1 == 1)) {
rtDW.is_c3_HALCA = IN_Condition_2;
rtDW.Highway_Display_Mode_1 = 213U;
rtDW.Highway_Display_Mode_2 = 183U;
rtDW.Highway_Display_Mode_3 = 9U;
rtDW.Highway_Display_Mode_4 = 94U;
} else {
if ((tmp == 1) && (tmp_0 == 0) && (tmp_1 == 1)) {
rtDW.is_c3_HALCA = IN_Condition_1;
rtDW.Highway_Display_Mode_1 = 232U;
rtDW.Highway_Display_Mode_2 = 183U;
rtDW.Highway_Display_Mode_3 = 41U;
rtDW.Highway_Display_Mode_4 = 94U;
}
}
break;
}
}
/* End of Chart: '/Highway_DisplayUnit_Logic' */
/* Chart: '/Lane_DisplayUnit_Logic' incorporates:
* Inport: '/Enable_Display'
* Inport: '/Input_Switch'
* Inport: '/Lane_Input_Signal'
*/
if (rtDW.is_active_c1_HALCA == 0U) {
rtDW.is_active_c1_HALCA = 1U;
rtDW.is_c1_HALCA = IN_Initstate;
} else {
switch (rtDW.is_c1_HALCA) {
case IN_Condition_2_k:
rtDW.Lane_Display_Mode_1 = 132U;
rtDW.Lane_Display_Mode_2 = 185U;
rtDW.Lane_Display_Mode_3 = 54U;
rtDW.Lane_Display_Mode_4 = 67U;
break;
case IN_Condition_3:
rtDW.Lane_Display_Mode_1 = 127U;
rtDW.Lane_Display_Mode_2 = 248U;
rtDW.Lane_Display_Mode_3 = 186U;
rtDW.Lane_Display_Mode_4 = 84U;
break;
default:
/* case IN_Initstate: */
tmp = Rte_IRead_HALCA_Step_Rp_Lane_Input_Signal_DE_Lane_Input_Signal();
tmp_0 = Rte_IRead_HALCA_Step_Rp_Enable_Display_DE_Input_Switch();
tmp_1 = Rte_IRead_HALCA_Step_Rp_Input_Switch_DE_Input_Switch();
if ((tmp == 6) && (tmp_0 == 0) && (tmp_1 == 1)) {
rtDW.is_c1_HALCA = IN_Condition_2_k;
rtDW.Lane_Display_Mode_1 = 132U;
rtDW.Lane_Display_Mode_2 = 185U;
rtDW.Lane_Display_Mode_3 = 54U;
rtDW.Lane_Display_Mode_4 = 67U;
} else {
if ((tmp == 6) && (tmp_0 == 1) && (tmp_1 == 1)) {
rtDW.is_c1_HALCA = IN_Condition_3;
rtDW.Lane_Display_Mode_1 = 127U;
rtDW.Lane_Display_Mode_2 = 248U;
rtDW.Lane_Display_Mode_3 = 186U;
rtDW.Lane_Display_Mode_4 = 84U;
}
}
break;
}
}
/* End of Chart: '/Lane_DisplayUnit_Logic' */
/* Switch: '/Switch' incorporates:
* Inport: '/Highway_Input_Signal'
* Switch: '/Switch1'
* Switch: '/Switch2'
* Switch: '/Switch3'
if (Rte_IRead_HALCA_Step_Rp_Highway_Input_Signal_DE_Highway_Input_Signal() !=
0) {
/* Outport: '/Display_Mode_1' */
Rte_IWrite_HALCA_Step_Pp_Display_Mode_1_DE_Display_Mode_1
(rtDW.Highway_Display_Mode_1);
/* Outport: '/Display_Mode_2' */
Rte_IWrite_HALCA_Step_Pp_Display_Mode_2_DE_Display_Mode_2
(rtDW.Highway_Display_Mode_2);
/* Outport: '/Display_Mode_3' */
Rte_IWrite_HALCA_Step_Pp_Display_Mode_3_DE_Display_Mode_3
(rtDW.Highway_Display_Mode_3);
/* Outport: '/Display_Mode_4' */
Rte_IWrite_HALCA_Step_Pp_Display_Mode_4_DE_Display_Mode_4
(rtDW.Highway_Display_Mode_4);
} else {
/* Outport: '/Display_Mode_1' */
Rte_IWrite_HALCA_Step_Pp_Display_Mode_1_DE_Display_Mode_1
(rtDW.Lane_Display_Mode_1);
/* Outport: '/Display_Mode_2' */
Rte_IWrite_HALCA_Step_Pp_Display_Mode_2_DE_Display_Mode_2
(rtDW.Lane_Display_Mode_2);
/* Outport: '/Display_Mode_3' */
Rte_IWrite_HALCA_Step_Pp_Display_Mode_3_DE_Display_Mode_3
(rtDW.Lane_Display_Mode_3);
/* Outport: '/Display_Mode_4' */
Rte_IWrite_HALCA_Step_Pp_Display_Mode_4_DE_Display_Mode_4
(rtDW.Lane_Display_Mode_4);
}
/* End of Switch: '/Switch' */
}
/* Model initialize function */
void HALCA_Init(void)
{
/* (no initialization code required) */
}

Conclusion:
According to MAAB requirements, a model of a feature of Highway Assistant-Lane Changing Assistant is modelled, generated a Model Advisor Report, and generated code using AUTOSAR Coder