Skip to content

Commit 344d223

Browse files
committed
FIX A BUNCH OF BUGS FROM EV ACTIVE
1 parent 0b4e9a0 commit 344d223

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

ETC/src/can_wrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void CANWrapper::processCANRx() {
130130
switch (rx.id) {
131131
case 0x188: // ACC_TPDO_STATUS
132132
ETCState state = this->etc.getState();
133-
state.ts_ready = rx.data[0] & 0x08;
133+
state.ts_ready = rx.data[0] & 0b00001000;
134134
this->etc.updateStateFromCAN(state);
135135
if (!this->etc.getState().ts_ready) {
136136
this->etc.turnOffMotor();

ETC/src/etc_controller.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@ void ETCController::updateState() {
4949
// two sensors differs by too much, or the voltages of either sensor is out of range (less
5050
// than 0% or more than 100% pedal travel).
5151

52-
float travelDifference = std::fabs(he1Travel - he2Travel);
52+
float travelDifference = std::abs(he1Travel - he2Travel);
5353
if (travelDifference > 0.1f) {
5454
if (!this->implausTravelTimerRunning) {
5555
// we now start our timer, if it's not already running
5656
this->implausTravelTimer.start();
5757
this->implausTravelTimerRunning = true;
5858
}
59-
else if (this->implausTravelTimer.elapsed_time() > 100ms) {
60-
this->implausTravelTimer.stop();
61-
this->implausTravelTimer.reset();
62-
this->implausTravelTimerRunning = false;
63-
this->turnOffMotor();
64-
}
59+
// else if (this->implausTravelTimer.elapsed_time() > 100ms) {
60+
// this->implausTravelTimer.stop();
61+
// this->implausTravelTimer.reset();
62+
// this->implausTravelTimerRunning = false;
63+
// this->turnOffMotor();
64+
// }
6565
}
6666
else {
6767
// if everything is good and timer is running, we reset
@@ -70,20 +70,20 @@ void ETCController::updateState() {
7070
this->implausTravelTimerRunning = false;
7171
}
7272

73-
if (he1Voltage <= 0.05f || he1Voltage >= ETCController::MAX_VOLTAGE ||
74-
he2Voltage <= 0.05f || he2Voltage >= ETCController::MAX_VOLTAGE)
73+
if (he1Voltage <= 0.2f || he1Voltage >= 3.0f ||
74+
he2Voltage <= 0.2f || he2Voltage >= 3.0f)
7575
{
7676
if (!this->implausBoundsTimerRunning) {
7777
// we now start our timer, if it's not already running
7878
this->implausBoundsTimer.start();
7979
this->implausBoundsTimerRunning = true;
8080
}
81-
else if (this->implausBoundsTimer.elapsed_time() > 100ms) {
82-
this->implausBoundsTimer.stop();
83-
this->implausBoundsTimer.reset();
84-
this->implausBoundsTimerRunning = false;
85-
this->turnOffMotor();
86-
}
81+
// else if (this->implausBoundsTimer.elapsed_time() > 100ms) {
82+
// this->implausBoundsTimer.stop();
83+
// this->implausBoundsTimer.reset();
84+
// this->implausBoundsTimerRunning = false;
85+
// this->turnOffMotor();
86+
// }
8787
}
8888
else {
8989
this->implausBoundsTimer.stop();
@@ -105,7 +105,7 @@ void ETCController::updateState() {
105105
this->state.he1_travel = he1Travel;
106106
this->state.he2_travel = he2Travel;
107107
this->state.torque_demand =
108-
(this->state.motor_enabled && !this->state.brakes_implausibility) ?
108+
(this->state.motor_enabled && (!this->state.brakes_implausibility && !this->hasImplausibility())) ?
109109
static_cast<int16_t>(pedalTravel * ETCController::MAX_TORQUE) :
110110
0;
111111

@@ -274,5 +274,7 @@ bool ETCController::isBraking() {
274274

275275

276276
bool ETCController::hasImplausibility() {
277-
return this->implausTravelTimerRunning || this->implausBoundsTimerRunning;
277+
// return this->implausTravelTimerRunning || this->implausBoundsTimerRunning;
278+
return this->implausTravelTimer.elapsed_time() >= 100ms
279+
|| this->implausBoundsTimer.elapsed_time() >= 100ms;
278280
}

ETC/src/etc_controller.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ETCController {
6767

6868
/** Timer for implausibility via HE sensor travel percent mismatch. */
6969
Timer implausTravelTimer;
70-
/** Whether the implausibility travel percent mismatch timer is active. */
70+
/** Whether the implausibility travel percent mismatch timer is active. */
7171
bool implausTravelTimerRunning;
7272
/** Timer for implausibility via HE sensor invalid voltages. */
7373
Timer implausBoundsTimer;
@@ -92,8 +92,8 @@ class ETCController {
9292
static constexpr float MAX_VOLTAGE = 3.3f;
9393

9494
/** The percentage tolerance for the brake pedal to be considered pressed. */
95-
static constexpr float BRAKE_TOLERANCE_HIGH = 0.38f;
96-
static constexpr float BRAKE_TOLERANCE_LOW = 0.25f;
95+
static constexpr float BRAKE_TOLERANCE_HIGH = 0.42f;
96+
static constexpr float BRAKE_TOLERANCE_LOW = 0.36f;
9797

9898
/** The voltage divider slope for the hall-effect 1 sensor. */
9999
static constexpr float HE1_SCALE = (330.0f / 480.0f);

0 commit comments

Comments
 (0)