Skip to content

Commit

Permalink
making the veh_vec constuctor actually a constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
RCMast3r committed Sep 21, 2024
1 parent c61ec58 commit 53d653a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 26 deletions.
1 change: 0 additions & 1 deletion lib/interfaces/include/HytechCANInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions lib/interfaces/include/LoadCellInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ struct LoadCellInterfaceTick_s

class LoadCellInterface
{
public:
LoadCellInterface() {
loadCellConversions_ = veh_vec<AnalogConversion_s>();
loadCellForcesUnfiltered_ = veh_vec<float[numFIRTaps_]>();
loadCellForcesFiltered_ = veh_vec<float>();
}
void tick(const LoadCellInterfaceTick_s &intake);
LoadCellInterfaceOutput_s getLoadCellForces();
private:
/*
FIR filter designed with
Expand Down Expand Up @@ -50,10 +58,7 @@ class LoadCellInterface
veh_vec<float[numFIRTaps_]> loadCellForcesUnfiltered_;
veh_vec<float> loadCellForcesFiltered_;
bool FIRSaturated_ = false;
public:
LoadCellInterface() {}
void tick(const LoadCellInterfaceTick_s &intake);
LoadCellInterfaceOutput_s getLoadCellForces();

};

#endif
8 changes: 2 additions & 6 deletions lib/interfaces/src/DrivebrainETHInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float> 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<float> 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<float> 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<float> 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;
Expand Down
30 changes: 16 additions & 14 deletions lib/shared_data/include/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,42 @@
#include "PhysicalParameters.h"
#include <array>
// 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

/// @brief generic data vector type that can be used with tire and / or anything to do with 4 corners of the car.
template <typename T>
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 <typename T>
Expand Down
1 change: 0 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "SABInterface.h"
#include "VectornavInterface.h"
#include "LoadCellInterface.h"
#include "DrivebrainInterface.h"
#include "TorqueControllers.h"

/* Systems */
Expand Down

0 comments on commit 53d653a

Please sign in to comment.