You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our control system is current writting in Simulink. We are converting it to C++. This task converts the DriverInterface model which is responsible for processing driver inputs (steering wheel angle, accelerator / brake pedal positions, brake lights, etc).
You will fill in a class which has an .Update() method to represent the DriverInterface behaviour.
Open the folder in Matlab r2022b. You will need Simulink installed.
In the Matlab file explorer, right click on the src/ folder and click Add to path -> Selected folders and subfolders.
You may need to do this each time you open Matlab.
Open src/controller.slx. Find the blue driver_interface block. This is what you will be recreating in C++.
Development
In driver_interface.hpp, define structs for the input and outputs (shows as variables on the left and right sides of the block, respectively).
You may need to define "enum classes" for the GOV_ input/outputs. See src/enums in the repo.
You can omit DI_*_ prefix to the variables. However, use the * character (meaning wildcard in the previous expression) to figure out the variable data type (p and V means float, b meens bool, and e mean enum).
Variable names should be in lower_snake_case following the style guide.
Double click on the DI block in Simulink to see inside. Implement this behaviour inside the .Update function in the driver_interface.cc file.
Write tests in driver_interface_test.cc. See example.
Notes
Most of the functions inside the DI block are implemented in the shared/controls folder. You should #include the relevant files and call those functions.
For example, the yellow Finite State Machine is implemented in shared/controls/driver_interface_fsm.hpp. The potentiometerProcessing block is roughly implemented as isInRange() in shared/controls/driver_interface_error_handling.h.
However, some of the functions are very simple and you can choose to "inline" them (implement directly as code instead of calling a function). The function in shared/controls/steering_angle.h is a good candidate for inlining
Resources
See the AMK, BatteryMonitor, and Simple_VD PRs for inspiration. They are implementing other blocks in the Simulink model.
The text was updated successfully, but these errors were encountered:
Development Instructions
Our control system is current writting in Simulink. We are converting it to C++. This task converts the
DriverInterface
model which is responsible for processing driver inputs (steering wheel angle, accelerator / brake pedal positions, brake lights, etc).You will fill in a
class
which has an.Update()
method to represent theDriverInterface
behaviour.Setup
src/
folder and clickAdd to path -> Selected folders and subfolders
.src/controller.slx
. Find the bluedriver_interface
block. This is what you will be recreating in C++.Development
driver_interface.hpp
, define structs for the input and outputs (shows as variables on the left and right sides of the block, respectively).GOV_
input/outputs. Seesrc/enums
in the repo.DI_*_
prefix to the variables. However, use the*
character (meaning wildcard in the previous expression) to figure out the variable data type (p
andV
meansfloat
,b
meensbool
, ande
mean enum).lower_snake_case
following the style guide..Update
function in thedriver_interface.cc
file.driver_interface_test.cc
. See example.Notes
Most of the functions inside the
DI
block are implemented in theshared/controls
folder. You should#include
the relevant files and call those functions.However, some of the functions are very simple and you can choose to "inline" them (implement directly as code instead of calling a function). The function in
shared/controls/steering_angle.h
is a good candidate for inliningResources
See the AMK, BatteryMonitor, and Simple_VD PRs for inspiration. They are implementing other blocks in the Simulink model.
The text was updated successfully, but these errors were encountered: