Challenge

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, and 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 to change 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 colossal algorithm & only one small part of the logic is implemented here. Idea is to familiarize me 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

Requirement No 1 [Highway_DisplayUnit]:

Inputs to this particular subsystem are “Highway_Input_Signal”, “Enable_Display”, and “Input_Switch”. These three input signals, when assigned to a particular value will give output signals of a specific value. The output signals are “Highway_Display_Mode_1”, “Highway_Display_Mode_2”, “Highway_Display_Mode_3”, and “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”, and “Lane_Input_Signal”. When assigned to a particular value, these three input signals will give output signals of a 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 the s 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 the s 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 the s 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 the s output signal “Display_Mode_4”.

Ans:-

AIM:-

Modal development of a feature of Highway Assistant _Lane changing Assitant using Matlab and Simulink MAAB guideline, producing model Autosar Repot as well as generating code using AUTOSAR code.

Objective:-

i)This model must be developed in MATLAB Simulink per MBD guidelines

ii)Code Generation Profile must be Autosar Coder.

iii)Simulink Data Dictionary must be created for the model & must be linked to the model.

iv)All the input & output signals must be mapped into the Autosar Editor.

v)Model Advisor Report is mandatory & this will be followed by Code Generation.

A lane-keeping assist (LKA) system is a control system that aids a driver in maintaining safe travel within a marked lane of a highway. The LKA system detects when the vehicle deviates from a lane and automatically adjusts the steering to restore proper travel inside the lane without additional input from the driver. In this example, the LKA system switches between the driver steering command and lane-keeping controller. This approach is sufficient to introduce a modeling architecture for an LKA system, however, a real system would also provide haptic feedback to the steering wheel and enable the driver to override the LKA system by applying sufficient counter-torque.

For the LKA to work correctly, the ego vehicle must determine the lane boundaries and how the lane in front of it curves. Idealized LKA designs rely mostly on the previewed curvature, the lateral deviation, and the relative yaw angle between the centerline of the lane and the ego vehicle. An example of such a system is given in Lane Keeping Assist System Using Model Predictive Control. Moving from the advanced drive-assistance system (ADAS) designs to more autonomous systems, the LKA must be robust to missing, incomplete, or inaccurate measurement readings from real-world lane detectors.

This example demonstrates a robust approach to the controller design when the data from lane detections may not be accurate. To do so, it uses data from a synthetic lane detector that simulates the impairments introduced by a wide-angle monocular vision camera. The controller makes decisions when the data from the sensor is invalid or outside a range. This provides a safety guard when the sensor measurement is false due to conditions in the environment, such as a sharp curve on the road.

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, and 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 to change lanes, the system issues an additional acoustic and/or haptic warning.

This model must be developed in MATLAB Simulink per MBD guidelines.

Requirement No 1 [Highway_DisplayUnit]:

Inputs to this particular subsystem are “Highway_Input_Signal”, “Enable_Display”, and “Input_Switch”. These three input signals, when assigned to a particular value will give output signals of a specific value. The output signals are “Highway_Display_Mode_1”, “Highway_Display_Mode_2”, “Highway_Display_Mode_3”, and “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

modal diagram

Model Explorer

Requirement No 2 [Lane_DisplayUnit]:

Inputs to this particular subsystem are “Enable_Display”, “Input_Switch”, and “Lane_Input_Signal”. These three input signals, when assigned to a particular value will give output signals of a 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

modal diagram:-

modal explore

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 the 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 the 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 the 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 the output signal “Display_Mode_4”.

  • Simulink Data Dictionary must be created for the model & must be linked to the model.

modal created

Code Generation Profile must be Autosar Coder.

  • All the input & output signals must be mapped into the Autosar Editor.

Modal advisor

Model Advisor Report is mandatory

Code Generation.

/*
* File: Highway_Assistant_Lane_Changing.c
*
* Code generated for Simulink model 'Highway_Assistant_Lane_Changing'.
*
* Model version : 1.9
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Sun Jun 26 13:03:01 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "Highway_Assistant_Lane_Changing.h"
#include "Highway_Assistant_Lane_Changing_private.h"
/* Named constants for Chart: '<S2>/Highway_DisplayUnit_logic' */
#define Highway_Assistan_IN_condition_1 ((uint8_T)1U)
#define Highway_Assistan_IN_condition_2 ((uint8_T)2U)
/* Exported data definition */
/* Definition for custom storage class: ExportToFile */
uint8_T Display_Mode_1; /* '<S1>/Switch' */
uint8_T Display_Mode_2; /* '<S1>/Switch1' */
uint8_T Display_Mode_3; /* '<S1>/Switch2' */
uint8_T Display_Mode_4; /* '<S1>/Switch3' */
/* Block states (default storage) */
DW_Highway_Assistant_Lane_Cha_T Highway_Assistant_Lane_Chang_DW;
/* External inputs (root inport signals with default storage) */
ExtU_Highway_Assistant_Lane_C_T Highway_Assistant_Lane_Changi_U;
/* Real-time model */
static RT_MODEL_Highway_Assistant_La_T Highway_Assistant_Lane_Chang_M_;
RT_MODEL_Highway_Assistant_La_T *const Highway_Assistant_Lane_Chang_M =
&Highway_Assistant_Lane_Chang_M_;
/* Model step function */
void Highway_Assistant_Lane_Changing_step(void)
{
/* local block i/o variables */
uint8_T Lane_Display_Mode_1;
uint8_T Lane_Display_Mode_2;
uint8_T Lane_Display_Mode_3;
uint8_T Lane_Display_Mode_4;
uint8_T Highway_Display_Mode_1;
uint8_T Highway_Display_Mode_2;
uint8_T Highway_Display_Mode_3;
uint8_T Highway_Display_Mode_4;
/* Outputs for Atomic SubSystem: '<S1>/Highway_Display_Unit' */
/* Chart: '<S2>/Highway_DisplayUnit_logic' incorporates:
* Inport: '<Root>/Enable_Display'
* Inport: '<Root>/Highway_Input_signal'
* Inport: '<Root>/Input_Switch'
*/
if (Highway_Assistant_Lane_Chang_DW.is_active_c3_Highway_Assistant_ == 0U) {
Highway_Assistant_Lane_Chang_DW.is_active_c3_Highway_Assistant_ = 1U;
Highway_Assistant_Lane_Chang_DW.is_c3_Highway_Assistant_Lane_Ch =
Highway_Assistan_IN_condition_1;
Highway_Display_Mode_1 = 232U;
Highway_Display_Mode_2 = 183U;
Highway_Display_Mode_3 = 41U;
Highway_Display_Mode_4 = 94U;
} else if (Highway_Assistant_Lane_Chang_DW.is_c3_Highway_Assistant_Lane_Ch ==
Highway_Assistan_IN_condition_1) {
if ((Highway_Input_Signal == 1) && (Enable_Display == 1) && (Input_Switch ==
1)) {
Highway_Assistant_Lane_Chang_DW.is_c3_Highway_Assistant_Lane_Ch =
Highway_Assistan_IN_condition_2;
Highway_Display_Mode_1 = 213U;
Highway_Display_Mode_2 = 183U;
Highway_Display_Mode_3 = 9U;
Highway_Display_Mode_4 = 94U;
} else {
Highway_Display_Mode_1 = 232U;
Highway_Display_Mode_2 = 183U;
Highway_Display_Mode_3 = 41U;
Highway_Display_Mode_4 = 94U;
}
/* case IN_condition_2: */
} else if ((Highway_Input_Signal == 1) && (Enable_Display == 1) &&
(Input_Switch == 1)) {
Highway_Assistant_Lane_Chang_DW.is_c3_Highway_Assistant_Lane_Ch =
Highway_Assistan_IN_condition_1;
Highway_Display_Mode_1 = 232U;
Highway_Display_Mode_2 = 183U;
Highway_Display_Mode_3 = 41U;
Highway_Display_Mode_4 = 94U;
} else {
Highway_Display_Mode_1 = 213U;
Highway_Display_Mode_2 = 183U;
Highway_Display_Mode_3 = 9U;
Highway_Display_Mode_4 = 94U;
}
/* End of Chart: '<S2>/Highway_DisplayUnit_logic' */
/* End of Outputs for SubSystem: '<S1>/Highway_Display_Unit' */
/* Chart: '<S3>/Lane_DisplayUnit_logic' incorporates:
* Inport: '<Root>/Enable_Display'
* Inport: '<Root>/Input_Switch'
* Inport: '<Root>/Lane_Input_Signal'
*/
if (Highway_Assistant_Lane_Chang_DW.is_active_c1_Highway_Assistant_ == 0U) {
Highway_Assistant_Lane_Chang_DW.is_active_c1_Highway_Assistant_ = 1U;
Highway_Assistant_Lane_Chang_DW.is_c1_Highway_Assistant_Lane_Ch =
Highway_Assistan_IN_condition_1;
Lane_Display_Mode_1 = 132U;
Lane_Display_Mode_2 = 185U;
Lane_Display_Mode_3 = 54U;
Lane_Display_Mode_4 = 67U;
} else if (Highway_Assistant_Lane_Chang_DW.is_c1_Highway_Assistant_Lane_Ch ==
Highway_Assistan_IN_condition_1) {
if ((Highway_Assistant_Lane_Changi_U.Lane_Input_Signal == 6.0) &&
(Enable_Display == 0) && (Input_Switch == 1)) {
Highway_Assistant_Lane_Chang_DW.is_c1_Highway_Assistant_Lane_Ch =
Highway_Assistan_IN_condition_2;
Lane_Display_Mode_1 = 127U;
Lane_Display_Mode_2 = 248U;
Lane_Display_Mode_3 = 186U;
Lane_Display_Mode_4 = 84U;
} else {
Lane_Display_Mode_1 = 132U;
Lane_Display_Mode_2 = 185U;
Lane_Display_Mode_3 = 54U;
Lane_Display_Mode_4 = 67U;
}
/* case IN_condition_2: */
} else if ((Highway_Assistant_Lane_Changi_U.Lane_Input_Signal == 6.0) &&
(Enable_Display == 1) && (Input_Switch == 1)) {
Highway_Assistant_Lane_Chang_DW.is_c1_Highway_Assistant_Lane_Ch =
Highway_Assistan_IN_condition_1;
Lane_Display_Mode_1 = 132U;
Lane_Display_Mode_2 = 185U;
Lane_Display_Mode_3 = 54U;
Lane_Display_Mode_4 = 67U;
} else {
Lane_Display_Mode_1 = 127U;
Lane_Display_Mode_2 = 248U;
Lane_Display_Mode_3 = 186U;
Lane_Display_Mode_4 = 84U;
}
/* End of Chart: '<S3>/Lane_DisplayUnit_logic' */
/* Switch: '<S1>/Switch' incorporates:
* Inport: '<Root>/Highway_Input_signal'
* Switch: '<S1>/Switch1'
* Switch: '<S1>/Switch2'
* Switch: '<S1>/Switch3'
*/
if (Highway_Input_Signal != 0) {
/* Switch: '<S1>/Switch' */
Display_Mode_1 = Highway_Display_Mode_1;
/* Switch: '<S1>/Switch1' */
Display_Mode_2 = Highway_Display_Mode_2;
/* Switch: '<S1>/Switch2' */
Display_Mode_3 = Highway_Display_Mode_3;
/* Switch: '<S1>/Switch3' */
Display_Mode_4 = Highway_Display_Mode_4;
} else {
/* Switch: '<S1>/Switch' */
Display_Mode_1 = Lane_Display_Mode_1;
/* Switch: '<S1>/Switch1' */
Display_Mode_2 = Lane_Display_Mode_2;
/* Switch: '<S1>/Switch2' */
Display_Mode_3 = Lane_Display_Mode_3;
/* Switch: '<S1>/Switch3' */
Display_Mode_4 = Lane_Display_Mode_4;
}
/* End of Switch: '<S1>/Switch' */
}
/* Model initialize function */
void Highway_Assistant_Lane_Changing_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void Highway_Assistant_Lane_Changing_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
/*
* File: ert_main.c
*
* Code generated for Simulink model 'Highway_Assistant_Lane_Changing'.
*
* Model version : 1.9
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Sun Jun 26 13:07:44 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include <stddef.h>
#include <stdio.h> /* This ert_main.c example uses printf/fflush */
#include "Highway_Assistant_Lane_Changing.h" /* Model's header file */
#include "rtwtypes.h"
/*
* Associating rt_OneStep with a real-time clock or interrupt service routine
* is what makes the generated code "real-time". The function rt_OneStep is
* always associated with the base rate of the model. Subrates are managed
* by the base rate from inside the generated code. Enabling/disabling
* interrupts and floating point context switches are target specific. This
* example code indicates where these should take place relative to executing
* the generated code step function. Overrun behavior should be tailored to
* your application needs. This example simply sets an error status in the
* real-time model and returns from rt_OneStep.
*/
void rt_OneStep(void);
void rt_OneStep(void)
{
static boolean_T OverrunFlag = false;
/* Disable interrupts here */
/* Check for overrun */
if (OverrunFlag) {
rtmSetErrorStatus(Highway_Assistant_Lane_Chang_M, "Overrun");
return;
}
OverrunFlag = true;
/* Save FPU context here (if necessary) */
/* Re-enable timer or interrupt here */
/* Set model inputs here */
/* Step the model */
Highway_Assistant_Lane_Changing_step();
/* Get model outputs here */
/* Indicate task complete */
OverrunFlag = false;
/* Disable interrupts here */
/* Restore FPU context here (if necessary) */
/* Enable interrupts here */
}
/*
* The example "main" function illustrates what is required by your
* application code to initialize, execute, and terminate the generated code.
* Attaching rt_OneStep to a real-time clock is target specific. This example
* illustrates how you do this relative to initializing the model.
*/
int_T main(int_T argc, const char *argv[])
{
/* Unused arguments */
(void)(argc);
(void)(argv);
/* Initialize model */
Highway_Assistant_Lane_Changing_initialize();
/* Attach rt_OneStep to a timer or interrupt service routine with
* period 1.0 seconds (the model's base sample time) here. The
* call syntax for rt_OneStep is
*
* rt_OneStep();
*/
printf("Warning: The simulation will run forever. "
"Generated ERT main won't simulate model step behavior. "
"To change this behavior select the 'MAT-file logging' option.\n");
fflush((NULL));
while (rtmGetErrorStatus(Highway_Assistant_Lane_Chang_M) == (NULL)) {
/* Perform other application tasks here */
}
/* Disable rt_OneStep() here */
/* Terminate model */
Highway_Assistant_Lane_Changing_terminate();
return 0;
}
/*
* File trailer for generated code.
*
* [EOF]
*/
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.

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.