Skip to content

Commit f725a8d

Browse files
committed
Resolve PR comments
1 parent ebea17e commit f725a8d

File tree

5 files changed

+21
-237
lines changed

5 files changed

+21
-237
lines changed

lib/interfaces/include/HytechCANInterface.h

Lines changed: 0 additions & 157 deletions
This file was deleted.

lib/interfaces/include/InverterInterface.h

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <hytech.h>
99
#include "DrivetrainSystem.h"
10+
#include <CANInterface.h>
1011

1112
namespace HTUnits
1213
{
@@ -132,30 +133,25 @@ class InverterInterface
132133

133134
// TODO un-public these (they are public for testing)
134135

135-
/* Recieving callbacks */
136-
void recieve_MCI_STATUS(CAN_message_t &can_msg);
136+
/* receiving callbacks */
137+
void receive_MCI_STATUS(CAN_message_t &can_msg);
137138

138-
void recieve_MCI_TEMPS(CAN_message_t &can_msg);
139+
void receive_MCI_TEMPS(CAN_message_t &can_msg);
139140

140-
void recieve_MCI_DYNAMICS(CAN_message_t &can_msg);
141+
void receive_MCI_DYNAMICS(CAN_message_t &can_msg);
141142

142-
void recieve_MCI_POWER(CAN_message_t &can_msg);
143+
void receive_MCI_POWER(CAN_message_t &can_msg);
143144

144-
void recieve_MCI_FEEDBACK(CAN_message_t &can_msg);
145+
void receive_MCI_FEEDBACK(CAN_message_t &can_msg);
145146

146147
/* Sending */
147-
template <typename U>
148-
void enqueue_new_CAN(U *structure, uint32_t (*pack_function)(U *, uint8_t *, uint8_t *, uint8_t *), uint32_t id);
149-
150148
void send_MC_SETPOINT_COMMAND();
151149

152150
void send_MC_CONTROL_WORD();
153151

154152
/* Inverter Functs */
155153
void set_speed(float desired_rpm, float torque_limit_nm);
156154

157-
void set_torque(float torque_nm);
158-
159155
void set_idle();
160156

161157
void set_inverter_control_word(InverterControlWord_s control_word);

lib/interfaces/src/HyTechCANInterface.cpp

Lines changed: 0 additions & 36 deletions
This file was deleted.

lib/interfaces/src/InverterInterface.cpp

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ InverterControlParams_s InverterInterface::get_control_params() {
3232

3333

3434
/**
35-
* Recieving CAN messages
35+
* receiving CAN messages
3636
*/
3737

38-
void InverterInterface::recieve_MCI_STATUS(CAN_message_t &can_msg)
38+
void InverterInterface::receive_MCI_STATUS(CAN_message_t &can_msg)
3939
{
4040
// Unpack the message
4141
MCI1_STATUS_t unpacked_msg;
4242
Unpack_MCI1_STATUS_hytech(&unpacked_msg, can_msg.buf, can_msg.len);
4343

4444
// Update inverter interface with new data
45-
_feedback_data.status.connected = true; // Will set to true once first CAN message has been recieved
45+
_feedback_data.status.connected = true; // Will set to true once first CAN message has been received
4646
_feedback_data.status.system_ready = unpacked_msg.system_ready;
4747
_feedback_data.status.error = unpacked_msg.error;
4848
_feedback_data.status.warning = unpacked_msg.warning;
49-
_feedback_data. status.quit_dc_on = unpacked_msg.quit_dc_on;
49+
_feedback_data.status.quit_dc_on = unpacked_msg.quit_dc_on;
5050
_feedback_data.status.dc_on = unpacked_msg.dc_on;
5151
_feedback_data.status.quit_inverter_on = unpacked_msg.quit_inverter_on;
5252
_feedback_data.status.derating_on = unpacked_msg.derating_on;
@@ -55,11 +55,9 @@ void InverterInterface::recieve_MCI_STATUS(CAN_message_t &can_msg)
5555
_feedback_data.status.hv_present = _feedback_data.status.dc_bus_voltage > _inverter_params.MINIMUM_HV_VOLTAGE;
5656
}
5757

58-
void InverterInterface::recieve_MCI_TEMPS(CAN_message_t &can_msg)
58+
void InverterInterface::receive_MCI_TEMPS(CAN_message_t &can_msg)
5959
{
6060

61-
Serial.println("Recieved temps data!");
62-
6361
// Unpack the message
6462
MCI1_TEMPS_t unpacked_msg;
6563
Unpack_MCI1_TEMPS_hytech(&unpacked_msg, can_msg.buf, can_msg.len);
@@ -72,7 +70,7 @@ void InverterInterface::recieve_MCI_TEMPS(CAN_message_t &can_msg)
7270

7371
}
7472

75-
void InverterInterface::recieve_MCI_DYNAMICS(CAN_message_t &can_msg)
73+
void InverterInterface::receive_MCI_DYNAMICS(CAN_message_t &can_msg)
7674
{
7775

7876
// Unpack the message
@@ -87,7 +85,7 @@ void InverterInterface::recieve_MCI_DYNAMICS(CAN_message_t &can_msg)
8785

8886
}
8987

90-
void InverterInterface::recieve_MCI_POWER(CAN_message_t &can_msg)
88+
void InverterInterface::receive_MCI_POWER(CAN_message_t &can_msg)
9189
{
9290
// Unpack the message
9391
MCI1_POWER_t unpacked_msg;
@@ -100,7 +98,7 @@ void InverterInterface::recieve_MCI_POWER(CAN_message_t &can_msg)
10098

10199
}
102100

103-
void InverterInterface::recieve_MCI_FEEDBACK(CAN_message_t &can_msg)
101+
void InverterInterface::receive_MCI_FEEDBACK(CAN_message_t &can_msg)
104102
{
105103
// Unpack the message
106104
MCI1_FEEDBACK_t unpacked_msg;
@@ -118,17 +116,6 @@ void InverterInterface::recieve_MCI_FEEDBACK(CAN_message_t &can_msg)
118116
* Sending CAN messages
119117
*/
120118

121-
template <typename U>
122-
void InverterInterface::enqueue_new_CAN(U *structure, uint32_t (*pack_function)(U *, uint8_t *, uint8_t *, uint8_t *), uint32_t id)
123-
{
124-
CAN_message_t can_msg;
125-
pack_function(structure, can_msg.buf, &can_msg.len, (uint8_t *)&can_msg.flags.extended);
126-
can_msg.id = id;
127-
uint8_t buf[sizeof(CAN_message_t)] = {};
128-
memmove(buf, &can_msg, sizeof(CAN_message_t));
129-
msg_queue_->push_back(buf, sizeof(CAN_message_t));
130-
}
131-
132119
void InverterInterface::send_MC_SETPOINT_COMMAND()
133120
{
134121
MC1_SETPOINTS_COMMAND_t msg_out;
@@ -137,7 +124,7 @@ void InverterInterface::send_MC_SETPOINT_COMMAND()
137124
msg_out.positive_torque_limit_ro = _inverter_setpoints.positive_torque_limit;
138125
msg_out.negative_torque_limit_ro = _inverter_setpoints.negative_torque_limit;
139126

140-
enqueue_new_CAN<MC1_SETPOINTS_COMMAND_t>(&msg_out, &Pack_MC1_SETPOINTS_COMMAND_hytech, inverter_ids.mc_setpoint_commands_id);
127+
CAN_util::enqueue_msg<MC1_SETPOINTS_COMMAND_t>(&msg_out, &Pack_MC1_SETPOINTS_COMMAND_hytech, inverter_ids.mc_setpoint_commands_id);
141128
}
142129

143130
void InverterInterface::send_MC_CONTROL_WORD()
@@ -152,15 +139,11 @@ void InverterInterface::send_MC_CONTROL_WORD()
152139
void InverterInterface::set_speed(float desired_rpm, float torque_limit_nm)
153140
{
154141
_inverter_setpoints.speed_rpm_setpoint = desired_rpm;
155-
_inverter_setpoints.positive_torque_limit = torque_limit_nm;
156-
_inverter_setpoints.negative_torque_limit = -torque_limit_nm;
157-
}
158142

159-
void InverterInterface::set_torque(float torque_nm)
160-
{
161-
// TODO set desired rpm to max?
162-
_inverter_setpoints.positive_torque_limit = torque_nm;
163-
_inverter_setpoints.negative_torque_limit = -torque_nm;
143+
float converted_torque = std::abs(torque_limit_nm * (1000/9.8));
144+
145+
_inverter_setpoints.positive_torque_limit = converted_torque;
146+
_inverter_setpoints.negative_torque_limit = -converted_torque;
164147
}
165148

166149
void InverterInterface::set_idle()

platformio.ini

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88

99
lib_deps_shared =
10-
interfaces-lib
1110
https://github.com/hytech-racing/shared_firmware_systems.git#af96a63
1211
https://github.com/hytech-racing/shared_firmware_types.git#9f4f017e5fd2a359d1123df37efef017ed06222e
1312
https://github.com/ssilverman/QNEthernet#v0.26.0
@@ -45,8 +44,7 @@ test_ignore =
4544
lib_deps =
4645
${common.lib_deps_shared}
4746
https://github.com/tonton81/FlexCAN_T4
48-
https://github.com/hytech-racing/shared_firmware_interfaces.git
49-
https://github.com/RCMast3r/hytech_can#testing_new_inv_ids
47+
https://github.com/hytech-racing/shared_firmware_interfaces.git#4d7d617d63720f5fef586f1d95ecd979c1f8a075
5048
https://github.com/hytech-racing/HT_CAN/releases/download/134/can_lib.tar.gz
5149

5250

0 commit comments

Comments
 (0)