diff --git a/components/i_feed/devices/vehicle.py b/components/i_feed/devices/vehicle.py index 0a04cd7..811041a 100644 --- a/components/i_feed/devices/vehicle.py +++ b/components/i_feed/devices/vehicle.py @@ -53,6 +53,8 @@ class Vehicle: _nce_possible = True # stores if nce already happened, it only happens (up to) once _nce_happened = False + # stores if we are still recovering from NCE + _recovering = False # continuous driving thread _t: threading.Thread @@ -93,9 +95,11 @@ class Vehicle: def _sleep_and_recover(): recover_in = TIME_TO_RECOVER / SCALING + self._recovering = True print('\nNCE !!! Recovering in {} (scaled) seconds.\n'.format(recover_in)) time.sleep(recover_in) print('\nRecovered.\n') + self._recovering = False self.velocity = self._last_velocity self._rt = threading.Thread(target=_sleep_and_recover) @@ -218,7 +222,11 @@ class Vehicle: response: TargetVelocity = pickle.loads(response) velocity = response.target_velocity print('Received new velocity {}'.format(velocity)) - self.velocity = velocity + + if not self._recovering: + self.velocity = velocity + else: + print('We are still recovering ... ignoring new target velocity.') if __name__ == "__main__":