Challenge

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:

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

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

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

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

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

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

The first step is to create Simulink Data Dictionary from the given Signals and Calibration Value:

Then under apps settings click on the AUTOSAR components and after clicking simulation option will get a new window as shown 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:

#include "Highway_Assistant_Lane_ChangingAssistant.h"
#include "Highway_Assistant_Lane_ChangingAssistant_private.h"
#define Highway_Assistant_IN_Condition1 ((uint8_T)1U)
#define Highway_Assistant_IN_Condition2 ((uint8_T)2U)
DW_Highway_Assistant_Lane_Cha_T Highway_Assistant_Lane_Chang_DW;
ExtU_Highway_Assistant_Lane_C_T Highway_Assistant_Lane_Changi_U;
ExtY_Highway_Assistant_Lane_C_T Highway_Assistant_Lane_Changi_Y;
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_;
void Highway_Assistant_Lane_ChangingAssistant_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;
  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_Assistant_IN_Condition1;
    rtb_Highway_Display_Mode_1 = 232;
    rtb_Highway_Display_Mode_3 = 41;
  } else if (Highway_Assistant_Lane_Chang_DW.is_c3_Highway_Assistant_Lane_Ch ==
             Highway_Assistant_IN_Condition1) {
    rtb_Highway_Display_Mode_1 = 232;
    rtb_Highway_Display_Mode_3 = 41;
    if ((Highway_Assistant_Lane_Changi_U.Highway_Input_Signal == 1.0) &&
        (Highway_Assistant_Lane_Changi_U.Enable_Display == 1.0) &&
        (Highway_Assistant_Lane_Changi_U.Input_Switch == 1.0)) {
      Highway_Assistant_Lane_Chang_DW
.is_c3_Highway_Assistant_Lane_Ch =
        Highway_Assistant_IN_Condition2;
      rtb_Highway_Display_Mode_1 = 213;
      rtb_Highway_Display_Mode_3 = 9;
    }
  } else {
    rtb_Highway_Display_Mode_1 = 213;
    rtb_Highway_Display_Mode_3 = 9;
    if ((Highway_Assistant_Lane_Changi_U.Highway_Input_Signal == 1.0) &&
        (Highway_Assistant_Lane_Changi_U.Enable_Display == 0.0) &&
        (Highway_Assistant_Lane_Changi_U.Input_Switch == 1.0)) {
      Highway_Assistant_Lane_Chang_DW.is_c3_Highway_Assistant_Lane_Ch =
        Highway_Assistant_IN_Condition1;
      rtb_Highway_Display_Mode_1 = 232;
      rtb_Highway_Display_Mode_3 = 41;
    }
  }
  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_Assistant_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 (Highway_Assistant_Lane_Chang_DW.is_c1_Highway_Assistant_Lane_Ch ==
             Highway_Assistant_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 ((Highway_Assistant_Lane_Changi_U.Lane_Input_Signal == 1.0) &&
        (Highway_Assistant_Lane_Changi_U.Enable_Display == 1.0) &&
        (Highway_Assistant_Lane_Changi_U.Input_Switch == 1.0)) {
      Highway_Assistant_Lane_Chang_DW.is_c1_Highway_Assistant_Lane_Ch =
        Highway_Assistant_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 {
    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 ((Highway_Assistant_Lane_Changi_U.Lane_Input_Signal == 1.0) &&
        (Highway_Assistant_Lane_Changi_U.Enable_Display == 0.0) &&
        (Highway_Assistant_Lane_Changi_U.Input_Switch == 1.0)) {
      Highway_Assistant_Lane_Chang_DW.is_c1_Highway_Assistant_Lane_Ch =
        Highway_Assistant_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 (Highway_Assistant_Lane_Changi_U.Highway_Input_Signal > 0.0) {
    Highway_Assistant_Lane_Changi_Y.Display_Mode_1 = (uint8_T)
      rtb_Highway_Display_Mode_1;
    Highway_Assistant_Lane_Changi_Y.Display_Mode_2 = 183U;
    Highway_Assistant_Lane_Changi_Y.Display_Mode_3 = (uint8_T)
      rtb_Highway_Display_Mode_3;
    Highway_Assistant_Lane_Changi_Y.Display_Mode_4 = 94U;
  } else {
    Highway_Assistant_Lane_Changi_Y.Display_Mode_1 = (uint8_T)
      rtb_Lane_Display_Mode_1;
    Highway_Assistant_Lane_Changi_Y.Display_Mode_2 = (uint8_T)
      rtb_Lane_Display_Mode_2;
    Highway_Assistant_Lane_Changi_Y.Display_Mode_3 = (uint8_T)
      rtb_Lane_Display_Mode_3;
    Highway_Assistant_Lane_Changi_Y.Display_Mode_4 = (uint8_T)
      rtb_Lane_Display_Mode_4;
  }
}
void Highway_Assistant_Lane_ChangingAssistant_initialize(void)
{
}
void Highway_Assistant_Lane_ChangingAssistant_terminate(void)
{
}

.h code:

#ifndef RTW_HEADER_Highway_Assistant_Lane_ChangingAssistant_h_
#define RTW_HEADER_Highway_Assistant_Lane_ChangingAssistant_h_
#ifndef Highway_Assistant_Lane_ChangingAssistant_COMMON_INCLUDES_
#define Highway_Assistant_Lane_ChangingAssistant_COMMON_INCLUDES_
#include "rtwtypes.h"
#endif           
#include "Highway_Assistant_Lane_ChangingAssistant_types.h"
#ifndef rtmGetErrorStatus
#define rtmGetErrorStatus(rtm)         ((rtm)->errorStatus)
#endif
#ifndef rtmSetErrorStatus
#define rtmSetErrorStatus(rtm, val)    ((rtm)->errorStatus = (val))
#endif
typedef struct {
  uint8_T is_active_c1_Highway_Assistant_;
  uint8_T is_c1_Highway_Assistant_Lane_Ch;
  uint8_T is_active_c3_Highway_Assistant_;
  uint8_T is_c3_Highway_Assistant_Lane_Ch;
} DW_Highway_Assistant_Lane_Cha_T;
typedef struct {
  real_T Highway_Input_Signal;         
  real_T Enable_Display;               
  real_T Input_Switch;                 
  real_T Lane_Input_Signal;            
} ExtU_Highway_Assistant_Lane_C_T;
typedef struct {
  uint8_T Display_Mode_1;              
  uint8_T Display_Mode_2;              
  uint8_T Display_Mode_3;              
  uint8_T Display_Mode_4;              
} ExtY_Highway_Assistant_Lane_C_T;
struct tag_RTM_Highway_Assistant_Lan_T {
  const char_T * volatile errorStatus;
};
extern DW_Highway_Assistant_Lane_Cha_T Highway_Assistant_Lane_Chang_DW;
extern ExtU_Highway_Assistant_Lane_C_T Highway_Assistant_Lane_Changi_U;
extern ExtY_Highway_Assistant_Lane_C_T Highway_Assistant_Lane_Changi_Y;
extern void Highway_Assistant_Lane_ChangingAssistant_initialize(void);
extern void Highway_Assistant_Lane_ChangingAssistant_step(void);
extern void Highway_Assistant_Lane_ChangingAssistant_terminate(void);
extern RT_MODEL_Highway_Assistant_La_T *const Highway_Assistant_Lane_Chang_M;
#endif

Conclusion:

From this project, we created a Simulink data dictionary file and generated a model advisory report, and also made port mapping in the AUTOSAR component parameter. Generated .c and .h algorithm for the entire subsystem and followed ISO26262 standards and MAAB guidelines.

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.