Project 1 (Mini Project on Vehicle Direction Detection
Vehicle Direction Detection
Objective :
- Development of MATLAB Simulink model as per requirement.
- Tag the requirements to the simulink model; tagging requirement 1 & requirement 2 to their corresponding subsystems is fine.
- MBD compliant changes, Data Dictionary creation & code generation is added advantage, and that is not scope of this project.
- If choosing code generation, Storage class for Input signals: ImportedExtern; Storage class for Output signal: Export to File; Storage class for local signals: localizable; Storage class for calibration signals: Const.
- Choose sample time for all signals as 0.01s
General Overview:
Identifying the direction of the vehicle is one of the important & diverse features in Autonomous driving & Advanced Driver Assistance Features. This particular sub-feature of identifying the direction of vehicle is basically identifying the direction the vehicle is taking based on the camera input.
Camera reads the road signs & stores into its memory with unique values for left turn, right turn & straight drive. Depending on the direction it is taking, final indication is given to the driver – as an indication if he is driving in the recommended direction or not.
Vehicle Direction Determination can also be coupled along - side features like GPS systems to identify whether the vehicle is reaching its destination in an optimized manner. This sub feature can also be used along with Lane Detection, Highway Warning, Ramp Entry / Exit in Wrong Way Detection etc.
MATLAB MODEL:

REQUIREMENT 1)
- Steering wheel input as yaw rate (Signal name: SteeringWheel_YawDegreeInput) is the input for this system.
- This is compared against 3 angular values, one each for left turn, right turn & straight drive (Calibration Values: Right_Turn_AngularLimit, Left_Turn_AngularLimit, Straight_Drive_Steering_Angle) to say which specific direction the steering wheel is turning towards.
- Use switch blocks to compare & develop this requirement. Keep this requirement in a subsystem & output of this requirement is a local signal (Signal Name: Vehicle_Turn_Status).

Requirement – 2:
- Keep this requirement as a separate subsystem. Inputs to this requirement are local signal from requirement 1 (Signal Name: Vehicle_Turn_Status) & an input signal from camera (Signal Name: CameraInput_RoadSign), which confirms the occurrence of a road sign.
- Signal Vehicle_Turn_Status is compared against calibration values (Calibration Values: RightTurn_RoadSign, LeftTurn_RoadSign, Straight_RoadSign), if each of them is found equal, then each of the three corresponding output is compared against the camera input signal,
- Using a logical operator block, only one among them is finally given as output signal (Signal Name: Vehicle_Direction_Indicator).

FOR SIGNAL RESOLVING:
1) click on signal and right click

2) go to properties

3)go to code genration and click on signal name must resolve to simulink signal object.

SLDD file:

RESULTS:
1) STRAIGHT TURN:

2)RIGHT TURN:

3) LEFT TURN:

CODE GENEARTION:
1) go to apps and embedded coder

2)then go to c code and and then click built.

thus c code is:
/*
* File: miniprojectlastadas.h
*
* Code generated for Simulink model 'miniprojectlastadas'.
*
* Model version : 1.1
* Simulink Coder version : 9.3 (R2020a) 18-Nov-2019
* C/C++ source code generated on : Sat Sep 25 08:58:40 2021
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#ifndef RTW_HEADER_miniprojectlastadas_h_
#define RTW_HEADER_miniprojectlastadas_h_
#ifndef miniprojectlastadas_COMMON_INCLUDES_
# define miniprojectlastadas_COMMON_INCLUDES_
#include "rtwtypes.h"
#endif /* miniprojectlastadas_COMMON_INCLUDES_ */
#include "miniprojectlastadas_types.h"
/* Macros for accessing real-time model data structure */
#ifndef rtmGetErrorStatus
# define rtmGetErrorStatus(rtm) ((rtm)->errorStatus)
#endif
#ifndef rtmSetErrorStatus
# define rtmSetErrorStatus(rtm, val) ((rtm)->errorStatus = (val))
#endif
/* External outputs (root outports fed by signals with default storage) */
typedef struct {
boolean_T vehicle_direction_indicator[3];
/* '<Root>/vehicle_direction_indicator' */
} ExtY_miniprojectlastadas_T;
/* Real-time Model Data Structure */
struct tag_RTM_miniprojectlastadas_T {
const char_T * volatile errorStatus;
};
/* External outputs (root outports fed by signals with default storage) */
extern ExtY_miniprojectlastadas_T miniprojectlastadas_Y;
/* Model entry point functions */
extern void miniprojectlastadas_initialize(void);
extern void miniprojectlastadas_step(void);
extern void miniprojectlastadas_terminate(void);
/* Exported data declaration */
/* Const memory section */
/* Declaration for custom storage class: Const */
extern const int16_T left_turn_angularlimit;/* Referenced by: '<S3>/Constant1' */
extern const int16_T left_turn_roadsign;/* Referenced by: '<S2>/Constant1' */
extern const int16_T right_turn_angularlimit;/* Referenced by: '<S3>/Constant' */
extern const int16_T right_turn_roadsign;/* Referenced by: '<S2>/Constant' */
extern const int16_T straight_drive_steering_angle;/* Referenced by: '<S3>/Constant2' */
extern const int16_T straight_roadsign;/* Referenced by: '<S2>/Constant2' */
/* Real-time Model object */
extern RT_MODEL_miniprojectlastadas_T *const miniprojectlastadas_M;
/*-
* These blocks were eliminated from the model due to optimizations:
*
* Block '<Root>/Display' : Unused code path elimination
*/
/*-
* The generated code includes comments that allow you to trace directly
* back to the appropriate location in the model. The basic format
* is <system>/block_name, where system is the system number (uniquely
* assigned by Simulink) and block_name is the name of the block.
*
* Use the MATLAB hilite_system command to trace the generated code back
* to the model. For example,
*
* hilite_system('<S3>') - opens system 3
* hilite_system('<S3>/Kp') - opens and selects block Kp which resides in S3
*
* Here is the system hierarchy for this model
*
* '<Root>' : 'miniprojectlastadas'
* '<S1>' : 'miniprojectlastadas/Subsystem2'
* '<S2>' : 'miniprojectlastadas/Subsystem2/Subsystem'
* '<S3>' : 'miniprojectlastadas/Subsystem2/Subsystem1'
*/
#endif /* RTW_HEADER_miniprojectlastadas_h_ */
/*
* File trailer for generated code.
*
* [EOF]
*/
CONCLUSION:
thus the model is successfully created from the given requirement data and the code is generated.