Skip to content

Commit

Permalink
Updated to actually reduce tq command
Browse files Browse the repository at this point in the history
  • Loading branch information
jstri114 committed May 31, 2024
1 parent 9db262e commit 37bb00d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions include/torque_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ class torque_controllerPID : public torque_controller
class torque_controllerSlipTime : public torque_controller
{
private:
const double tireSlipHigh = 0.05; // Slip threshold
const double tireSlipHigh = 0.15; // Slip threshold
unsigned long _lastSlip = 0; // Time slip began
unsigned long slip_dT = 0; // Time delta since slip first began
double slipTime = 0; // Slip * time, the x axis
bool slipActive = false; // Flag to indicate if slip is active
static const int numPoints = 6; // Number of data points
double yTorqueRTD[numPoints] = {10, 20, 30, 50, 80, 160}; // TQ in Nm to reduce the output by
double xSlipTime[numPoints] = {50, 100, 200, 400, 600, 1000}; // SlipTime, is % slip * time (ms)
double yTorqueRTD[numPoints] = {20, 30, 40, 50, 80, 120}; // TQ in Nm to reduce the output by
double xSlipTime[numPoints] = {100, 200, 300, 500, 750, 1000}; // SlipTime, is % slip * time (ms)
double slopes[numPoints]; // Slopes at each point for interpolation
double outputTorqueRTD = 0; // Torque Retard due to controller
public:
Expand Down
2 changes: 1 addition & 1 deletion src/torque_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ int16_t torque_controllerSlipTime::calculate_torque(unsigned long elapsedTime, i
}

// Limit torque outputs like normal
torqueOut = outputTorqueRTD * 10; // times 10 because your input is coming from the output of calculate_torque based on the APPS which is Nmx10
torqueOut = driverTorqueRequest - (outputTorqueRTD * 10); // times 10 because your input is coming from the output of calculate_torque based on the APPS which is Nmx10, and subtracts the amount of torque you want to remove from the driver's request
lcTorqueRequest = static_cast<int16_t>(torqueOut); // Pre clamping
if (torqueOut > maxTorque)
{
Expand Down

0 comments on commit 37bb00d

Please sign in to comment.