Challenge

Project 1- Traffic Jam Assistant Feature

Traffic Jam Assistant Feature

Introduction to the Feature:

Traffic Jam Assistant is one of the most common feature in Advanced Driver Assistance System. Traffic Jam Assistant helps the driver arrive more relaxed at their destination, even in dense traffic or in traffic jams. As a partially automated comfort function, the system takes over the longitudinal & lateral guidance of the vehicle. This means that the car can drive off, accelerate & brake automatically, as well as steer the vehicle within certain constraints. The driver has to permanently supervise the system & be ready to take over the complete control of the vehicle at any time.

Traffic Jam Assistant system helps to avoid rear end collisions in dense traffic conditions & traffic jams. In Traffic jams, the vehicle takes over driving off, acceleration, braking and steering within same lane.

Basic Working Principle:

Traffic Jam Assistant is based on the sensors and the functionality of the Adaptive Cruise Control (ACC) with stop & go and Lane Keeping Support (LKS). When ACC ‘Stop & Go’ is turned ON, the Traffic Jam Assistant continuously analyses the speed of the surrounding vehicles and compares it with the own driving speed. If the system detects dense traffic or a traffic jam at speeds less than 60 kmph, the driver can activate the functionality by press of a button. The vehicle will now automatically follow the vehicle in front, takes over driving off, acceleration, braking and steering within same lane.

Information regarding the Traffic Jam Assistant will be available to be displayed to the driver in the Instrument Panel Cluster (IPC). The Algorithm which the students need to implement here in this project is predominantly based on IPC units.

File: ert_main.c

1 /*
2 * File: ert_main.c
3 *
4 * Code generated for Simulink model 'Traffic_Jam_Assistant'.
5 *
6 * Model version : 1.20
7 * Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
8 * C/C++ source code generated on : Sun Jan 9 21:57:20 2022
9 *
10 * Target selection: ert.tlc
11 * Embedded hardware selection: Intel->x86-64 (Windows64)
12 * Code generation objectives: Unspecified
13 * Validation result: Not run
14 */
15  
16 #include
17 #include /* This ert_main.c example uses printf/fflush */
18 #include "Traffic_Jam_Assistant.h" /* Model's header file */
19 #include "rtwtypes.h"
20  
21 /*
22 * Associating rt_OneStep with a real-time clock or interrupt service routine
23 * is what makes the generated code "real-time". The function rt_OneStep is
24 * always associated with the base rate of the model. Subrates are managed
25 * by the base rate from inside the generated code. Enabling/disabling
26 * interrupts and floating point context switches are target specific. This
27 * example code indicates where these should take place relative to executing
28 * the generated code step function. Overrun behavior should be tailored to
29 * your application needs. This example simply sets an error status in the
30 * real-time model and returns from rt_OneStep.
31 */
32 void rt_OneStep(void);
33 void rt_OneStep(void)
34 {
35 static boolean_T OverrunFlag = false;
36  
37 /* Disable interrupts here */
38  
39 /* Check for overrun */
40 if (OverrunFlag) {
41 rtmSetErrorStatus(Traffic_Jam_Assistant_M, "Overrun");
42 return;
43 }
44  
45 OverrunFlag = true;
46  
47 /* Save FPU context here (if necessary) */
48 /* Re-enable timer or interrupt here */
49 /* Set model inputs here */
50  
51 /* Step the model */
52 Traffic_Jam_Assistant_step();
53  
54 /* Get model outputs here */
55  
56 /* Indicate task complete */
57 OverrunFlag = false;
58  
59 /* Disable interrupts here */
60 /* Restore FPU context here (if necessary) */
61 /* Enable interrupts here */
62 }
63  
64 /*
65 * The example "main" function illustrates what is required by your
66 * application code to initialize, execute, and terminate the generated code.
67 * Attaching rt_OneStep to a real-time clock is target specific. This example
68 * illustrates how you do this relative to initializing the model.
69 */
70 int_T main(int_T argc, const char *argv[])
71 {
72 /* Unused arguments */
73 (void)(argc);
74 (void)(argv);
75  
76 /* Initialize model */
77 Traffic_Jam_Assistant_initialize();
78  
79 /* Attach rt_OneStep to a timer or interrupt service routine with
80 * period 0.2 seconds (the model's base sample time) here. The
81 * call syntax for rt_OneStep is
82 *
83 * rt_OneStep();
84 */
85 printf("Warning: The simulation will run forever. "
86 "Generated ERT main won't simulate model step behavior. "
87 "To change this behavior select the 'MAT-file logging' option.\n");
88 fflush((NULL));
89 while (rtmGetErrorStatus(Traffic_Jam_Assistant_M) == (NULL)) {
90 /* Perform other application tasks here */
91 }
92  
93 /* Disable rt_OneStep() here */
94  
95 /* Terminate model */
96 Traffic_Jam_Assistant_terminate();
97 return 0;
98 }
99  
100 /*
101 * File trailer for generated code.
102 *
103 * [EOF]
104 */
105  

File: Traffic_Jam_Assistant.c

1 /*
2 * File: Traffic_Jam_Assistant.c
3 *
4 * Code generated for Simulink model 'Traffic_Jam_Assistant'.
5 *
6 * Model version : 1.20
7 * Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
8 * C/C++ source code generated on : Sun Jan 9 21:57:20 2022
9 *
10 * Target selection: ert.tlc
11 * Embedded hardware selection: Intel->x86-64 (Windows64)
12 * Code generation objectives: Unspecified
13 * Validation result: Not run
14 */
15  
16 #include "Traffic_Jam_Assistant.h"
17 #include "Traffic_Jam_Assistant_private.h"
18  
19 /* External inputs (root inport signals with default storage) */
20 ExtU_Traffic_Jam_Assistant_T Traffic_Jam_Assistant_U;
21  
22 /* External outputs (root outports fed by signals with default storage) */
23 ExtY_Traffic_Jam_Assistant_T Traffic_Jam_Assistant_Y;
24  
25 /* Real-time model */
26 static RT_MODEL_Traffic_Jam_Assistan_T Traffic_Jam_Assistant_M_;
27 RT_MODEL_Traffic_Jam_Assistan_T *const Traffic_Jam_Assistant_M =
28 &Traffic_Jam_Assistant_M_;
29  
30 /* Model step function */
31 void Traffic_Jam_Assistant_step(void)
32 {
33 uint8_T tmp;
34  
35 /* Switch: '/Switch' incorporates:
36 * Constant: '/VOLTAGE_MAXIMUM_RANGE'
37 * Constant: '/VOLTAGE_MINIMUM_RANGE'
38 * Inport: '/Input_Switch'
39 * Inport: '/Input_Voltage'
40 * Logic: '/AND1'
41 * Logic: '/NOT1'
42 * Logic: '/AND'
43 * RelationalOperator: '/GreaterThanOrEqual'
44 * RelationalOperator: '/LessThanOrEqual'
45 */
46 if ((!Traffic_Jam_Assistant_U.Input_Switch) &&
47 ((Traffic_Jam_Assistant_U.Input_Voltage >= 30) &&
48 (Traffic_Jam_Assistant_U.Input_Voltage <= 50)) &&
49 Traffic_Jam_Assistant_ConstB.RelationalOperator) {
50 /* Saturate: '/Saturation' incorporates:
51 * Inport: '/Enable_Display'
52 */
53 if (Traffic_Jam_Assistant_U.Enable_Display < 7) {
54 tmp = Traffic_Jam_Assistant_U.Enable_Display;
55 } else {
56 tmp = 7U;
57 }
58  
59 /* End of Saturate: '/Saturation' */
60  
61 /* MultiPortSwitch: '/ ' */
62 switch (tmp) {
63 case 0:
64 /* Outport: '/Output_Display' incorporates:
65 * Constant: '/ON_MODE'
66 */
67 Traffic_Jam_Assistant_Y.Output_Display = 1U;
68 break;
69  
70 case 1:
71 /* Outport: '/Output_Display' incorporates:
72 * Constant: '/ON_MODE'
73 */
74 Traffic_Jam_Assistant_Y.Output_Display = 1U;
75 break;
76  
77 case 2:
78 /* Outport: '/Output_Display' incorporates:
79 * Constant: '/OFF_MODE'
80 */
81 Traffic_Jam_Assistant_Y.Output_Display = 2U;
82 break;
83  
84 case 3:
85 /* Outport: '/Output_Display' incorporates:
86 * Constant: '/OFF_MODE'
87 */
88 Traffic_Jam_Assistant_Y.Output_Display = 2U;
89 break;
90  
91 default:
92 /* Outport: '/Output_Display' incorporates:
93 * Constant: '/STANDBY_MODE'
94 */
95 Traffic_Jam_Assistant_Y.Output_Display = 3U;
96 break;
97 }
98  
99 /* End of MultiPortSwitch: '/ ' */
100 } else {
101 /* Outport: '/Output_Display' incorporates:
102 * Constant: '/NO_DISPLAY'
103 */
104 Traffic_Jam_Assistant_Y.Output_Display = 0U;
105 }
106  
107 /* End of Switch: '/Switch' */
108 }
109  
110 /* Model initialize function */
111 void Traffic_Jam_Assistant_initialize(void)
112 {
113 /* (no initialization code required) */
114 }
115  
116 /* Model terminate function */
117 void Traffic_Jam_Assistant_terminate(void)
118 {
119 /* (no terminate code required) */
120 }
121  
122 /*
123 * File trailer for generated code.
124 *
125 * [EOF]
126 */
127  

File: Traffic_Jam_Assistant.h

1 /*
2 * File: Traffic_Jam_Assistant.h
3 *
4 * Code generated for Simulink model 'Traffic_Jam_Assistant'.
5 *
6 * Model version : 1.20
7 * Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
8 * C/C++ source code generated on : Sun Jan 9 21:57:20 2022
9 *
10 * Target selection: ert.tlc
11 * Embedded hardware selection: Intel->x86-64 (Windows64)
12 * Code generation objectives: Unspecified
13 * Validation result: Not run
14 */
15  
16 #ifndef RTW_HEADER_Traffic_Jam_Assistant_h_
17 #define RTW_HEADER_Traffic_Jam_Assistant_h_
18 #ifndef Traffic_Jam_Assistant_COMMON_INCLUDES_
19 #define Traffic_Jam_Assistant_COMMON_INCLUDES_
20 #include "rtwtypes.h"
21 #endif /* Traffic_Jam_Assistant_COMMON_INCLUDES_ */
22  
23 #include "Traffic_Jam_Assistant_types.h"
24  
25 /* Macros for accessing real-time model data structure */
26 #ifndef rtmGetErrorStatus
27 #define rtmGetErrorStatus(rtm) ((rtm)->errorStatus)
28 #endif
29  
30 #ifndef rtmSetErrorStatus
31 #define rtmSetErrorStatus(rtm, val) ((rtm)->errorStatus = (val))
32 #endif
33  
34 /* Invariant block signals (default storage) */
35 typedef struct {
36 const boolean_T RelationalOperator; /* '/Relational Operator' */
37 } ConstB_Traffic_Jam_Assistant_T;
38  
39 /* External inputs (root inport signals with default storage) */
40 typedef struct {
41 uint8_T Input_Voltage; /* '/Input_Voltage' */
42 uint8_T Enable_Display; /* '/Enable_Display' */
43 boolean_T Input_Switch; /* '/Input_Switch' */
44 } ExtU_Traffic_Jam_Assistant_T;
45  
46 /* External outputs (root outports fed by signals with default storage) */
47 typedef struct {
48 uint8_T Output_Display; /* '/Output_Display' */
49 } ExtY_Traffic_Jam_Assistant_T;
50  
51 /* Real-time Model Data Structure */
52 struct tag_RTM_Traffic_Jam_Assistant_T {
53 const char_T * volatile errorStatus;
54 };
55  
56 /* External inputs (root inport signals with default storage) */
57 extern ExtU_Traffic_Jam_Assistant_T Traffic_Jam_Assistant_U;
58  
59 /* External outputs (root outports fed by signals with default storage) */
60 extern ExtY_Traffic_Jam_Assistant_T Traffic_Jam_Assistant_Y;
61 extern const ConstB_Traffic_Jam_Assistant_T Traffic_Jam_Assistant_ConstB;/* constant block i/o */
62  
63 /* Model entry point functions */
64 extern void Traffic_Jam_Assistant_initialize(void);
65 extern void Traffic_Jam_Assistant_step(void);
66 extern void Traffic_Jam_Assistant_terminate(void);
67  
68 /* Real-time Model object */
69 extern RT_MODEL_Traffic_Jam_Assistan_T *const Traffic_Jam_Assistant_M;
70  
71 /*-
72 * The generated code includes comments that allow you to trace directly
73 * back to the appropriate location in the model. The basic format
74 * is /block_name, where system is the system number (uniquely
75 * assigned by Simulink) and block_name is the name of the block.
76 *
77 * Use the MATLAB hilite_system command to trace the generated code back
78 * to the model. For example,
79 *
80 * hilite_system('') - opens system 3
81 * hilite_system('/Kp') - opens and selects block Kp which resides in S3
82 *
83 * Here is the system hierarchy for this model
84 *
85 * '' : 'Traffic_Jam_Assistant'
86 * '' : 'Traffic_Jam_Assistant/Traffic_Jam_Assitant'
87 * '' : 'Traffic_Jam_Assistant/Traffic_Jam_Assitant/DisplayUnitSubsystem'
88 * '' : 'Traffic_Jam_Assistant/Traffic_Jam_Assitant/Requirement_No_1'
89 */
90 #endif /* RTW_HEADER_Traffic_Jam_Assistant_h_ */
91  
92 /*
93 * File trailer for generated code.
94 *
95 * [EOF]
96 */
97  

File: Traffic_Jam_Assistant_private.h

1 /*
2 * File: Traffic_Jam_Assistant_private.h
3 *
4 * Code generated for Simulink model 'Traffic_Jam_Assistant'.
5 *
6 * Model version : 1.20
7 * Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
8 * C/C++ source code generated on : Sun Jan 9 21:57:20 2022
9 *
10 * Target selection: ert.tlc
11 * Embedded hardware selection: Intel->x86-64 (Windows64)
12 * Code generation objectives: Unspecified
13 * Validation result: Not run
14 */
15  
16 #ifndef RTW_HEADER_Traffic_Jam_Assistant_private_h_
17 #define RTW_HEADER_Traffic_Jam_Assistant_private_h_
18 #include "rtwtypes.h"
19 #endif /* RTW_HEADER_Traffic_Jam_Assistant_private_h_ */
20  
21 /*
22 * File trailer for generated code.
23 *
24 * [EOF]
25 */
26  

File: Traffic_Jam_Assistant_types.h

1 /*
2 * File: Traffic_Jam_Assistant_types.h
3 *
4 * Code generated for Simulink model 'Traffic_Jam_Assistant'.
5 *
6 * Model version : 1.20
7 * Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
8 * C/C++ source code generated on : Sun Jan 9 21:57:20 2022
9 *
10 * Target selection: ert.tlc
11 * Embedded hardware selection: Intel->x86-64 (Windows64)
12 * Code generation objectives: Unspecified
13 * Validation result: Not run
14 */
15  
16 #ifndef RTW_HEADER_Traffic_Jam_Assistant_types_h_
17 #define RTW_HEADER_Traffic_Jam_Assistant_types_h_
18  
19 /* Model Code Variants */
20  
21 /* Forward declaration for rtModel */
22 typedef struct tag_RTM_Traffic_Jam_Assistant_T RT_MODEL_Traffic_Jam_Assistan_T;
23  
24 #endif /* RTW_HEADER_Traffic_Jam_Assistant_types_h_ */
25  
26 /*
27 * File trailer for generated code.
28 *
29 * [EOF]
30 */
31  

File: Traffic_Jam_Assistant_data.c

1 /*
2 * File: Traffic_Jam_Assistant_data.c
3 *
4 * Code generated for Simulink model 'Traffic_Jam_Assistant'.
5 *
6 * Model version : 1.20
7 * Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
8 * C/C++ source code generated on : Sun Jan 9 21:57:20 2022
9 *
10 * Target selection: ert.tlc
11 * Embedded hardware selection: Intel->x86-64 (Windows64)
12 * Code generation objectives: Unspecified
13 * Validation result: Not run
14 */
15  
16 #include "Traffic_Jam_Assistant.h"
17 #include "Traffic_Jam_Assistant_private.h"
18  
19 /* Invariant block signals (default storage) */
20 const ConstB_Traffic_Jam_Assistant_T Traffic_Jam_Assistant_ConstB = {
21 1 /* '/Relational Operator' */
22 };
23  
24 /*
25 * File trailer for generated code.
26 *
27 * [EOF]
28 */
29  
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.