@@ -90,17 +90,19 @@ void ETCController::updateState() {
90
90
// can then update the state information related to pedal travel.
91
91
92
92
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 ();
93
97
94
98
this ->state .he1_read = this ->he1Input .read () * ETCController::MAX_VOLTAGE;
95
99
this ->state .he2_read = this ->he2Input .read () * ETCController::MAX_VOLTAGE;
96
100
this ->state .he1_travel = he1Travel;
97
101
this ->state .he2_travel = he2Travel;
98
- this ->state .pedal_travel = pedalTravel;
99
102
this ->state .torque_demand =
100
- this ->state .motor_enabled ?
103
+ ( this ->state .motor_enabled && ! this -> state . brakes_implausibility ) ?
101
104
static_cast <int16_t >(pedalTravel * ETCController::MAX_TORQUE) :
102
105
0 ;
103
- this ->state .brakes_read = this ->brakePedalInput .read () * ETCController::MAX_VOLTAGE;
104
106
105
107
this ->brakeLightOutput .write (this ->state .brakes_read >= ETCController::BRAKE_TOLERANCE);
106
108
}
@@ -121,7 +123,7 @@ void ETCController::checkStartConditions() {
121
123
// If the brake is pressed past the tolerance threshold and the tractive system is ready
122
124
// then the motor can be enabled. The last condition for motor start is the cockpit switch
123
125
// 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 ) {
125
127
this ->state .motor_enabled = true ;
126
128
this ->runRTDS ();
127
129
}
@@ -153,8 +155,20 @@ void ETCController::resetState() {
153
155
this ->state .motor_forward = true ;
154
156
this ->state .cockpit = false ;
155
157
this ->state .torque_demand = 0 ;
158
+ this ->state .brakes_implausibility = false ;
156
159
}
157
160
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
+ }
158
172
159
173
ETCState ETCController::getState () const {
160
174
return this ->state ;
0 commit comments