-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into tc_mux_testing
- Loading branch information
Showing
44 changed files
with
683 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef __DRIVEBRAINETHINTERFACE_H__ | ||
#define __DRIVEBRAINETHINTERFACE_H__ | ||
#include "hytech_msgs.pb.h" | ||
#include "DrivebrainData.h" | ||
#include "SharedDataTypes.h" | ||
class DrivebrainETHInterface | ||
{ | ||
public: | ||
DrivebrainETHInterface(){ | ||
_latest_data.last_receive_time_millis = -1; | ||
_latest_data.DB_prev_MCU_recv_millis = -1; | ||
}; | ||
|
||
void receive_pb_msg(const hytech_msgs_MCUCommandData &msg_in, unsigned long curr_millis); | ||
|
||
hytech_msgs_MCUOutputData make_db_msg(const SharedCarState_s &shared_state); | ||
DrivebrainData_s get_latest_data() { return _latest_data; } | ||
|
||
private: | ||
|
||
DrivebrainData_s _latest_data = {}; | ||
}; | ||
|
||
#endif // __DRIVEBRAINETHINTERFACE_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "DrivebrainETHInterface.h" | ||
#include "SharedDataTypes.h" | ||
#include <Arduino.h> | ||
|
||
hytech_msgs_MCUOutputData DrivebrainETHInterface::make_db_msg(const SharedCarState_s &shared_state) | ||
{ | ||
hytech_msgs_MCUOutputData out; | ||
out.accel_percent = shared_state.pedals_data.accelPercent; | ||
out.brake_percent = shared_state.pedals_data.brakePercent; | ||
|
||
out.has_rpm_data = true; | ||
out.rpm_data.FL = shared_state.drivetrain_data.measuredSpeeds[0]; | ||
out.rpm_data.FR = shared_state.drivetrain_data.measuredSpeeds[1]; | ||
out.rpm_data.RL = shared_state.drivetrain_data.measuredSpeeds[2]; | ||
out.rpm_data.RR = shared_state.drivetrain_data.measuredSpeeds[3]; | ||
|
||
out.steering_angle_deg = shared_state.steering_data.angle; | ||
out.MCU_recv_millis = _latest_data.last_receive_time_millis; | ||
out.load_cell_data = {shared_state.raw_loadcell_data.raw_load_cell_data.FL, | ||
shared_state.raw_loadcell_data.raw_load_cell_data.FR, | ||
shared_state.raw_loadcell_data.raw_load_cell_data.RL, | ||
shared_state.raw_loadcell_data.raw_load_cell_data.RR}; | ||
out.has_load_cell_data = true; | ||
return out; | ||
} | ||
|
||
void DrivebrainETHInterface::receive_pb_msg(const hytech_msgs_MCUCommandData &msg_in, unsigned long curr_millis) | ||
{ | ||
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(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; | ||
_latest_data.DB_prev_MCU_recv_millis = msg_in.prev_MCU_recv_millis; | ||
_latest_data.last_receive_time_millis = curr_millis; // current tick millis | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#ifndef __DRIVEBRAININTERFACE_H__ | ||
#define __DRIVEBRAININTERFACE_H__ | ||
|
||
|
||
#endif // __DRIVEBRAININTERFACE_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef __DRIVEBRAINDATA_H__ | ||
#define __DRIVEBRAINDATA_H__ | ||
|
||
#include "Utility.h" | ||
|
||
struct DrivebrainData_s | ||
{ | ||
/// @brief the latest time that the MCU received a message w.r.t the current tick's millis | ||
int64_t last_receive_time_millis = -1; | ||
/// @brief the latest MCU last_receive_time_millis that the drivebrain received | ||
int64_t DB_prev_MCU_recv_millis = -1; | ||
veh_vec<float> torque_limits_nm; | ||
veh_vec<float> speed_setpoints_rpm; | ||
}; | ||
|
||
#endif // __DRIVEBRAINDATA_H__ |
Oops, something went wrong.