Bird
Raised Fist0
Drone Programmingprogramming~20 mins

RC signal loss failsafe in Drone Programming - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
RC Signal Loss Failsafe Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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())
AFailsafe Active
BNormal Operation
CAttributeError
DFailsafe Active after 5 seconds
Attempts:
2 left
💡 Hint
Think about how the failsafe triggers after 3 seconds of no signal.
🧠 Conceptual
intermediate
1:30remaining
What is the main purpose of an RC signal loss failsafe?
Why do drones implement an RC signal loss failsafe mechanism?
ATo increase the drone's speed when signal is weak
BTo automatically land or hover the drone safely when control signal is lost
CTo disable the drone's motors permanently
DTo send a notification to the pilot without changing drone behavior
Attempts:
2 left
💡 Hint
Think about safety when the pilot loses control.
🔧 Debug
advanced
2: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())
AFailsafe Active
BTypeError: unsupported operand type(s) for -: 'NoneType' and 'int'
CSyntaxError: invalid syntax
DAttributeError: 'Failsafe' object has no attribute 'status'
Attempts:
2 left
💡 Hint
Check if all methods used are defined.
📝 Syntax
advanced
1: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
Afailsafe_active = True if (time_since_loss > 5) else False
Bfailsafe_active = True if time_since_loss > 5 else
Cfailsafe_active = True if time_since_loss > 5 else False
Dfailsafe_active = True if time_since_loss > 5
Attempts:
2 left
💡 Hint
Ternary operator requires both 'if' and 'else' parts.
🚀 Application
expert
3: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)
A1
B0
C3
D2
Attempts:
2 left
💡 Hint
Failsafe triggers only once per continuous loss period after 3 seconds.

Practice

(1/5)
1.

What is the main purpose of an RC signal loss failsafe in drone programming?

easy
A. To keep the drone safe by triggering automatic actions when the remote control signal is lost
B. To increase the drone's speed during flight
C. To change the drone's color based on signal strength
D. To disable the drone's camera when the battery is low

Solution

  1. Step 1: Understand the role of failsafe

    The failsafe activates when the drone loses connection with the remote control to prevent accidents.
  2. Step 2: Identify the correct purpose

    It triggers automatic actions like hovering or returning home to keep the drone safe.
  3. Final Answer:

    To keep the drone safe by triggering automatic actions when the remote control signal is lost -> Option A
  4. Quick Check:

    Failsafe = safety trigger on signal loss [OK]
Hint: Failsafe acts when signal is lost to protect drone [OK]
Common Mistakes:
  • Confusing failsafe with speed control
  • Thinking failsafe changes drone color
  • Assuming failsafe disables camera
2.

Which of the following code snippets correctly sets a failsafe action to make the drone hover when RC signal is lost?

if rc_signal_lost:
    drone.____()
easy
A. return_home
B. hover
C. land_immediately
D. increase_speed

Solution

  1. Step 1: Identify the correct failsafe action for hovering

    The action to keep the drone in place is called 'hover'.
  2. Step 2: Match the method name

    Using drone.hover() will make the drone stay in the air safely when signal is lost.
  3. Final Answer:

    hover -> Option B
  4. Quick Check:

    Hover = stay still on signal loss [OK]
Hint: Hover means stay still; use drone.hover() for failsafe [OK]
Common Mistakes:
  • Choosing return_home which moves drone away
  • Selecting land_immediately which lands drone
  • Picking increase_speed which is unsafe
3.

What will be the output of the following code snippet when rc_signal_lost is True?

rc_signal_lost = True

if rc_signal_lost:
    action = 'return_home'
else:
    action = 'normal_flight'

print(action)
medium
A. return_home
B. normal_flight
C. None
D. SyntaxError

Solution

  1. Step 1: Check the value of rc_signal_lost

    rc_signal_lost is True, so the if condition is met.
  2. Step 2: Determine the assigned action

    Since condition is True, action is set to 'return_home'.
  3. Final Answer:

    return_home -> Option A
  4. Quick Check:

    True condition sets action = return_home [OK]
Hint: True condition triggers return_home action [OK]
Common Mistakes:
  • Confusing True with False branch
  • Expecting syntax error due to indentation
  • Thinking print outputs None
4.

Find the error in this failsafe code snippet and choose the correct fix:

if rc_signal_lost = True:
    drone.hover()
medium
A. Change drone.hover() to drone.land()
B. Add a colon ':' after drone.hover()
C. Remove the if statement entirely
D. Change '=' to '==' in the if condition

Solution

  1. Step 1: Identify the syntax error in the if condition

    The code uses '=' which is assignment, not comparison, inside the if condition.
  2. Step 2: Correct the comparison operator

    Replace '=' with '==' to properly check if rc_signal_lost is True.
  3. Final Answer:

    Change '=' to '==' in the if condition -> Option D
  4. Quick Check:

    Use '==' for comparison in if statements [OK]
Hint: Use '==' to compare, '=' assigns value [OK]
Common Mistakes:
  • Using '=' instead of '==' in conditions
  • Adding colon after function call instead of if
  • Removing if statement breaks logic
5.

You want to program a failsafe that makes the drone return home if the RC signal is lost for more than 5 seconds, otherwise it should hover. Which code snippet correctly implements this logic?

signal_lost_time = 6  # seconds

if rc_signal_lost:
    if signal_lost_time > 5:
        drone.return_home()
    else:
        drone.hover()
hard
A. The code should call drone.land() instead of drone.hover()
B. The code should use 'signal_lost_time >= 5' instead of '>'
C. The code correctly implements the failsafe logic
D. The code is missing an else for rc_signal_lost being False

Solution

  1. Step 1: Analyze the nested if conditions

    The outer if checks if signal is lost, inner if checks if lost time is more than 5 seconds.
  2. Step 2: Verify actions for each condition

    If lost time > 5, drone returns home; else it hovers. This matches the requirement.
  3. Final Answer:

    The code correctly implements the failsafe logic -> Option C
  4. Quick Check:

    Nested if matches time check and actions [OK]
Hint: Nested if handles time check and actions correctly [OK]
Common Mistakes:
  • Using >= instead of > changes timing slightly
  • Replacing hover with land changes behavior
  • Ignoring else for rc_signal_lost is acceptable here