Challenge

Project 2-Highway Assistant-Lane Changing Assistant

AIM: To develop a Highway Assistant – Lane Changing Assistant model in Matlab Simulink as per MBD guidelines and producing model advisory report followed by code generation using Autosar coder

Step1: Creating Simulink data dictionary for the given signals list

Step2: Implementation of Requirement No 1 [Highway_DisplayUnit]

Created a subsystem with three inputs namely 'Highway_Input_Signal', 'Enable_Display' and 'Input_Switch'.

As per the requirement1, the logic is implemented in the chart block inside the sub sysytem with four outputs 'Highway_Display_Mode_1', 'Highway_Display_Mode_2', 'Highway_Display_Mode_3 and 'Highway_Display_Mode_4'.

After writing the logic in the chart block, signals used in it must be mapped to input and outports ports in the model explorer

Step3: Implementation of Requirement No 2 [Lane_DisplayUnit]

Created a subsystem with three inputs: 'Enable_Display', 'Input_Switch', 'Lane_Input_Signal'.

As per the requirement2, the logic is implemented in the chart block inside the sub sysytem with four outputs: 'Lane_Display_Mode_1', 'Lane_Display_Mode_2', 'Lane_Display_Mode_3', 'Lane_Display_Mode_4.

Inside the chart, the logic is written

The input and output signals are then resolved

Step 4: Implementation of Requirement 3:

The output of the Highway_Display_Mode and Lane_Display_Mode are provided to the Switch block. That is in total 4 switch blocks are used. The conditional input signal is taken as Highway_Input_Signal for all the blocks.

The final model is shown below

Step 5: Mapping of input and output signals into the Autosar Editor to make the model in compliance with the AUTOSAR

i)Code Generation settings: System target file to autosar.tlc

ii) Solver settings: Type to fixed step and Solver to discrete

iii) Goto APPS-->Autosar Component

Open the Code Mapping- Auosar Software Component

iv) Interfaces for the 4 input ports & their corresponding Data elements are created

For the S-R Interfaces of the model, we will rename the port with the prefix SRIf_.

For the Data Elements of the model, we will rename the port with the prefix DE_

v) Add inputs under receiver port section

For the Reciever port of the model, that is input, we will rename the port with the prefix Rp_

vi) Add oututs under sender port section

For the Sender port of the model, that is output, we will rename the port with the prefix Pp_.

Autosar dictionary is configured

Step 6: Model validation with AUTOSAR Compliance

Click on the right mark for model validation

Step 7: Model Advisory Report

Step 8: Code Generation

/*
 
 
* File: HA_LaneChangingAssistant_model.c
 
 
*
 
 
* Code generated for Simulink model 'HA_LaneChangingAssistant_model'.
 
 
*
 
 
* Model version : 1.17
 
 
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
 
 
* C/C++ source code generated on : Thu Jan 26 13:33:23 2023
 
 
*
 
 
* Target selection: autosar.tlc
 
 
* Embedded hardware selection: Intel->x86-64 (Windows64)
 
 
* Code generation objectives: Unspecified
 
 
* Validation result: Not run
 
 
*/
 
 
 
 
 
#include "HA_LaneChangingAssistant_model.h"
 
 
#include "HA_LaneChangingAssistant_model_private.h"
 
 
 
 
 
/* Named constants for Chart: '/Chart' */
 
 
#define HA_LaneChangingA_IN_Condition_1 ((uint8)1U)
 
 
#define HA_LaneChangingA_IN_Condition_2 ((uint8)2U)
 
 
 
 
 
/* Block states (default storage) */
 
 
DW_HA_LaneChangingAssistant_m_T HA_LaneChangingAssistant_mod_DW;
 
 
 
 
 
/* Model step function */
 
 
void HA_LaneChangingAssistant_model_Step(void)
 
 
{
 
 
float64 tmp;
 
 
sint32 rtb_Highway_Display_Mode_1;
 
 
sint32 rtb_Highway_Display_Mode_3;
 
 
sint32 rtb_Lane_Display_Mode_1;
 
 
sint32 rtb_Lane_Display_Mode_2;
 
 
sint32 rtb_Lane_Display_Mode_3;
 
 
sint32 rtb_Lane_Display_Mode_4;
 
 
 
 
 
/* Chart: '/Chart' incorporates:
 
 
* Inport: '/Enable_Display'
 
 
* Inport: '/Highway_Input_Signal'
 
 
* Inport: '/Input_Switch'
 
 
*/
 
 
if (HA_LaneChangingAssistant_mod_DW.is_active_c3_HA_LaneChangingAss == 0U) {
 
 
HA_LaneChangingAssistant_mod_DW.is_active_c3_HA_LaneChangingAss = 1U;
 
 
HA_LaneChangingAssistant_mod_DW.is_c3_HA_LaneChangingAssistant_ =
 
 
HA_LaneChangingA_IN_Condition_1;
 
 
rtb_Highway_Display_Mode_1 = 232;
 
 
rtb_Highway_Display_Mode_3 = 41;
 
 
} else if (HA_LaneChangingAssistant_mod_DW.is_c3_HA_LaneChangingAssistant_ ==
 
 
HA_LaneChangingA_IN_Condition_1) {
 
 
if ((Rte_IRead_HA_LaneChangingAssistant_model_Step_Rp_Highway_Input_Signal_DE_Highway_Input_Signal
 
 
() == 1.0) &&
 
 
(Rte_IRead_HA_LaneChangingAssistant_model_Step_Rp_Enable_Display_DE_Enable_Display
 
 
() == 1.0) &&
 
 
(Rte_IRead_HA_LaneChangingAssistant_model_Step_Rp_Input_Switch_DE_Input_Switch
 
 
() == 1.0)) {
 
 
HA_LaneChangingAssistant_mod_DW.is_c3_HA_LaneChangingAssistant_ =
 
 
HA_LaneChangingA_IN_Condition_2;
 
 
rtb_Highway_Display_Mode_1 = 213;
 
 
rtb_Highway_Display_Mode_3 = 9;
 
 
} else {
 
 
rtb_Highway_Display_Mode_1 = 232;
 
 
rtb_Highway_Display_Mode_3 = 41;
 
 
}
 
 
 
 
 
/* case IN_Condition_2: */
 
 
} else if
 
 
((Rte_IRead_HA_LaneChangingAssistant_model_Step_Rp_Highway_Input_Signal_DE_Highway_Input_Signal
 
 
() == 1.0) &&
 
 
(Rte_IRead_HA_LaneChangingAssistant_model_Step_Rp_Enable_Display_DE_Enable_Display
 
 
() == 0.0) &&
 
 
(Rte_IRead_HA_LaneChangingAssistant_model_Step_Rp_Input_Switch_DE_Input_Switch
 
 
() == 1.0)) {
 
 
HA_LaneChangingAssistant_mod_DW.is_c3_HA_LaneChangingAssistant_ =
 
 
HA_LaneChangingA_IN_Condition_1;
 
 
rtb_Highway_Display_Mode_1 = 232;
 
 
rtb_Highway_Display_Mode_3 = 41;
 
 
} else {
 
 
rtb_Highway_Display_Mode_1 = 213;
 
 
rtb_Highway_Display_Mode_3 = 9;
 
 
}
 
 
 
 
 
/* End of Chart: '/Chart' */
 
 
 
 
 
/* Chart: '/Chart' incorporates:
 
 
* Inport: '/Enable_Display'
 
 
* Inport: '/Input_Switch'
 
 
* Inport: '/Lane_Input_Signal'
 
 
*/
 
 
if (HA_LaneChangingAssistant_mod_DW.is_active_c1_HA_LaneChangingAss == 0U) {
 
 
HA_LaneChangingAssistant_mod_DW.is_active_c1_HA_LaneChangingAss = 1U;
 
 
HA_LaneChangingAssistant_mod_DW.is_c1_HA_LaneChangingAssistant_ =
 
 
HA_LaneChangingA_IN_Condition_1;
 
 
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 (HA_LaneChangingAssistant_mod_DW.is_c1_HA_LaneChangingAssistant_ ==
 
 
HA_LaneChangingA_IN_Condition_1) {
 
 
if ((Rte_IRead_HA_LaneChangingAssistant_model_Step_Rp_Lane_Input_Signal_DE_Lane_Input_Signal
 
 
() == 6.0) &&
 
 
(Rte_IRead_HA_LaneChangingAssistant_model_Step_Rp_Enable_Display_DE_Enable_Display
 
 
() == 1.0) &&
 
 
(Rte_IRead_HA_LaneChangingAssistant_model_Step_Rp_Input_Switch_DE_Input_Switch
 
 
() == 1.0)) {
 
 
HA_LaneChangingAssistant_mod_DW.is_c1_HA_LaneChangingAssistant_ =
 
 
HA_LaneChangingA_IN_Condition_2;
 
 
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 = 132;
 
 
rtb_Lane_Display_Mode_2 = 185;
 
 
rtb_Lane_Display_Mode_3 = 54;
 
 
rtb_Lane_Display_Mode_4 = 67;
 
 
}
 
 
 
 
 
/* case IN_Condition_2: */
 
 
} else if
 
 
((Rte_IRead_HA_LaneChangingAssistant_model_Step_Rp_Lane_Input_Signal_DE_Lane_Input_Signal
 
 
() == 6.0) &&
 
 
(Rte_IRead_HA_LaneChangingAssistant_model_Step_Rp_Enable_Display_DE_Enable_Display
 
 
() == 0.0) &&
 
 
(Rte_IRead_HA_LaneChangingAssistant_model_Step_Rp_Input_Switch_DE_Input_Switch
 
 
() == 1.0)) {
 
 
HA_LaneChangingAssistant_mod_DW.is_c1_HA_LaneChangingAssistant_ =
 
 
HA_LaneChangingA_IN_Condition_1;
 
 
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 {
 
 
rtb_Lane_Display_Mode_1 = 127;
 
 
rtb_Lane_Display_Mode_2 = 248;
 
 
rtb_Lane_Display_Mode_3 = 186;
 
 
rtb_Lane_Display_Mode_4 = 84;
 
 
}
 
 
 
 
 
/* End of Chart: '/Chart' */
 
 
 
 
 
/* Switch: '/Switch' incorporates:
 
 
* Inport: '/Highway_Input_Signal'
 
 
* Switch: '/Switch1'
 
 
* Switch: '/Switch2'
 
 
*/
 
 
tmp =
 
 
Rte_IRead_HA_LaneChangingAssistant_model_Step_Rp_Highway_Input_Signal_DE_Highway_Input_Signal
 
 
();
 
 
if (tmp > 0.0) {
 
 
/* Outport: '/Display_Mode_1' */
 
 
Rte_IWrite_HA_LaneChangingAssistant_model_Step_Display_Mode_1_Display_Mode_1
 
 
(rtb_Highway_Display_Mode_1);
 
 
rtb_Lane_Display_Mode_2 = 183;
 
 
} else {
 
 
/* Outport: '/Display_Mode_1' */
 
 
Rte_IWrite_HA_LaneChangingAssistant_model_Step_Display_Mode_1_Display_Mode_1
 
 
(rtb_Lane_Display_Mode_1);
 
 
}
 
 
 
 
 
/* End of Switch: '/Switch' */
 
 
 
 
 
/* Outport: '/Display_Mode_2' */
 
 
Rte_IWrite_HA_LaneChangingAssistant_model_Step_Display_Mode_2_Display_Mode_2
 
 
(rtb_Lane_Display_Mode_2);
 
 
 
 
 
/* Switch: '/Switch2' incorporates:
 
 
* Switch: '/Switch3'
 
 
*/
 
 
if (tmp > 0.0) {
 
 
/* Outport: '/Display_Mode_3' */
 
 
Rte_IWrite_HA_LaneChangingAssistant_model_Step_Display_Mode_3_Display_Mode_3
 
 
(rtb_Highway_Display_Mode_3);
 
 
rtb_Lane_Display_Mode_4 = 0;
 
 
} else {
 
 
/* Outport: '/Display_Mode_3' */
 
 
Rte_IWrite_HA_LaneChangingAssistant_model_Step_Display_Mode_3_Display_Mode_3
 
 
(rtb_Lane_Display_Mode_3);
 
 
}
 
 
 
 
 
/* Outport: '/Display_Mode_4' */
 
 
Rte_IWrite_HA_LaneChangingAssistant_model_Step_Display_Mode_4_Display_Mode_4
 
 
(rtb_Lane_Display_Mode_4);
 
 
}
 
 
 
 
 
/* Model initialize function */
 
 
void HA_LaneChangingAssistant_model_Init(void)
 
 
{
 
 
/* (no initialization code required) */
 
 
}
 
 
 
 
 
/*
 
 
* File trailer for generated code.
 
 
*
 
 
* [EOF]
 
 
*/
 
 
 
 
 

Conclusion: Developed a Model of a feature of Highway Assistant-Lane Changing Assistant as per MAAB guidelines, produced Model Advisor Report as well as generated Code using AUTOSAR Coder

 

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