-
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.
Feature/drivebrain integration (#105)
* tuning pedals and updated to latest can definition * drivebrain controller creation * added receiving of drivebrain messages * fixing pedals tests * adding drivebrain interface empty mock header * feat(drivebrain_controller): added tests for drivebrain controller latency and jitter * adding in latching logic for the db controller * added in drivebrain interface into main * ensuring that the regen and torque limits dont get applied to the drivebrain controller * fix(drivebrain_controller): fixed drivebrain_controller failure and reset logic * adjusting logic; removing interaction with tc and giving drivebrain more responsbility * fixing oopsie in drivebrain control mode and adding it to main * ready to test on car * fixing header * seemingly working ethernet integration * switching ethernet driver * removing CAN based drivebrain interface, addressing naming for inverter interface updates, updating ethernet interface since only one message is received, and fixing tests for new interface * making the veh_vec constuctor actually a constructor * addressing comments * a little cleanup * added compiler macro flag for debug prints * added in type alias * adding in better handling of timing for drivebrain message latency * updated to latest HT-prot * updating pedal params and to latest HT_proto --------- Co-authored-by: sreekara <[email protected]>
- Loading branch information
Showing
29 changed files
with
458 additions
and
198 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,31 @@ | ||
#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.rpm_data = {shared_state.drivetrain_data.measuredSpeeds[0], | ||
shared_state.drivetrain_data.measuredSpeeds[1], | ||
shared_state.drivetrain_data.measuredSpeeds[2], | ||
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; | ||
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
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.