Skip to content

Commit

Permalink
User/freerb/fc (#127)
Browse files Browse the repository at this point in the history
* bringup frontcontroller bindings to rvalue-reference style

* fix: 🐛 Fix OS compiler errors.

675f0d0 introduced a breaking change for the TMS and DemoProjectRTOS by removing the CMake commands which compiled and linked the freertos code, as well as added an unnecessary include (sys/types.h) to mcal/stm/os/tick.h (this is likely clangd's fault). This commit restores these files so that the projects can compile again.

* feat: Add Tasks to FrontController.

Creates a 5 and 500 ms task in FrontController using freertos. Provides a framework for Sam and Blake to develop the actual code off of.

* updates moing avg class to be more robust against large values and adds a moving average to the pedal class

* adds docs from electrical team for pedal position

* finishes simulink input, besides reading CAN messages

* adds all outputs from simulink, uses placeholders where I didn't know what to fill in

* Update control system to latest

* Add enums to cangen

* Add ability to do 2 can busses with cangen

* Removes duplicate include in app, unnecessary include in main

* updates ioc to match 'ENG-Electrical/MACEV5/Low Voltage/Pin Mapping' as of time of commit

* adds bindings for all IO pins, though not all have an app-level object yet

* Update yamls

* Fix build for lvcontroller

* Remove clangd include

* remvoes amps, not building

* converts to & from &&

* update to 6.11.1

* fixes type conversion warnings in jinja, converts bms cmd to bool

* adds front controller simple

* checkouts out mfang simple branch

* disables unused IO for simple model

* fc

* uses different autogen and staticcast bool

* sends inverter

* fixes clang-format issue

---------

Co-authored-by: BlakeFreer <[email protected]>
  • Loading branch information
samparent97 and BlakeFreer authored Jul 16, 2024
1 parent f792862 commit 95fa36d
Show file tree
Hide file tree
Showing 48 changed files with 2,084 additions and 321 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "firmware/third-party/etl"]
path = firmware/third-party/etl
url = https://github.com/ETLCPP/etl.git
[submodule "firmware/projects/FrontControllerSimple/vehicle_control_system"]
path = firmware/projects/FrontControllerSimple/vehicle_control_system
url = https://github.com/macformula/vehicle_control_system.git
2 changes: 0 additions & 2 deletions firmware/dbcs/veh.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ BO_ 777 GnssImu: 8 CANmod
SG_ AngularRateY : 42|11@1+ (0.25,-256) [-256|255.75] "deg/s" FC
SG_ AngularRateZ : 53|11@1+ (0.25,-256) [-256|255.75] "deg/s" FC



CM_ BO_ 3221225472 "This is a message for not used signals, created by Vector CANdb++ DBC OLE DB Provider.";
CM_ BO_ 1572 "This ID Transmits at 8 ms.";
CM_ BO_ 1571 "This ID Transmits at 8 ms.";
Expand Down
2 changes: 0 additions & 2 deletions firmware/mcal/stm32f767/os/tick.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#pragma once

#include <sys/types.h>

#include <cstdint>

#include "cmsis_os2.h"
Expand Down
3 changes: 0 additions & 3 deletions firmware/mcal/stm32f767/periph/can.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

#pragma once

#include <bits/ranges_base.h>
#include <sys/_stdint.h>

#include <cstddef>

#include "shared/comms/can/raw_can_msg.h"
Expand Down
7 changes: 4 additions & 3 deletions firmware/projects/DemoCanBar/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
canGen:
ourNode: bar
busName: veh
dbcFiles:
- "demo.dbc"
busses:
- busName: veh
dbcFiles:
- "demo.dbc"
7 changes: 4 additions & 3 deletions firmware/projects/DemoCanFoo/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
canGen:
ourNode: foo
busName: veh
dbcFiles:
- "demo.dbc"
busses:
- busName: veh
dbcFiles:
- "demo.dbc"
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ add_subdirectory(cubemx)

target_sources(bindings PUBLIC bindings.cc)
target_link_libraries(bindings PUBLIC driver mcal-stm32f767)

add_library(os)
target_sources(os PUBLIC os.cc)
target_link_libraries(os PUBLIC driver mcal-stm32f767)
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ Mcu.PinsNb=5
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F767ZITx
MxCube.Version=6.8.1
MxDb.Version=DB.6.0.81
MxCube.Version=6.11.0
MxDb.Version=DB.6.0.110
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false\:false
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false\:false
NVIC.ForceEnableDMAVector=true
Expand Down Expand Up @@ -94,6 +94,8 @@ ProjectManager.RegisterCallBack=
ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=Makefile
ProjectManager.ToolChainLocation=
ProjectManager.UAScriptAfterPath=
ProjectManager.UAScriptBeforePath=
ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true
RCC.48MHZClocksFreq_Value=24000000
Expand Down
41 changes: 31 additions & 10 deletions firmware/projects/FrontController/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,46 @@
# The target executable 'main' is created in the master CMakeLists. Do not change its name.
# We only need to add the source code files and include directories.

find_package(Python3 COMPONENTS Interpreter)
message(${Python3_EXECUTABLE})

if(NOT ${Python3_FOUND})
message(FATAL_ERROR "Python 3 executable not found")
endif()

FILE(GLOB_RECURSE CAN_DEPENDENCIES CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/../scripts/cangen/*" "${CMAKE_SOURCE_DIR}/dbcs/*")

list(APPEND CAN_DEPENDENCIES "${CMAKE_CURRENT_SOURCE_DIR}/config.yaml")

add_custom_target(
generated_can
COMMAND ${Python3_EXECUTABLE} "${CMAKE_SOURCE_DIR}/../scripts/cangen/main.py" "--project=\"FrontController\""
DEPENDS ${CAN_DEPENDENCIES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT Generating CAN code from DBCs
)

target_sources(main
PRIVATE
PRIVATE
main.cc
)
add_dependencies(main generated_can)

target_include_directories(main
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/inc
${CMAKE_CURRENT_SOURCE_DIR}/generated/can
)

add_library(controls)
# Compile and link the control system files.

target_include_directories(controls
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/vehicle_control_system/src/vehicle_control_system-autogen/controller_autogen_ert_rtw
)
add_library(controls)

FILE(GLOB SRC_CONTROLS CONFIGURE_DEPENDS
"vehicle_control_system/src/vehicle_control_system-autogen/controller_autogen_ert_rtw/*.c"
)
set(CTRL_SYS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vehicle_control_system/src/vehicle_control_system-autogen/controller_autogen_ert_rtw")
target_include_directories(controls PUBLIC ${CTRL_SYS_DIR})

message(STATUS ${SRC_CONTROLS})
FILE(GLOB SRC_CONTROLS CONFIGURE_DEPENDS "${CTRL_SYS_DIR}/*.cpp")
message(STATUS "Controls sources: ${SRC_CONTROLS}")

target_sources(controls
PUBLIC
Expand All @@ -34,6 +52,9 @@ PUBLIC

target_link_libraries(main PUBLIC controls)

# Link ETL which is needed for generated/can/msg_registry.h
add_subdirectory(${CMAKE_SOURCE_DIR}/third-party/etl ${CMAKE_BINARY_DIR}/third-party)
target_link_libraries(main PRIVATE etl)

# Notice that we don't include any mcal/ subdirectory in this CMake file.
# The master CMakeLists handles platform selection and library linking.
9 changes: 9 additions & 0 deletions firmware/projects/FrontController/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
canGen:
ourNode: fc
busses:
- busName: veh
dbcFiles:
- "veh.dbc"
- busName: pt
dbcFiles:
- "pt.dbc"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 95fa36d

Please sign in to comment.