Challenge - 5 Problems
RC Signal Loss Failsafe Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output when RC signal is lost?
Consider this drone control snippet that triggers a failsafe when the RC signal is lost for more than 3 seconds. What will be printed if the signal is lost at time 0 and no signal is received for 4 seconds?
Drone Programming
class DroneController: def __init__(self): self.signal_lost_time = None self.failsafe_triggered = False def receive_signal(self, time): self.signal_lost_time = None def check_signal(self, current_time): if self.signal_lost_time is None: self.signal_lost_time = current_time elif current_time - self.signal_lost_time > 3: self.failsafe_triggered = True def status(self): return 'Failsafe Active' if self.failsafe_triggered else 'Normal Operation' controller = DroneController() controller.check_signal(0) controller.check_signal(4) print(controller.status())
Attempts:
2 left
💡 Hint
Think about how the failsafe triggers after 3 seconds of no signal.
✗ Incorrect
The failsafe triggers because the signal is lost at time 0 and remains lost at time 4, which is more than 3 seconds. So the status returns 'Failsafe Active'.
🧠 Conceptual
intermediate1:30remaining
What is the main purpose of an RC signal loss failsafe?
Why do drones implement an RC signal loss failsafe mechanism?
Attempts:
2 left
💡 Hint
Think about safety when the pilot loses control.
✗ Incorrect
The failsafe ensures the drone does not fly uncontrolled by automatically landing or hovering safely when the RC signal is lost.
🔧 Debug
advanced2:30remaining
Identify the error in this failsafe implementation
This code is supposed to trigger a failsafe after 2 seconds of signal loss. What error will it cause when run?
Drone Programming
class Failsafe: def __init__(self): self.lost_time = None self.active = False def signal_received(self): self.lost_time = None def check(self, current_time): if self.lost_time is None: self.lost_time = current_time elif current_time - self.lost_time > 2: self.active = True failsafe = Failsafe() failsafe.check(1) failsafe.check(4) print(failsafe.status())
Attempts:
2 left
💡 Hint
Check if all methods used are defined.
✗ Incorrect
The class does not have a 'status' method, so calling failsafe.status() raises an AttributeError.
📝 Syntax
advanced1:30remaining
Which option correctly implements a failsafe check with a ternary operator?
Fix the syntax error in this failsafe check line:
failsafe_active = True if time_since_loss > 5 else False
Attempts:
2 left
💡 Hint
Ternary operator requires both 'if' and 'else' parts.
✗ Incorrect
Option C is the correct syntax for a ternary conditional expression in Python.
🚀 Application
expert3:00remaining
How many times will the failsafe trigger in this signal loss sequence?
Given this code that checks signal loss every second and triggers failsafe if loss lasts more than 3 seconds, how many times will 'Failsafe triggered' print?
class Drone:
def __init__(self):
self.signal_lost_start = None
self.failsafe_triggered = False
def update_signal(self, signal_present, current_time):
if signal_present:
self.signal_lost_start = None
self.failsafe_triggered = False
else:
if self.signal_lost_start is None:
self.signal_lost_start = current_time
elif current_time - self.signal_lost_start >= 3 and not self.failsafe_triggered:
print('Failsafe triggered')
self.failsafe_triggered = True
# Signal presence over 7 seconds: [True, False, False, False, False, True, False]
drone = Drone()
signal_sequence = [True, False, False, False, False, True, False]
for t, signal in enumerate(signal_sequence):
drone.update_signal(signal, t)
Attempts:
2 left
💡 Hint
Failsafe triggers only once per continuous loss period after 3 seconds.
✗ Incorrect
Failsafe triggers once at t=4 (after 3 seconds of loss). It resets when signal returns at t=5, so no second trigger at t=6.