Skip to content

Commit

Permalink
data flow in superloop. test_env c/g++ versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dopp-IO committed Feb 8, 2024
1 parent 47f2fa2 commit 0c049df
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
2 changes: 2 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ test_framework = googletest
build_src_filter =
-<**/*.c>
-<**/*.cpp>
build_unflags = -std=gnu++11
build_flags = -std=c++17
lib_ignore =
interfaces-lib

Expand Down
40 changes: 29 additions & 11 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ InverterInterfaceType rr_inv(&CAN2_txBuffer, ID_MC4_SETPOINTS_COMMAND, 9, 8);
SysClock sys_clock;
BuzzerController buzzer(BUZZER_ON_INTERVAL);
SafetySystem safety_system(&ams_interface, &wd_interface); // Tie ams and wd interface to safety system (by pointers)
PedalsSystem pedals({100, 100, 3000, 3000, 0.1}, {100, 100, 3000, 3000, 0.05});
PedalsSystem pedals_system({100, 100, 3000, 3000, 0.1}, {100, 100, 3000, 3000, 0.05});
SteeringSystem steering_system(&steering1); // Unify member reference and pointers? tied by reference in this case
using DrivetrainSystemType = DrivetrainSystem<InverterInterfaceType>;
auto drivetrain = DrivetrainSystemType({&fl_inv, &fr_inv, &rl_inv, &rr_inv}, INVERTER_ENABLING_TIMEOUT_INTERVAL); // Tie inverter interfaces to drivetrain system (by pointers)
Expand All @@ -73,7 +73,7 @@ auto drivetrain = DrivetrainSystemType({&fl_inv, &fr_inv, &rl_inv, &rr_inv}, INV
TorqueControllerSimple launch_control_mode;
TorqueControllerSimple torque_vectoring_mode;
*/
TorqueControllerMux torque_controller_mux; // would prob need to tie controllers to mux as well?
TorqueControllerMux torque_controller_mux;


/* Declare state machine */
Expand All @@ -89,8 +89,8 @@ SysTick_s curr_tick;
void update_and_enqueue_all_CAN();
/* External value readings */
void sample_all_external_readings();
/* Process all readings */
void process_all_value_readings();
/* Tick all systems */
void tick_all_systems();

void setup() {

Expand Down Expand Up @@ -125,7 +125,7 @@ void loop() {
sample_all_external_readings();

/* System process readings prior to ticking state machine */
process_all_value_readings();
tick_all_systems();

/* Update and enqueue CAN messages */
update_and_enqueue_all_CAN();
Expand Down Expand Up @@ -195,11 +195,29 @@ void sample_all_external_readings() {
main_ecu.read_mcu_status();
}

void process_all_value_readings() {
pedals.tick(curr_tick,
ADC1.get().conversions[MCU15_ACCEL1_CHANNEL],
ADC1.get().conversions[MCU15_ACCEL2_CHANNEL],
ADC1.get().conversions[MCU15_BRAKE1_CHANNEL],
ADC1.get().conversions[MCU15_BRAKE2_CHANNEL]);
void tick_all_systems() {
pedals_system.tick(
curr_tick,
ADC1.get().conversions[MCU15_ACCEL1_CHANNEL],
ADC1.get().conversions[MCU15_ACCEL2_CHANNEL],
ADC1.get().conversions[MCU15_BRAKE1_CHANNEL],
ADC1.get().conversions[MCU15_BRAKE2_CHANNEL]
);
steering_system.tick(
curr_tick,
ADC1.get().conversions[MCU15_STEERING_CHANNEL]
);
torque_controller_mux.tick(
curr_tick,
(const DrivetrainDynamicReport_s) {}, // TODO: get drivetrain dynamic data
pedals_system.getPedalsSystemData(),
steering_system.getSteeringSystemData(),
ADC2.get().conversions[0], // FL load cell reading. TODO: fix index
ADC3.get().conversions[0], // FR load cell reading. TODO: fix index
(const AnalogConversion_s) {}, // RL load cell reading. TODO: get data from rear load cells
(const AnalogConversion_s) {}, // RR load cell reading. TODO: get data from rear load cells
dashboard.getDialMode(),
dashboard.torqueButtonPressed()
);
}

0 comments on commit 0c049df

Please sign in to comment.