Skip to content

Commit ccea63d

Browse files
committed
ETC brake implausibility check
1 parent 1aaf7c4 commit ccea63d

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

ETC/src/etc_controller.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,19 @@ void ETCController::updateState() {
9090
// can then update the state information related to pedal travel.
9191

9292
float pedalTravel = (he1Travel + he2Travel) / 2.0f;
93+
this->state.pedal_travel = pedalTravel;
94+
this->state.brakes_read = this->brakePedalInput.read() * ETCController::MAX_VOLTAGE;
95+
96+
this->set_brake_implausibility();
9397

9498
this->state.he1_read = this->he1Input.read() * ETCController::MAX_VOLTAGE;
9599
this->state.he2_read = this->he2Input.read() * ETCController::MAX_VOLTAGE;
96100
this->state.he1_travel = he1Travel;
97101
this->state.he2_travel = he2Travel;
98-
this->state.pedal_travel = pedalTravel;
99102
this->state.torque_demand =
100-
this->state.motor_enabled ?
103+
(this->state.motor_enabled && !this->state.brakes_implausibility) ?
101104
static_cast<int16_t>(pedalTravel * ETCController::MAX_TORQUE) :
102105
0;
103-
this->state.brakes_read = this->brakePedalInput.read() * ETCController::MAX_VOLTAGE;
104106

105107
this->brakeLightOutput.write(this->state.brakes_read >= ETCController::BRAKE_TOLERANCE);
106108
}
@@ -121,7 +123,7 @@ void ETCController::checkStartConditions() {
121123
// If the brake is pressed past the tolerance threshold and the tractive system is ready
122124
// then the motor can be enabled. The last condition for motor start is the cockpit switch
123125
// being set to the ON position, which is what calls this method.
124-
if(this->state.ts_ready && this->state.brakes_read >= ETCController::BRAKE_TOLERANCE && this->state.pedal_travel <= 0.01) {
126+
if(this->state.ts_ready && this->state.brakes_read >= ETCController::BRAKE_TOLERANCE && this->state.pedal_travel < 0.05) {
125127
this->state.motor_enabled = true;
126128
this->runRTDS();
127129
}
@@ -153,8 +155,20 @@ void ETCController::resetState() {
153155
this->state.motor_forward = true;
154156
this->state.cockpit = false;
155157
this->state.torque_demand = 0;
158+
this->state.brakes_implausibility = false;
156159
}
157160

161+
void ETCController::set_brake_implausibility() {
162+
if (this->state.brakes_implausibility) {
163+
if (this->state.pedal_travel < 0.05f) {
164+
this->state.brakes_implausibility = false;
165+
}
166+
} else {
167+
if (this->state.brakes_read >= BRAKE_TOLERANCE && this->state.pedal_travel > 0.25f) {
168+
this->state.brakes_implausibility = true;
169+
}
170+
}
171+
}
158172

159173
ETCState ETCController::getState() const {
160174
return this->state;

ETC/src/etc_controller.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct ETCState {
4242
bool motor_forward;
4343
bool cockpit;
4444
int16_t torque_demand;
45+
bool brakes_implausibility;
4546
};
4647

4748

@@ -177,6 +178,10 @@ class ETCController {
177178
*/
178179
ETCState getState() const;
179180

181+
/**
182+
* sets brakes implausibility
183+
*/
184+
void set_brake_implausibility();
180185

181186
/**
182187
* Returns {@code state.mbb_alive}.

0 commit comments

Comments
 (0)