Project 2-Highway Assistant-Lane Changing Assistant
Aim: To develop an algorithm for one of the features of the Highway Lane Changing Assistance, create a Simulink Data Dictionary for the given signals data list, develop a Model Advisor Report and generate a C code for it using Autosar coder in Simulink.
Objectives:
- 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.
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.
Signals data lists:
| 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 |
| 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 |
| Display_Mode_1 | uint8 | 0 – 255 |
| Display_Mode_2 | uint8 | 0 – 255 |
| Display_Mode_3 | uint8 | 0 – 255 |
| Display_Mode_4 | uint8 | 0 – 255 |
Procedure:
The first step is to create Simulink Data Dictionry from the given Signals and Calibration Value

Requirement 1: Highway Display Unit
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.




Requiement 2: Lane Display Unit
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.




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

Follwing figure shows the subsystem consist of all the three requirements:

Following figure shows the Highway Lane Changing Assistance with all inputs and outputs in Simulink model:

Now we are making model incomplience with the AUTOSAR for that first we have to do some configuration parameter settings as shown in the below image:
Then under apps settings click on the AUTOSAR components and it will open as shown in the below:

After clicking simulation option will get new window as showed below and Select S-R interface to enter the signal names:

Then by clicking the Sender and Receiver port option will enter the input and output signals:

And now we are mapping inports of the model:

Mapping outports of the model and click on the highlighted right mark option:
AUTOSAR Validation:

Model Advisor Report:

.C Code generation:
/*
* Trial License - for use to evaluate programs for possible purchase as
* an end-user only.
*
* File: Subsystem.c
*
* Code generated for Simulink model 'Subsystem'.
*
* Model version : 1.3
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Tue Sep 21 17:05:45 2021
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "Subsystem.h"
#include "Subsystem_private.h"
/* Named constants for Chart: '/Chart' */
#define Subsystem_IN_Condition1 ((uint8_T)1U)
#define Subsystem_IN_Condition2 ((uint8_T)2U)
/* Block states (default storage) */
DW_Subsystem_T Subsystem_DW;
/* External inputs (root inport signals with default storage) */
ExtU_Subsystem_T Subsystem_U;
/* External outputs (root outports fed by signals with default storage) */
ExtY_Subsystem_T Subsystem_Y;
/* Real-time model */
static RT_MODEL_Subsystem_T Subsystem_M_;
RT_MODEL_Subsystem_T *const Subsystem_M = &Subsystem_M_;
/* Model step function */
void Subsystem_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;
/* Outputs for Atomic SubSystem: '/Subsystem' */
/* Chart: '/Chart' incorporates:
* Inport: '/Enable_Display'
* Inport: '/Highway_Input_Signal'
* Inport: '/Input_Switch'
*/
if (Subsystem_DW.is_active_c3_Subsystem == 0U) {
Subsystem_DW.is_active_c3_Subsystem = 1U;
Subsystem_DW.is_c3_Subsystem = Subsystem_IN_Condition1;
rtb_Highway_Display_Mode_1 = 232;
rtb_Highway_Display_Mode_3 = 41;
} else if (Subsystem_DW.is_c3_Subsystem == Subsystem_IN_Condition1) {
rtb_Highway_Display_Mode_1 = 232;
rtb_Highway_Display_Mode_3 = 41;
if ((Subsystem_U.Highway_Input_Signal == 1.0) && (Subsystem_U.Enable_Display
== 1.0) && (Subsystem_U.Input_Switch == 1.0)) {
Subsystem_DW.is_c3_Subsystem = Subsystem_IN_Condition2;
rtb_Highway_Display_Mode_1 = 213;
rtb_Highway_Display_Mode_3 = 9;
}
} else {
/* case IN_Condition2: */
rtb_Highway_Display_Mode_1 = 213;
rtb_Highway_Display_Mode_3 = 9;
if ((Subsystem_U.Highway_Input_Signal == 1.0) && (Subsystem_U.Enable_Display
== 0.0) && (Subsystem_U.Input_Switch == 1.0)) {
Subsystem_DW.is_c3_Subsystem = Subsystem_IN_Condition1;
rtb_Highway_Display_Mode_1 = 232;
rtb_Highway_Display_Mode_3 = 41;
}
}
/* End of Chart: '/Chart' */
/* Chart: '/Chart' incorporates:
* Inport: '/Enable_Display'
* Inport: '/Input_Switch'
* Inport: '/Lane_Input_Signal'
*/
if (Subsystem_DW.is_active_c1_Subsystem == 0U) {
Subsystem_DW.is_active_c1_Subsystem = 1U;
Subsystem_DW.is_c1_Subsystem = Subsystem_IN_Condition1;
rtb_Lane_Display_Mode_1 = 132;
rtb_Lane_Display_Mode_2 = 185;
rtb_Lane_Display_Mode_3 = 54;
rtb_Lane_Display_Mode_4 = 67;
} else if (Subsystem_DW.is_c1_Subsystem == Subsystem_IN_Condition1) {
rtb_Lane_Display_Mode_1 = 132;
rtb_Lane_Display_Mode_2 = 185;
rtb_Lane_Display_Mode_3 = 54;
rtb_Lane_Display_Mode_4 = 67;
if ((Subsystem_U.Lane_Input_Signal == 6.0) && (Subsystem_U.Enable_Display ==
1.0) && (Subsystem_U.Input_Switch == 1.0)) {
Subsystem_DW.is_c1_Subsystem = Subsystem_IN_Condition2;
rtb_Lane_Display_Mode_1 = 127;
rtb_Lane_Display_Mode_2 = 248;
rtb_Lane_Display_Mode_3 = 186;
rtb_Lane_Display_Mode_4 = 84;
}
} else {
/* case IN_Condition2: */
rtb_Lane_Display_Mode_1 = 127;
rtb_Lane_Display_Mode_2 = 248;
rtb_Lane_Display_Mode_3 = 186;
rtb_Lane_Display_Mode_4 = 84;
if ((Subsystem_U.Lane_Input_Signal == 6.0) && (Subsystem_U.Enable_Display ==
0.0) && (Subsystem_U.Input_Switch == 1.0)) {
Subsystem_DW.is_c1_Subsystem = Subsystem_IN_Condition1;
rtb_Lane_Display_Mode_1 = 132;
rtb_Lane_Display_Mode_2 = 185;
rtb_Lane_Display_Mode_3 = 54;
rtb_Lane_Display_Mode_4 = 67;
}
}
/* End of Chart: '/Chart' */
/* Switch: '/Switch' incorporates:
* Inport: '/Highway_Input_Signal'
* Switch: '/Switch1'
* Switch: '/Switch2'
* Switch: '/Switch3'
*/
if (Subsystem_U.Highway_Input_Signal > 0.0) {
/* Outport: '/Display_Mode_1' incorporates:
* DataTypeConversion: '/Data Type Conversion'
*/
Subsystem_Y.Display_Mode_1 = (uint8_T)rtb_Highway_Display_Mode_1;
/* Outport: '/Display_Mode_2' incorporates:
* DataTypeConversion: '/Data Type Conversion1'
*/
Subsystem_Y.Display_Mode_2 = 183U;
/* Outport: '/Display_Mode_3' incorporates:
* DataTypeConversion: '/Data Type Conversion2'
*/
Subsystem_Y.Display_Mode_3 = (uint8_T)rtb_Highway_Display_Mode_3;
/* Outport: '/Display_Mode_4' incorporates:
* DataTypeConversion: '/Data Type Conversion3'
*/
Subsystem_Y.Display_Mode_4 = 94U;
} else {
/* Outport: '/Display_Mode_1' incorporates:
* DataTypeConversion: '/Data Type Conversion'
*/
Subsystem_Y.Display_Mode_1 = (uint8_T)rtb_Lane_Display_Mode_1;
/* Outport: '/Display_Mode_2' incorporates:
* DataTypeConversion: '/Data Type Conversion1'
*/
Subsystem_Y.Display_Mode_2 = (uint8_T)rtb_Lane_Display_Mode_2;
/* Outport: '/Display_Mode_3' incorporates:
* DataTypeConversion: '/Data Type Conversion2'
*/
Subsystem_Y.Display_Mode_3 = (uint8_T)rtb_Lane_Display_Mode_3;
/* Outport: '/Display_Mode_4' incorporates:
* DataTypeConversion: '/Data Type Conversion3'
*/
Subsystem_Y.Display_Mode_4 = (uint8_T)rtb_Lane_Display_Mode_4;
}
/* End of Switch: '/Switch' */
/* End of Outputs for SubSystem: '/Subsystem' */
}
/* Model initialize function */
void Subsystem_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void Subsystem_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
.h Code generation:
/*
* Trial License - for use to evaluate programs for possible purchase as
* an end-user only.
*
* File: rtwtypes.h
*
* Code generated for Simulink model 'Highway_Lane_Changing_Assistance'.
*
* Model version : 1.4
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Tue Sep 21 17:26:46 2021
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#ifndef RTWTYPES_H
#define RTWTYPES_H
/* Logical type definitions */
#if (!defined(__cplusplus))
#ifndef false
#define false (0U)
#endif
#ifndef true
#define true (1U)
#endif
#endif
/*=======================================================================*
* Target hardware information
* Device type: Intel->x86-64 (Windows64)
* Number of bits: char: 8 short: 16 int: 32
* long: 32
* native word size: 64
* Byte ordering: LittleEndian
* Signed integer division rounds to: Zero
* Shift right on a signed integer as arithmetic shift: on
*=======================================================================*/
/*=======================================================================*
* Fixed width word size data types: *
* int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *
* uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *
* real32_T, real64_T - 32 and 64 bit floating point numbers *
*=======================================================================*/
typedef signed char int8_T;
typedef unsigned char uint8_T;
typedef short int16_T;
typedef unsigned short uint16_T;
typedef int int32_T;
typedef unsigned int uint32_T;
typedef float real32_T;
typedef double real64_T;
/*===========================================================================*
* Generic type definitions: boolean_T, char_T, byte_T, int_T, uint_T, *
* real_T, time_T, ulong_T. *
*===========================================================================*/
typedef double real_T;
typedef double time_T;
typedef unsigned char boolean_T;
typedef int int_T;
typedef unsigned int uint_T;
typedef unsigned long ulong_T;
typedef char char_T;
typedef unsigned char uchar_T;
typedef char_T byte_T;
/*===========================================================================*
* Complex number type definitions *
*===========================================================================*/
#define CREAL_T
typedef struct {
real32_T re;
real32_T im;
} creal32_T;
typedef struct {
real64_T re;
real64_T im;
} creal64_T;
typedef struct {
real_T re;
real_T im;
} creal_T;
#define CINT8_T
typedef struct {
int8_T re;
int8_T im;
} cint8_T;
#define CUINT8_T
typedef struct {
uint8_T re;
uint8_T im;
} cuint8_T;
#define CINT16_T
typedef struct {
int16_T re;
int16_T im;
} cint16_T;
#define CUINT16_T
typedef struct {
uint16_T re;
uint16_T im;
} cuint16_T;
#define CINT32_T
typedef struct {
int32_T re;
int32_T im;
} cint32_T;
#define CUINT32_T
typedef struct {
uint32_T re;
uint32_T im;
} cuint32_T;
/*=======================================================================*
* Min and Max: *
* int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *
* uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *
*=======================================================================*/
#define MAX_int8_T ((int8_T)(127))
#define MIN_int8_T ((int8_T)(-128))
#define MAX_uint8_T ((uint8_T)(255U))
#define MAX_int16_T ((int16_T)(32767))
#define MIN_int16_T ((int16_T)(-32768))
#define MAX_uint16_T ((uint16_T)(65535U))
#define MAX_int32_T ((int32_T)(2147483647))
#define MIN_int32_T ((int32_T)(-2147483647-1))
#define MAX_uint32_T ((uint32_T)(0xFFFFFFFFU))
/* Block D-Work pointer type */
typedef void * pointer_T;
#endif /* RTWTYPES_H */
/*
* File trailer for generated code.
*
* [EOF]
*/
Conclusion:
From this project we created simulink data dictionary file and generated model advisory report and also made port mapping in AUTOSAR component parameter. Generated .c and .h algorithm for the entire subsystem and followed ISO26262 standards and MAAB guidelines.
------------------------------------x---------------------------------------------------x------------------------------------