Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ simple controller, live parameter interface, and controller manager beginnings #3

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
560880b
initial cut
RCMast3r Aug 29, 2024
879ea69
progress on param integration, almost there needs type checking for p…
RCMast3r Aug 30, 2024
00d2896
properly handled param server
RCMast3r Aug 31, 2024
9ddd4f2
formatting mostly and addressing todos in readme
RCMast3r Aug 31, 2024
40e0cdb
current version, a lot TODO
RCMast3r Sep 2, 2024
032fe29
progress on db
RCMast3r Sep 4, 2024
bf0b3cf
updating comments
RCMast3r Sep 4, 2024
5a6feef
progressing on business logic
RCMast3r Sep 4, 2024
6da97f7
updates
RCMast3r Sep 6, 2024
c6abbf9
cooking on controller manager to make it build for now
RCMast3r Sep 6, 2024
3aeeffe
adding in beginnings of the state estimator
RCMast3r Sep 6, 2024
3952a5e
seemingly working, need to switch the command that the controller is …
RCMast3r Sep 7, 2024
f9b3cd2
seemingly working on car
RCMast3r Sep 7, 2024
15a8fc7
semi-working; removed deps because we need overlays that we can combi…
RCMast3r Sep 7, 2024
aae1fe1
added another live prarmeter
RCMast3r Sep 8, 2024
1fd0d6c
updating readme with beta feature set, closing alpha implementation
RCMast3r Sep 8, 2024
a4e850a
updating readme
RCMast3r Sep 8, 2024
2b6b41a
readme update
RCMast3r Sep 8, 2024
f82aadc
returning false on value more than possible
RCMast3r Sep 18, 2024
9da4de6
adding in some comments
RCMast3r Sep 28, 2024
feb1135
removing some autos
RCMast3r Sep 28, 2024
7803a19
adding comments describing controller class
RCMast3r Sep 28, 2024
3945b27
now using boost::program_options
RCMast3r Sep 28, 2024
72d20e4
adding user literals and type aliases for units
RCMast3r Sep 28, 2024
0c10895
added counter to enum
RCMast3r Sep 28, 2024
a4ef831
added config handling for state estimator
RCMast3r Sep 28, 2024
205ef02
adding in comments
RCMast3r Sep 28, 2024
6dd9c3f
added comments
RCMast3r Sep 29, 2024
63c77b7
adding more doxygen comments and comments in general
RCMast3r Sep 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.vscode/
result
result/
build/
build/
result-dev
result-dev/
21 changes: 11 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ project(drivebrain_software LANGUAGES CXX C)
find_package(hytech_np_proto_cpp CONFIG REQUIRED)

### this one is generated from nix-proto but using foxglove's
find_package(foxglove-schemas_proto_cpp CONFIG REQUIRED)
# find_package(foxglove-schemas_proto_cpp CONFIG REQUIRED)

### off-the-shelf libraries
find_package(nlohmann_json REQUIRED)
find_package(Boost REQUIRED COMPONENTS system)
find_package(Boost REQUIRED COMPONENTS system program_options)
find_package(protobuf REQUIRED)
find_package(GTest REQUIRED)

Expand All @@ -28,7 +28,7 @@ include(create_package)
#####################

# drivebrain core library
add_library(drivebrain_core SHARED drivebrain_core_base/src/JsonFileHandler.cpp)
add_library(drivebrain_core SHARED drivebrain_core_base/src/JsonFileHandler.cpp drivebrain_core_base/src/Configurable.cpp drivebrain_core_base/src/StateEstimator.cpp)

target_include_directories(drivebrain_core PUBLIC
$<INSTALL_INTERFACE:drivebrain_core_base/include/public>
Expand Down Expand Up @@ -56,9 +56,9 @@ target_include_directories(foxglove_param_server PUBLIC

target_link_libraries(foxglove_param_server PUBLIC
drivebrain_core
foxglove-schemas_proto_cpp::foxglove-schemas_proto_cpp
foxglove_websocket::foxglove_websocket
)
target_compile_features(foxglove_param_server PUBLIC cxx_std_17)
make_cmake_package(foxglove_param_server drivebrain)

# CAN driver for parsing and encoding CAN packets and interacting with a socketCAN interface
Expand Down Expand Up @@ -111,27 +111,28 @@ make_cmake_package(drivebrain_control drivebrain)
# Boost::boost
# )

add_executable(test_param_server test/test_param_server.cpp)
# add_executable(test_param_server test/test_param_server.cpp)

target_link_libraries(test_param_server PUBLIC
foxglove-schemas_proto_cpp::foxglove-schemas_proto_cpp
foxglove_websocket::foxglove_websocket)
# target_link_libraries(test_param_server PUBLIC
# foxglove-schemas_proto_cpp::foxglove-schemas_proto_cpp
# foxglove_websocket::foxglove_websocket)

### ###
### system executable ###
### ###
add_executable(alpha_build drivebrain_app/main.cpp)

target_link_libraries(alpha_build PUBLIC
Boost::boost
drivebrain_core
drivebrain_control
CAN_driver
foxglove_param_server
Boost::program_options
)

include(GNUInstallDirs)
install(TARGETS
test_param_server
# test_param_server
alpha_build
RUNTIME
DESTINATION ${CMAKE_INSTALL_BINDIR})
86 changes: 62 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

[wiki link](https://wiki.hytechracing.org/books/software/page/drivebrain-architecture-rev1)

## implementation details

- `drivebrain_core_base` shouldnt change from car to car but `drivebrain_core_impl` may change


## first pass
ideas:
- at first, we will generate protobuf message descriptions from the simulink model
Expand All @@ -20,6 +25,8 @@ I think for q2, we can go with keeping the state estimation monolithic?
- keep CASE, just new wrapper code for v1?

## prototyping

### ideas about manually implemented controllers vs generated controllers
idea: if we have the ability to go both ways for having the ability to both:

1. define/add inputs for a simulink model based on a .proto message
Expand All @@ -28,32 +35,63 @@ idea: if we have the ability to go both ways for having the ability to both:

and generated code for the data passing into and out of proto messages, then we can book-end the controllers and estimators.


### release planning
alpha feature set (~2 weeks, 16 days):
- [ ] basic controller library (9 days) (first pass I want to try out different types of regen handling)
- [ ] generic controller (2 days)
- [ ] live parameter controller interface (2 days, 50%)
- [ ] controller manager structure (2 days)
- [ ] controller manager runtime (2 days)
- [ ] controller business logic (1 day)
- [ ] CAN MCU driver library (4 days)

#### release notes:
- verified that we can have both drivebrain and the data_acq bound to the same CAN device and receiving / talking over it
- due to this, we dont need to have the live telem in the alpha since we will only be using CAN still for this release for all comms

- [x] alpha feature set ((start: 8/19) ~2 weeks, 16 days): -> basic control of car with TCU
- [x] basic controller library (7 days) (first pass I want to try out different types of regen handling)
- [x] live parameter controller interface (2 days, 50%)
- [x] simple controller business logic (1 day)
- [x] basic state estimator that can be sampled and manages state (2 days)
- [x] create the state estimation system that can hold multiple state estimators (2 days)
- [x] create a state of the car that can be updated by each of the drivers (1 day)
- [x] integrate the driver inputs into state estimator for creating a shared state (2 days)
- [x] CAN MCU driver library (4 days)
- [x] DBC based parsing
- [ ] async receiving and transmitting with Boost.Asio (2 days)
- [ ] protobuf message packing (2 days, 50% done, 1 day left)
- [ ] simple internal communication with basic controller (1 day)
- [ ] application runtime (1 day)
- [ ] live telem integration with foxglove websocket (1 day)
- [ ] foxglove live parameter server and websocket integration (1 day)

beta feature set (1 week):
- [ ] vectornav UART driver integration
- [ ] CASE integrated into controller manager with existing integration methods (1 day)
- [ ] driver bus with UDP port comms to data acq

v1 feature set (1 week):
- [ ] CASE protobuf status output over UDP
- [ ] basic controller integrated
- [ ] live param interface working fully integrated with foxglove websocket comms
- [x] async receiving and transmitting with Boost.Asio (2 days)
- [x] protobuf message packing (2 days)
- [x] simple internal communication with basic controller (1 day)
- [x] application runtime (1 day)
- [x] foxglove live parameter server and websocket integration (1 day)

beta feature set (4 weeks): -> existing controller on TCU with telemetry and recording

(WEEK 1):
- [ ] improve protobuf generation from DBC by supporting enums properly (1 day)
- tied to making the DBC parser also able to handle enums
- [ ] CAN driver improvements (1 day)
- [ ] make the DBC parser also be able to handle enums
- [ ] controller manager implementation (4 days)
- [ ] be able to switch between controllers in a safe manor while driving (2 days, 50% done)
- [ ] hook into the grpc server through some method for handling the switch (2 days)
- [ ] grpc server interface for switching between controllers (1 day)

(WEEK 2)
- [ ] vectornav UART driver integration that adds new messages to the message bus (1 week)

(WEEK 3):
- [ ] implement MCAP recording of all messages between components (1 week)
- [ ] implement MCAP recording componenet (3 days)
- [ ] driver inputs into state estimator (1 day)
- [ ] state estimation output (1 day)
- [ ] controller output to the car (1 day)

(WEEK 4):
- [ ] add CASE to controllers available to switch to (3 days)
- [ ] implement live telemetry of all messages (4 days)
- [ ] add to the foxglove server interface the ability to live output protobuf messages (2 days)
- [ ] hookup all components (2 days)

v1 feature set (3 weeks): ->
- [ ] LQR based controller integrated onto car for torque vectoring (2 weeks)
- [ ] luke's models integrated into state estimator (1 week)

v1.1 feature set (): -> ht09-capable
- [ ] be able

### TODOs
- [ ] make a controller manager for switching between controllers
Expand Down
16 changes: 16 additions & 0 deletions config/example_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"CANDriver": {
"canbus_device": "vcan0",
"path_to_dbc": "../config/test_config/hytech.dbc"
},
"SimpleController": {
"max_torque": 22.4,
"max_regen_torque": 10.0,
"rear_torque_scale": 1.0,
"regen_torque_scale": 0.6,
"positive_speed_set": 10.0
},
"StateEstimator": {
"threshold_microseconds": 30000
}
}
6 changes: 4 additions & 2 deletions config/test_config/can_driver.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@

{
"CANDriver": {
"canbus_device": "vcan0",
"path_to_dbc": "config/test_config/hytech.dbc"
},
"SimpleController": {
"max_torque": 22.4,
"max_regen_torque": 10.0

"max_regen_torque": 10.0,
"rear_torque_scale": 1.0,
"regen_torque_scale": 0.6
}
}
4 changes: 2 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{ pkgs, stdenv, cmake, boost, pkg-config, protobuf, nlohmann_json, foxglove-ws-protocol-cpp, cmake_macros, foxglove-schemas_proto_cpp, drivebrain_core_msgs_proto_cpp, hytech_np_proto_cpp, dbcppp, gtest, ... }:
{ pkgs, stdenv, cmake, boost, pkg-config, protobuf, nlohmann_json, foxglove-ws-protocol-cpp, cmake_macros, hytech_np_proto_cpp, dbcppp, gtest, ... }:

stdenv.mkDerivation {
name = "drivebrain_software";
src = ./.;
nativeBuildInputs = [ cmake ];
propagatedBuildInputs = [ protobuf boost cmake_macros nlohmann_json foxglove-ws-protocol-cpp foxglove-schemas_proto_cpp drivebrain_core_msgs_proto_cpp hytech_np_proto_cpp dbcppp gtest ];
propagatedBuildInputs = [ protobuf boost cmake_macros nlohmann_json foxglove-ws-protocol-cpp hytech_np_proto_cpp dbcppp gtest ];
}
Loading