Challenge

Project 2-Highway Assistant-Lane Changing Assistant

AIM:

To explain the following,

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

OBJECTIVES:

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

1. TO DEVELOP ONE SPECIFIC REQUIREMENT OF HIGHWAY ASSISTANT - LANE CHANGING ASSISTANT ALGORITHM. IDEA IS TO FAMILIARIZE WITH CONCEPTS OF AUTOSAR SOFTWARE COMPONENT DEVELOPMENT IN MATLAB ENVIRONMENT BY FOLLOWING THE MODEL BASED DEVELOPMENT GUIDELINES

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

Following were the procedure to develop one specific requirement of "Highway Assistant - Lane Changing Assistant" algorithm,

STEP 1 - Open Modelling >>> Model settings. In configuration parameters choose 'code generation', In system target file browse "autosar.tlc AUTOSAR" and click OK. This makes to adapt all the configuration parameters as per the model

STEP 2 - Simulink Data Dictionary. Now select Modelling tab >>> Link to Data Dictionary. In that pop-up window, Under the 'external data' tab, click New option to create the new data dictionary, name it and click OK

STEP 3 - Open Modelling >>> Model Explorer, choose created the 'lane_change_assist_dd' (.sldd) file as below. And click the marked two simulink parameter and signal options to add the inputs to the data dictionary file. Then make a right click on the created file and select save changes

STEP 4 - Now we have to create the subsystem of 'Highway_Lane_Changing_Assistant_Logic' with four inputs and four outputs. Inside of this subsystem block we going to construct the given three requirements

STEP 5 - Inside the main subsystem, create 3 subsystems and name it as 'Requirement_No_1_[Highway_DisplayUnit]', 'Requirement_No_2_[Lane_DisplayUnit]' and 'Requirement_No_3'

Requirement_No_1_[Highway_DisplayUnit]:

  • Inside the Stateflow Chart,

Requirement_No_2_[Lane_DisplayUnit]:

  • Inside the Stateflow Chart,

Requirement_No_3:

STEP 6 - Follow the following points,

  • Connect the 'Highway_Input_Signal', 'Enable_Display', 'Input_Switch' signals to the 'Requirement_No_1_[Highway_DisplayUnit]' subsystem as inputs through the goto and from blocks for avoid signals crossing each other during connections
  • Connect the 'Lane_Input_Signal', 'Enable_Display', 'Input_Switch' signals to the 'Requirement_No_2_[Lane_DisplayUnit]' subsystem as inputs through the goto and from blocks for same as like previous subsystem
  • Connect both subsystems (4 local outputs for each as shown below) outputs to the 'Requirement_No_3' subsystem as inputs
  • Make 4 final outputs which are from the output of 'Requirement_No_3' subsystem as shown

STEP 7 - Port Mapping into the Autosar Editor. Now open the 'show perspective views' option and choose the 'Code' for enter the perspectives

STEP 8 - After that select the 'Code Mappings' in AUTOSAR SW components. By this process, a pop-up window will appears and select the 'Configuration of AUTOSAR Dictionary' option as shown below. This will helps to create and edit the input and output ports, interfaces, Data Elements

  • Under this above process, the signals in ports, interfaces and data elements were renamed and has to be reflected in the codes for our reference. So the required section's signals are renamed were shown below

1. ReceiverPorts:

2. SenderPorts:

3. S-R Interfaces:

4. DataElements:

STEP 9 - Validate Code Mapping. Now select the 'validate' option for check the code mappings. By refresh the diagram will get updated

  • By clicking the validation option, the AUTOSAR will checks the model were all the parameters are provided with the same naming and finally it gets validated as shown below

STEP 10 - Then finally click the refresh option for updates the changes in the model

  • The updated data of the model were shown below

1.Inports:

2.Outports:

STEP 11 - Now Tagging. Tag the required documents of 'Requirement_No_1_[Highway_DisplayUnit]', 'Requirement_No_2_[Lane_DisplayUnit]' & 'Requirement_No_3' to their corresponding subsystems were shown below

  • Create the word document with the given information
  • Select the appropriate word (Requirement No 1 [Highway_DisplayUnit]) from the created document

  • And go to the simulink model and right click on the related subsystem (Requirement No 1 [Highway_DisplayUnit]), then select Requirements >>> link to the selection in word. This makes that selected paragraph on word document to link with this subsystem's description

  • After the linking process, we can cross check as it linked properly or not. So again right click on the subsystem and select Requirements >>> 1. "Requirement No 1 [Highway_DisplayUnit]"

  • Now you can see the targeted word from the document as below

  • Just follow the same steps to tag the description for 'Requirement_No_2_[Lane_DisplayUnit]' and 'Requirement_No_3' subsystems from the word document

Requirement_No_2_[Lane_DisplayUnit]:

Requirement_No_3:

STEP 12 - Resolve & Propagate. For resolve(requires that the resolved signal have the same name as the subsystem output or local data). For Propagate (to track a signal label through one block or many blocks)

Follow these steps for resolve:

  • Right-click the signal line connected to the subsystem that you want to resolve and select properties from the context menu
  • In the signal properties dialog box, enter a name for the signal that corresponds to the signal object
  • Enable the signal name must resolve to Simulink signal object check box. Click apply and OK

Follow these steps for propagate:

  • Right-click the signal for which you want to display a propagated signal label and select properties
  • In the signal properties dialog box, enable propagated signals check box. Click apply and OK

  • Following will shows how the model will looks like after the signals resolve and propagate were done,

Highway Lane Changing Assistant Logic:

Inside the Main Subsystem:

Requirement No.1 [Highway Display Unit]:

Requirement No.2 [Lane Display Unit]:

Requirement No.3:

STEP 13 - Now have to change the subsystem's parameter, so right click on the created subsystem and select 'block parameters (subsystem)'

STEP 14 - In this block parameters, enable the 'Treat as atomic unit', this causes simulink to treat the subsystem as a unit when determining block execution order. When it comes time to execute the subsystem, simulink executes all blocks within the subsystem before executing any other block at the same level as the subsystem block

For information,

  • If this option is not selected, simulink treats all blocks in the subsystem as being at the same level in the model hierarchy as the subsystem when determining block execution order
  • This can cause execution of blocks within the subsystem to be interleaved with execution of blocks outside the subsystem

STEP 15 - Model Advisor. Now open the Modelling >>> Model Advisor for MBD compliant changes. In that pop-up window, choose the system have to check and click OK

STEP 16 - Under the 'By Task' option, check 'Modeling Standards for MAB' and click the 'Run Selected Checks' option to starts the complaints checking

STEP 17 - After the check done, the report summary will shows the no.of pass, fail, warning as below,

  • Finally generate the report by selecting the 'Generate Report' option and click OK. The report file will saves in the related folder as in HTML format

  • The generated report has shown below,

STEP 18 - Code Generation. Open the APPS tab and choose the 'AUTOSAR Component Designer' option to go to generate the AUTOSAR complaint code as shown below

STEP 19 - By choosing the 'AUTOSAR Component Designer', the 'C code' tab will appears. In that tab, check once the 'code for' section for ensuring we're doing the codes for right subsystem and choose the 'Build' option to generate the codes. By this process, after the few moments the "C code" will be generated as shown below

STEP 20 - After the code generation, the 'Highway_Lane_Changing_Assistant_autosar_rtw' folder will auto generated. This folder holds the supporting files of 'Highway lane changing assistant logic' subsystem like codes (.c), MAT (.mat), header (.h) files, etc.,

  • Following will shows the codes were hold by the C source file of 'Highway_Lane_Changing_Assistant.c',
/*
 * File: Highway_Lane_Changing_Assistant.c
 *
 * Code generated for Simulink model 'Highway_Lane_Changing_Assistant'.
 *
 * Model version                  : 1.38
 * Simulink Coder version         : 9.5 (R2021a) 14-Nov-2020
 * C/C++ source code generated on : Sun Jun 19 21:21:17 2022
 *
 * Target selection: autosar.tlc
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "Highway_Lane_Changing_Assistant.h"
#include "Highway_Lane_Changing_Assistant_private.h"

/* Named constants for Chart: '/Chart' */
#define Highway_Lane_Changing_IN_Case_1 ((uint8)1U)
#define Highway_Lane_Changing_IN_Case_2 ((uint8)2U)

/* Block states (default storage) */
DW_Highway_Lane_Changing_Assi_T Highway_Lane_Changing_Assist_DW;

/* Model step function */
void Highway_Lane_Changing_Assistant_Step(void)
{
  sint32 tmp;
  uint8 rtb_Highway_Display_Mode_1;
  uint8 rtb_Highway_Display_Mode_3;
  uint8 rtb_Lane_Display_Mode_1;
  uint8 rtb_Lane_Display_Mode_2;
  uint8 rtb_Lane_Display_Mode_3;
  uint8 rtb_Lane_Display_Mode_4;

  /* Outputs for Atomic SubSystem: '/Highway_Lane_Changing_Assistant_Logic' */
  /* Chart: '/Chart' incorporates:
   *  Inport: '/Enable_Display'
   *  Inport: '/Highway_Input_Signal'
   *  Inport: '/Input_Switch'
   */
  if (Highway_Lane_Changing_Assist_DW.is_active_c3_Highway_Lane_Chang == 0U) {
    Highway_Lane_Changing_Assist_DW.is_active_c3_Highway_Lane_Chang = 1U;
    Highway_Lane_Changing_Assist_DW.is_c3_Highway_Lane_Changing_Ass =
      Highway_Lane_Changing_IN_Case_1;
    rtb_Highway_Display_Mode_1 = 232U;
    rtb_Highway_Display_Mode_3 = 41U;
  } else if (Highway_Lane_Changing_Assist_DW.is_c3_Highway_Lane_Changing_Ass ==
             Highway_Lane_Changing_IN_Case_1) {
    rtb_Highway_Display_Mode_1 = 232U;
    rtb_Highway_Display_Mode_3 = 41U;
    if ((Rte_IRead_Highway_Lane_Changing_Assistant_Step_Highway_Input_Signal_Highway_Input_Signal
         () == 1) &&
        (Rte_IRead_Highway_Lane_Changing_Assistant_Step_Enable_Display_Enable_Display
         () == 1) &&
        (Rte_IRead_Highway_Lane_Changing_Assistant_Step_Input_Switch_Input_Switch
         () == 1)) {
      Highway_Lane_Changing_Assist_DW.is_c3_Highway_Lane_Changing_Ass =
        Highway_Lane_Changing_IN_Case_2;
      rtb_Highway_Display_Mode_1 = 213U;
      rtb_Highway_Display_Mode_3 = 9U;
    }
  } else {
    /* case IN_Case_2: */
    rtb_Highway_Display_Mode_1 = 213U;
    rtb_Highway_Display_Mode_3 = 9U;
    if ((Rte_IRead_Highway_Lane_Changing_Assistant_Step_Highway_Input_Signal_Highway_Input_Signal
         () == 1) &&
        (Rte_IRead_Highway_Lane_Changing_Assistant_Step_Enable_Display_Enable_Display
         () == 0) &&
        (Rte_IRead_Highway_Lane_Changing_Assistant_Step_Input_Switch_Input_Switch
         () == 1)) {
      Highway_Lane_Changing_Assist_DW.is_c3_Highway_Lane_Changing_Ass =
        Highway_Lane_Changing_IN_Case_1;
      rtb_Highway_Display_Mode_1 = 232U;
      rtb_Highway_Display_Mode_3 = 41U;
    }
  }

  /* End of Chart: '/Chart' */

  /* Chart: '/Chart' incorporates:
   *  Inport: '/Enable_Display'
   *  Inport: '/Input_Switch'
   *  Inport: '/Lane_Input_Signal'
   */
  if (Highway_Lane_Changing_Assist_DW.is_active_c1_Highway_Lane_Chang == 0U) {
    Highway_Lane_Changing_Assist_DW.is_active_c1_Highway_Lane_Chang = 1U;
    Highway_Lane_Changing_Assist_DW.is_c1_Highway_Lane_Changing_Ass =
      Highway_Lane_Changing_IN_Case_1;
    rtb_Lane_Display_Mode_1 = 132U;
    rtb_Lane_Display_Mode_2 = 185U;
    rtb_Lane_Display_Mode_3 = 54U;
    rtb_Lane_Display_Mode_4 = 67U;
  } else if (Highway_Lane_Changing_Assist_DW.is_c1_Highway_Lane_Changing_Ass ==
             Highway_Lane_Changing_IN_Case_1) {
    rtb_Lane_Display_Mode_1 = 132U;
    rtb_Lane_Display_Mode_2 = 185U;
    rtb_Lane_Display_Mode_3 = 54U;
    rtb_Lane_Display_Mode_4 = 67U;
    if ((Rte_IRead_Highway_Lane_Changing_Assistant_Step_Rp_Lane_Input_Signal_DE_Lane_Input_Signal
         () == 6) &&
        (Rte_IRead_Highway_Lane_Changing_Assistant_Step_Enable_Display_Enable_Display
         () == 0) &&
        (Rte_IRead_Highway_Lane_Changing_Assistant_Step_Input_Switch_Input_Switch
         () == 1)) {
      Highway_Lane_Changing_Assist_DW.is_c1_Highway_Lane_Changing_Ass =
        Highway_Lane_Changing_IN_Case_2;
      rtb_Lane_Display_Mode_1 = 127U;
      rtb_Lane_Display_Mode_2 = 248U;
      rtb_Lane_Display_Mode_3 = 186U;
      rtb_Lane_Display_Mode_4 = 4U;
    }
  } else {
    /* case IN_Case_2: */
    rtb_Lane_Display_Mode_1 = 127U;
    rtb_Lane_Display_Mode_2 = 248U;
    rtb_Lane_Display_Mode_3 = 186U;
    rtb_Lane_Display_Mode_4 = 4U;
    if ((Rte_IRead_Highway_Lane_Changing_Assistant_Step_Rp_Lane_Input_Signal_DE_Lane_Input_Signal
         () == 6) &&
        (Rte_IRead_Highway_Lane_Changing_Assistant_Step_Enable_Display_Enable_Display
         () == 1) &&
        (Rte_IRead_Highway_Lane_Changing_Assistant_Step_Input_Switch_Input_Switch
         () == 1)) {
      Highway_Lane_Changing_Assist_DW.is_c1_Highway_Lane_Changing_Ass =
        Highway_Lane_Changing_IN_Case_1;
      rtb_Lane_Display_Mode_1 = 132U;
      rtb_Lane_Display_Mode_2 = 185U;
      rtb_Lane_Display_Mode_3 = 54U;
      rtb_Lane_Display_Mode_4 = 67U;
    }
  }

  /* End of Chart: '/Chart' */

  /* Switch: '/Switch' incorporates:
   *  Inport: '/Highway_Input_Signal'
   *  Switch: '/Switch1'
   *  Switch: '/Switch2'
   */
  tmp =
    Rte_IRead_Highway_Lane_Changing_Assistant_Step_Highway_Input_Signal_Highway_Input_Signal
    ();
  if (tmp != 0) {
    /* Outport: '/Display_Mode_1' */
    Rte_IWrite_Highway_Lane_Changing_Assistant_Step_Pp_Display_Mode_1_DE_Display_Mode_1
      (rtb_Highway_Display_Mode_1);
    rtb_Lane_Display_Mode_2 = 183U;
  } else {
    /* Outport: '/Display_Mode_1' */
    Rte_IWrite_Highway_Lane_Changing_Assistant_Step_Pp_Display_Mode_1_DE_Display_Mode_1
      (rtb_Lane_Display_Mode_1);
  }

  /* End of Switch: '/Switch' */
  /* End of Outputs for SubSystem: '/Highway_Lane_Changing_Assistant_Logic' */

  /* Outport: '/Display_Mode_2' */
  Rte_IWrite_Highway_Lane_Changing_Assistant_Step_Pp_Display_Mode_2_DE_Display_Mode_2
    (rtb_Lane_Display_Mode_2);

  /* Outputs for Atomic SubSystem: '/Highway_Lane_Changing_Assistant_Logic' */
  /* Switch: '/Switch2' incorporates:
   *  Switch: '/Switch3'
   */
  if (tmp != 0) {
    /* Outport: '/Display_Mode_3' */
    Rte_IWrite_Highway_Lane_Changing_Assistant_Step_Pp_Display_Mode_3_DE_Display_Mode_3
      (rtb_Highway_Display_Mode_3);
    rtb_Lane_Display_Mode_4 = 94U;
  } else {
    /* Outport: '/Display_Mode_3' */
    Rte_IWrite_Highway_Lane_Changing_Assistant_Step_Pp_Display_Mode_3_DE_Display_Mode_3
      (rtb_Lane_Display_Mode_3);
  }

  /* End of Outputs for SubSystem: '/Highway_Lane_Changing_Assistant_Logic' */

  /* Outport: '/Display_Mode_4' */
  Rte_IWrite_Highway_Lane_Changing_Assistant_Step_Pp_Display_Mode_4_DE_Display_Mode_4
    (rtb_Lane_Display_Mode_4);
}

/* Model initialize function */
void Highway_Lane_Changing_Assistant_Init(void)
{
  /* (no initialization code required) */
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */

Note: All the workout files were attached by zip file (.slx, .sldd, .m, .c, .html, etc.,) as below

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.