MCU
Loading...
Searching...
No Matches
DrivebrainETHInterface.cpp
Go to the documentation of this file.
2#include "SharedDataTypes.h"
3#include <Arduino.h>
4
5hytech_msgs_MCUOutputData DrivebrainETHInterface::make_db_msg(const SharedCarState_s &shared_state)
6{
7 hytech_msgs_MCUOutputData out;
8 out.accel_percent = shared_state.pedals_data.accelPercent;
9 out.brake_percent = shared_state.pedals_data.regenPercent;
10
11 out.has_rpm_data = true;
12 out.rpm_data.FL = shared_state.drivetrain_data.measuredSpeeds[0];
13 out.rpm_data.FR = shared_state.drivetrain_data.measuredSpeeds[1];
14 out.rpm_data.RL = shared_state.drivetrain_data.measuredSpeeds[2];
15 out.rpm_data.RR = shared_state.drivetrain_data.measuredSpeeds[3];
16 out.steering_angle_deg = shared_state.steering_data.angle;
17 out.MCU_recv_millis = _latest_data.last_receive_time_millis;
18 out.load_cell_data = {shared_state.raw_loadcell_data.raw_load_cell_data.FL,
22 out.has_load_cell_data = true;
23
24 out.timing_failure_active = shared_state.drivebrain_timing_failure;
25 return out;
26}
27
28void DrivebrainETHInterface::receive_pb_msg(const hytech_msgs_MCUCommandData &msg_in, unsigned long curr_millis)
29{
30 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);
31 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);
34 _latest_data.DB_prev_MCU_recv_millis = msg_in.prev_MCU_recv_millis;
35 _latest_data.last_receive_time_millis = curr_millis; // current tick millis
36}
hytech_msgs_MCUOutputData make_db_msg(const SharedCarState_s &shared_state)
void receive_pb_msg(const hytech_msgs_MCUCommandData &msg_in, unsigned long curr_millis)
int64_t last_receive_time_millis
the latest time that the MCU received a message w.r.t the current tick's millis
Definition: DrivebrainData.h:9
int64_t DB_prev_MCU_recv_millis
the latest MCU last_receive_time_millis that the drivebrain received
veh_vec< float > speed_setpoints_rpm
veh_vec< float > torque_limits_nm
speed_rpm measuredSpeeds[NUM_MOTORS]
car state struct that contains state of everything about the car including
SteeringSystemData_s steering_data
PedalsSystemData_s pedals_data
DrivetrainDynamicReport_s drivetrain_data
LoadCellInterfaceRawOutput_s raw_loadcell_data
generic data vector type that can be used with tire and / or anything to do with 4 corners of the car...
Definition: Utility.h:17
T FL
Definition: Utility.h:19
T RL
Definition: Utility.h:21
T RR
Definition: Utility.h:22
T FR
Definition: Utility.h:20