From 53d653ad859d2271e40ac2cef500c2549146b0df Mon Sep 17 00:00:00 2001 From: Ben Hall Date: Sat, 21 Sep 2024 11:38:44 -0400 Subject: [PATCH] making the veh_vec constuctor actually a constructor --- lib/interfaces/include/HytechCANInterface.h | 1 - lib/interfaces/include/LoadCellInterface.h | 13 +++++--- lib/interfaces/src/DrivebrainETHInterface.cpp | 8 ++--- lib/shared_data/include/Utility.h | 30 ++++++++++--------- src/main.cpp | 1 - 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/lib/interfaces/include/HytechCANInterface.h b/lib/interfaces/include/HytechCANInterface.h index 8f3b4c7e2..b2c2249fa 100644 --- a/lib/interfaces/include/HytechCANInterface.h +++ b/lib/interfaces/include/HytechCANInterface.h @@ -14,7 +14,6 @@ #include "VectornavInterface.h" #include "HT08_CASE_types.h" #include "MessageQueueDefine.h" -#include "DrivebrainInterface.h" /* struct holding interfaces processed by process_ring_buffer() FL = MC1 diff --git a/lib/interfaces/include/LoadCellInterface.h b/lib/interfaces/include/LoadCellInterface.h index 7d5dc4d0c..f0e260f36 100644 --- a/lib/interfaces/include/LoadCellInterface.h +++ b/lib/interfaces/include/LoadCellInterface.h @@ -19,6 +19,14 @@ struct LoadCellInterfaceTick_s class LoadCellInterface { +public: + LoadCellInterface() { + loadCellConversions_ = veh_vec(); + loadCellForcesUnfiltered_ = veh_vec(); + loadCellForcesFiltered_ = veh_vec(); + } + void tick(const LoadCellInterfaceTick_s &intake); + LoadCellInterfaceOutput_s getLoadCellForces(); private: /* FIR filter designed with @@ -50,10 +58,7 @@ class LoadCellInterface veh_vec loadCellForcesUnfiltered_; veh_vec loadCellForcesFiltered_; bool FIRSaturated_ = false; -public: - LoadCellInterface() {} - void tick(const LoadCellInterfaceTick_s &intake); - LoadCellInterfaceOutput_s getLoadCellForces(); + }; #endif \ No newline at end of file diff --git a/lib/interfaces/src/DrivebrainETHInterface.cpp b/lib/interfaces/src/DrivebrainETHInterface.cpp index 4e1f90c66..ef092d2c5 100644 --- a/lib/interfaces/src/DrivebrainETHInterface.cpp +++ b/lib/interfaces/src/DrivebrainETHInterface.cpp @@ -16,13 +16,9 @@ hytech_msgs_MCUOutputData DrivebrainETHInterface::make_db_msg(const SharedCarSta void DrivebrainETHInterface::receive_pb_msg(const hytech_msgs_MCUCommandData &msg_in, unsigned long curr_millis) { - // Serial.println("msg recvd in here"); - veh_vec nm_lim; - nm_lim.construct(msg_in.torque_limit_nm.FL, msg_in.torque_limit_nm.FR, msg_in.torque_limit_nm.RL, msg_in.torque_limit_nm.RR); + veh_vec nm_lim(msg_in.torque_limit_nm.FL, msg_in.torque_limit_nm.FR, msg_in.torque_limit_nm.RL, msg_in.torque_limit_nm.RR); - veh_vec speed_set; - speed_set.construct(msg_in.desired_rpms.FL, msg_in.desired_rpms.FR, msg_in.desired_rpms.RL, msg_in.desired_rpms.RR); - // Serial.println(msg_in.desired_rpms.FL); + veh_vec speed_set(msg_in.desired_rpms.FL, msg_in.desired_rpms.FR, msg_in.desired_rpms.RL, msg_in.desired_rpms.RR); _latest_data.torque_limits_nm = nm_lim; _latest_data.speed_setpoints_rpm = speed_set; diff --git a/lib/shared_data/include/Utility.h b/lib/shared_data/include/Utility.h index 66d0f2cb5..d528a73f6 100644 --- a/lib/shared_data/include/Utility.h +++ b/lib/shared_data/include/Utility.h @@ -3,11 +3,11 @@ #include "PhysicalParameters.h" #include // Defines -const int FL = 0; -const int FR = 1; -const int RL = 2; -const int RR = 3; -const int NUM_MOTORS = 4; +const int FL = 0; +const int FR = 1; +const int RL = 2; +const int RR = 3; +const int NUM_MOTORS = 4; const int DEBOUNCE_MILLIS = 10; // milliseconds before registering another button press @@ -15,28 +15,30 @@ const int DEBOUNCE_MILLIS = 10; // milliseconds before registering another butto template struct veh_vec { +public: T FL; T FR; T RL; T RR; - void construct(T _FL, T _FR, T _RL, T _RR) +public: + veh_vec() = default; + veh_vec(T _FL, T _FR, T _RL, T _RR) { FL = _FL; FR = _FR; RL = _RL; RR = _RR; } - - /// @brief copy values to array in FL, FR, RL, RR order - void copy_to_arr(T(&arr_out)[4]) + + /// @brief copy values to array in FL, FR, RL, RR order + void copy_to_arr(T (&arr_out)[4]) { - arr_out[0]=FL; - arr_out[1]=FR; - arr_out[2]=RL; - arr_out[3]=RR; + arr_out[0] = FL; + arr_out[1] = FR; + arr_out[2] = RL; + arr_out[3] = RR; } - }; template diff --git a/src/main.cpp b/src/main.cpp index 2f95dd72d..97dff3083 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,7 +24,6 @@ #include "SABInterface.h" #include "VectornavInterface.h" #include "LoadCellInterface.h" -#include "DrivebrainInterface.h" #include "TorqueControllers.h" /* Systems */