Challenge

Project 2-Highway Assistant-Lane Changing Assistant

Highway Assistant – Lane Changing Assistant

AIM

To develop a Highway Assistant – Lane Changing Assistant algorithm with concepts of Autosar Software Component Development in MATLAB Environment by following the Model Based Development guidelines as per given requiremnets.

INTRODUCTION

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.

Development of Highway Assistant–Lane Changing Assistant model using MATLAB Simulink per MBD guidelines.

Steps involved in the modelling as per the given three requirements and the MBD guidlines the model is been developed.

1: Main Subsysten

  • The Highway Asssitant - LCA Subsystem is created.
  • The inputs signal names of the model are - Highway_Input_Signal, Enable_Display, Input_Switch, Lane_Input_Signal.
  • The input signals are resolved.
  • The output signal names of the model are - Display_Mode_1, Display_Mode_2, Display_Mode_3, Display_Mode_4.

2: Inside Main Subsystem

  • Inside the main model show above 3 requiemnt subsystems are created.
  • Requirement No: 1 - Highway_DisplayUnit
  • Requirement No: 2 - Lane_DisplayUnit
  • Requirement No: 3

2.1: Requiremnt No:1 - Highway_DisplayUnit Subsystem.

  • Inputs of the subsystem are: “Highway_Input_Signal”, “Enable_Display”, “Input_Switch”.
  • Inside the subsytem a stateflow chart is created to implement the requirement logic.
  • The input signals are propagated into the state flow chart.
  • The ouput of the stateflow chart are: “Highway_Display_Mode_1”, “Highway_Display_Mode_2”, “Highway_Display_Mode_3”, “Highway_Display_Mode_4”.
  • The output signals from the stateflow chart is resolved and propagted outside the Highway_DisplayUnit Subsystem.

  • As per the given requirement the stateflow logic is implemented.

2.2: Requirement No: 2 - Lane_DisplayUnit Subsytem

  • Inputs of the subsystem are: “Enable_Display”, “Input_Switch”, “Lane_Input_Signal”.
  • Inside the subsytem a stateflow chart is created to implement the requirement logic.
  • The ouput of the stateflow chart are: “Lane_Display_Mode_1”, “Lane_Display_Mode_2”, “Lane_Display_Mode_3”, “Lane_Display_Mode_4”.
  • The output signals from the stateflow chart is resolved and propagted outside the Lane_DisplayUnit Subsystem.

  • As per the given requirement the stateflow logic is implemented.

2.3: Requirement No: 3

  • Signals coming from both subsystems Highway_DisplayUnit & Lane_DisplayUnit are given as input tothe Requirement 3 Subsystem.
  • In addition the Highway_Input_Signal is also given as input.
  • 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”.

  • The outputs of each switch is resolved and propagated.
  • The 3 subsystems.

3: Simulink Data Dictionary Creation

  • Simulink data dictionary is created as per the given requiremnt documents.

4: Requirement Tagging

  • Requirement Document for all the three subsystems are linked with Word document and requiment tagging is done.

  • The above method is executed for the other 2 subsystems similarlly.

5: Configuration Parameter for Autosar Port Mapping

  • Solver Setting

  • Code Generation Setting

6: Modify the AUTOSAR SW Component by Configuring Autosar Dictionary

  • An Excel File is created for referance

  • Modifying XML Options

  • Create the S- R Interfaces

  • Add Corresponding Data Elements

  • Configure the Sender Ports

  • Configure the Receiver Ports

  • Validate the Port Mapping

  • Simulated to check whather the model to check the model is working properly.

7: AUTOSAR Code Generation

/*
 * File: Highway_Assistant_Lane_Changing_Assistant.c
 *
 * Code generated for Simulink model 'Highway_Assistant_Lane_Changing_Assistant'.
 *
 * Model version                  : 1.9
 * Simulink Coder version         : 9.5 (R2021a) 14-Nov-2020
 * C/C++ source code generated on : Thu Jul 14 12:24:53 2022
 *
 * Target selection: autosar.tlc
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "Highway_Assistant_Lane_Changing_Assistant.h"
#include "Highway_Assistant_Lane_Changing_Assistant_private.h"

/* Named constants for Chart: '<S2>/Highway_DisplayUnit' */
#define Highway_Assistant_Lan_IN_Case_1 ((uint8)1U)
#define Highway_Assistant_Lan_IN_Case_2 ((uint8)2U)

/* Block signals (default storage) */
B_Highway_Assistant_Lane_Chan_T Highway_Assistant_Lane_Changi_B;

/* Block states (default storage) */
DW_Highway_Assistant_Lane_Cha_T Highway_Assistant_Lane_Chang_DW;

/* Model step function */
void Highway_Assistant_Lane_Changing_Assistant_Step(void)
{
  /* Chart: '<S2>/Highway_DisplayUnit' incorporates:
   *  Inport: '<Root>/Enable_Display'
   *  Inport: '<Root>/Highway_Input_Signal'
   *  Inport: '<Root>/Input_Switch'
   */
  if (Highway_Assistant_Lane_Chang_DW.is_active_c2_Highway_Assistant_ == 0U) {
    Highway_Assistant_Lane_Chang_DW.is_active_c2_Highway_Assistant_ = 1U;
    Highway_Assistant_Lane_Chang_DW.is_c2_Highway_Assistant_Lane_Ch =
      Highway_Assistant_Lan_IN_Case_1;
    Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_1 = 232U;
    Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_2 = 183U;
    Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_3 = 41U;
    Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_4 = 94U;
  } else if (Highway_Assistant_Lane_Chang_DW.is_c2_Highway_Assistant_Lane_Ch ==
             Highway_Assistant_Lan_IN_Case_1) {
    if ((Rte_IRead_Highway_Assistant_Lane_Changing_Assistant_Step_Rp_Highway_Input_Signal_DE_Highway_Input_Signal
         () == 1) &&
        (Rte_IRead_Highway_Assistant_Lane_Changing_Assistant_Step_Rp_Enable_Display_DE_Enable_Display
         () == Highway_Assistant_Lane_Chang_DW.on_l) &&
        (Rte_IRead_Highway_Assistant_Lane_Changing_Assistant_Step_Rp_Input_Switch_DE_Input_Switch
         () == Highway_Assistant_Lane_Chang_DW.on_l)) {
      Highway_Assistant_Lane_Chang_DW.is_c2_Highway_Assistant_Lane_Ch =
        Highway_Assistant_Lan_IN_Case_2;
      Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_1 = 213U;
      Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_2 = 183U;
      Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_3 = 9U;
      Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_4 = 94U;
    }

    /* case IN_Case_2: */
  } else if
      ((Rte_IRead_Highway_Assistant_Lane_Changing_Assistant_Step_Rp_Highway_Input_Signal_DE_Highway_Input_Signal
        () == 1) &&
       (Rte_IRead_Highway_Assistant_Lane_Changing_Assistant_Step_Rp_Enable_Display_DE_Enable_Display
        () == Highway_Assistant_Lane_Chang_DW.off_i) &&
       (Rte_IRead_Highway_Assistant_Lane_Changing_Assistant_Step_Rp_Input_Switch_DE_Input_Switch
        () == Highway_Assistant_Lane_Chang_DW.on_l)) {
    Highway_Assistant_Lane_Chang_DW.is_c2_Highway_Assistant_Lane_Ch =
      Highway_Assistant_Lan_IN_Case_1;
    Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_1 = 232U;
    Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_2 = 183U;
    Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_3 = 41U;
    Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_4 = 94U;
  } else {
    Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_1 = 213U;
    Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_2 = 183U;
    Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_3 = 9U;
    Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_4 = 94U;
  }

  /* End of Chart: '<S2>/Highway_DisplayUnit' */

  /* Chart: '<S3>/Lane_DisplayUnit' 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_Assistant_Lan_IN_Case_1;
    Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_1 = 132U;
    Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_2 = 185U;
    Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_3 = 54U;
    Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_4 = 67U;
  } else if (Highway_Assistant_Lane_Chang_DW.is_c1_Highway_Assistant_Lane_Ch ==
             Highway_Assistant_Lan_IN_Case_1) {
    if ((Rte_IRead_Highway_Assistant_Lane_Changing_Assistant_Step_Rp_Lane_Input_Signal_DE_Lane_Input_Signal
         () == 6) &&
        (Rte_IRead_Highway_Assistant_Lane_Changing_Assistant_Step_Rp_Enable_Display_DE_Enable_Display
         () == Highway_Assistant_Lane_Chang_DW.off) &&
        (Rte_IRead_Highway_Assistant_Lane_Changing_Assistant_Step_Rp_Input_Switch_DE_Input_Switch
         () == Highway_Assistant_Lane_Chang_DW.on)) {
      Highway_Assistant_Lane_Chang_DW.is_c1_Highway_Assistant_Lane_Ch =
        Highway_Assistant_Lan_IN_Case_2;
      Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_1 = 127U;
      Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_2 = 248U;
      Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_3 = 186U;
      Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_4 = 84U;
    }

    /* case IN_Case_2: */
  } else if
      ((Rte_IRead_Highway_Assistant_Lane_Changing_Assistant_Step_Rp_Lane_Input_Signal_DE_Lane_Input_Signal
        () == 6) &&
       (Rte_IRead_Highway_Assistant_Lane_Changing_Assistant_Step_Rp_Enable_Display_DE_Enable_Display
        () == Highway_Assistant_Lane_Chang_DW.on) &&
       (Rte_IRead_Highway_Assistant_Lane_Changing_Assistant_Step_Rp_Input_Switch_DE_Input_Switch
        () == Highway_Assistant_Lane_Chang_DW.on)) {
    Highway_Assistant_Lane_Chang_DW.is_c1_Highway_Assistant_Lane_Ch =
      Highway_Assistant_Lan_IN_Case_1;
    Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_1 = 132U;
    Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_2 = 185U;
    Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_3 = 54U;
    Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_4 = 67U;
  } else {
    Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_1 = 127U;
    Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_2 = 248U;
    Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_3 = 186U;
    Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_4 = 84U;
  }

  /* End of Chart: '<S3>/Lane_DisplayUnit' */

  /* Switch: '<S4>/Switch' incorporates:
   *  Inport: '<Root>/Highway_Input_Signal'
   *  Switch: '<S4>/Switch1'
   *  Switch: '<S4>/Switch2'
   *  Switch: '<S4>/Switch3'
   */
  if (Rte_IRead_Highway_Assistant_Lane_Changing_Assistant_Step_Rp_Highway_Input_Signal_DE_Highway_Input_Signal
      () != 0) {
    /* Outport: '<Root>/Display_Mode_1' */
    Rte_IWrite_Highway_Assistant_Lane_Changing_Assistant_Step_Display_Mode_1_Display_Mode_1
      (Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_1);

    /* Outport: '<Root>/Display_Mode_2' */
    Rte_IWrite_Highway_Assistant_Lane_Changing_Assistant_Step_Display_Mode_2_Display_Mode_2
      (Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_2);

    /* Outport: '<Root>/Display_Mode_3' */
    Rte_IWrite_Highway_Assistant_Lane_Changing_Assistant_Step_Display_Mode_3_Display_Mode_3
      (Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_3);

    /* Outport: '<Root>/Display_Mode_4' */
    Rte_IWrite_Highway_Assistant_Lane_Changing_Assistant_Step_Display_Mode_4_Display_Mode_4
      (Highway_Assistant_Lane_Changi_B.Highway_Display_Mode_4);
  } else {
    /* Outport: '<Root>/Display_Mode_1' */
    Rte_IWrite_Highway_Assistant_Lane_Changing_Assistant_Step_Display_Mode_1_Display_Mode_1
      (Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_1);

    /* Outport: '<Root>/Display_Mode_2' */
    Rte_IWrite_Highway_Assistant_Lane_Changing_Assistant_Step_Display_Mode_2_Display_Mode_2
      (Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_2);

    /* Outport: '<Root>/Display_Mode_3' */
    Rte_IWrite_Highway_Assistant_Lane_Changing_Assistant_Step_Display_Mode_3_Display_Mode_3
      (Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_3);

    /* Outport: '<Root>/Display_Mode_4' */
    Rte_IWrite_Highway_Assistant_Lane_Changing_Assistant_Step_Display_Mode_4_Display_Mode_4
      (Highway_Assistant_Lane_Changi_B.Lane_Display_Mode_4);
  }

  /* End of Switch: '<S4>/Switch' */
}

/* Model initialize function */
void Highway_Assistant_Lane_Changing_Assistant_Init(void)
{
  /* SystemInitialize for Chart: '<S2>/Highway_DisplayUnit' */
  Highway_Assistant_Lane_Chang_DW.on_l = 1.0;

  /* SystemInitialize for Chart: '<S3>/Lane_DisplayUnit' */
  Highway_Assistant_Lane_Chang_DW.on = 1.0;
}

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

CONCLUSION

  • The model for Lane Changing Assistant is developed using MATLAB Simulink as per MBD guidelines.
  • Simulink Data Dictionary is created for the model and is linked to the model.
  • Requirement document is tagged with each subsystem.
  • All the input & output signals are mapped into the Autosar Editor.
  • Code Generation Profile is chosen to be Autosar Coder.
  • Model Advisor Report is performed, and the the Report is Generated.
  • Code generation is executed using Autosar Coder.
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.