added reset on malicious coordinates
This commit is contained in:
parent
8d89b569ba
commit
a3183ade07
@ -223,15 +223,16 @@ class Vehicle:
|
|||||||
def check_reset(self):
|
def check_reset(self):
|
||||||
"""
|
"""
|
||||||
Checks if end of route is reached and resets vehicle to starting conditions.
|
Checks if end of route is reached and resets vehicle to starting conditions.
|
||||||
|
It also resets on malicious coordinates.
|
||||||
|
|
||||||
Afterwards, the vehicle is still driving, but again from start.
|
Afterwards, the vehicle is still driving, but again from start.
|
||||||
"""
|
"""
|
||||||
if self._driven_kms >= RESET_KM:
|
if self._driven_kms >= RESET_KM:
|
||||||
print('\n\nEnd of route reached ... resetting and restarting vehicle')
|
self._reset()
|
||||||
self._gps_location = self._starting_point
|
|
||||||
self._driven_kms = 0
|
if self._gps_location.latitude < self._starting_point.latitude or \
|
||||||
self.last_update = datetime.now()
|
self._gps_location.longitude < self._starting_point.longitude:
|
||||||
self.nce = False
|
self._reset()
|
||||||
self.velocity = STARTING_VELOCITY
|
|
||||||
|
|
||||||
@circuit(failure_threshold=10, expected_exception=AMQPConnectionError)
|
@circuit(failure_threshold=10, expected_exception=AMQPConnectionError)
|
||||||
def send_status_update(self):
|
def send_status_update(self):
|
||||||
@ -256,6 +257,14 @@ class Vehicle:
|
|||||||
else:
|
else:
|
||||||
print('We are still recovering ... ignoring new target velocity.')
|
print('We are still recovering ... ignoring new target velocity.')
|
||||||
|
|
||||||
|
def _reset(self):
|
||||||
|
print('\n\nEnd of route reached ... resetting and restarting vehicle')
|
||||||
|
self._gps_location = self._starting_point
|
||||||
|
self._driven_kms = 0
|
||||||
|
self.last_update = datetime.now()
|
||||||
|
self.nce = False
|
||||||
|
self.velocity = STARTING_VELOCITY
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
...
|
...
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user