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
Failsafe Actions: RTL, Land, and SmartRTL
📖 Scenario: You are programming a drone to handle emergency situations safely. When the drone loses connection or faces a critical battery level, it must perform a failsafe action to protect itself and its surroundings.There are three main failsafe actions:RTL (Return to Launch): The drone flies back to its starting point.Land: The drone lands immediately at its current location.SmartRTL: The drone decides the safest way to return home, avoiding obstacles.
🎯 Goal: You will create a program that stores the drone's failsafe actions, sets a current failsafe mode, and then prints the action the drone will take in an emergency.
📋 What You'll Learn
Create a dictionary called failsafe_actions with keys 'RTL', 'Land', and 'SmartRTL' and their descriptions as values.
Create a variable called current_mode and set it to 'SmartRTL'.
Use a for loop with variables mode and description to iterate over failsafe_actions.items() and find the description for current_mode.
Print the message "Failsafe action: <description>" where <description> is the description of the current failsafe mode.
💡 Why This Matters
🌍 Real World
Drones must handle emergencies safely to avoid crashes or damage. Programming failsafe actions helps drones respond automatically when something goes wrong.
💼 Career
Understanding how to manage emergency procedures in drone software is important for drone operators, developers, and engineers working in robotics and unmanned aerial vehicles.
Progress0 / 4 steps
1
Create the failsafe actions dictionary
Create a dictionary called failsafe_actions with these exact entries: 'RTL': 'Return to Launch - fly back to starting point', 'Land': 'Land immediately at current location', and 'SmartRTL': 'Return home safely avoiding obstacles'.
Drone Programming
Hint
Use curly braces {} to create the dictionary and separate each key-value pair with a comma.
2
Set the current failsafe mode
Create a variable called current_mode and set it to the string 'SmartRTL'.
Drone Programming
Hint
Assign the string 'SmartRTL' to the variable current_mode.
3
Find the description for the current failsafe mode
Use a for loop with variables mode and description to iterate over failsafe_actions.items(). Inside the loop, check if mode equals current_mode. If yes, assign description to a variable called action_description.
Drone Programming
Hint
Use if mode == current_mode: inside the loop to find the matching description.
4
Print the failsafe action description
Write a print statement to display the message "Failsafe action: <action_description>" where <action_description> is the variable holding the description of the current failsafe mode.
Drone Programming
Hint
Use an f-string inside print to include the variable action_description in the message.
Practice
(1/5)
1. What does the RTL failsafe action do when triggered on a drone?
easy
A. The drone returns to its takeoff point automatically.
B. The drone immediately lands at its current location.
C. The drone hovers in place until manual control is regained.
D. The drone performs a pre-programmed flight path before landing.
Solution
Step 1: Understand RTL meaning
RTL stands for "Return To Launch," meaning the drone flies back to where it took off.
Step 2: Compare with other failsafe actions
Unlike Land or SmartRTL, RTL specifically returns the drone to the takeoff point automatically.
Final Answer:
The drone returns to its takeoff point automatically. -> Option A
Quick Check:
RTL = Return To Launch [OK]
Hint: RTL always means return to the starting point [OK]
Common Mistakes:
Confusing RTL with immediate landing
Thinking RTL means hovering
Assuming RTL follows a custom path
2. Which of the following is the correct syntax to set the failsafe action to Land in a drone programming script?
easy
A. set_failsafeAction('Land')
B. setFailsafeAction(Land)
C. setFailsafeAction("Land")
D. setFailsafeAction('land')
Solution
Step 1: Identify string syntax in code
Failsafe actions are usually passed as strings, so quotes are needed around the word Land.
Step 2: Check correct string format
Double quotes or single quotes can be used, but the option with double quotes and correct capitalization is standard.
Final Answer:
setFailsafeAction("Land") -> Option C
Quick Check:
String with quotes and correct case = setFailsafeAction("Land") [OK]
Hint: Use quotes and correct capitalization for string parameters [OK]
Common Mistakes:
Omitting quotes around the string
Using wrong capitalization
Passing the action as a variable without quotes
3. Given the following code snippet, what will be the drone's behavior if the failsafe is triggered?
failsafe = 'SmartRTL'
if failsafe == 'RTL':
action = 'Return to launch point'
elif failsafe == 'Land':
action = 'Land immediately'
elif failsafe == 'SmartRTL':
action = 'Return home avoiding obstacles'
else:
action = 'Hover in place'
print(action)
medium
A. Return home avoiding obstacles
B. Land immediately
C. Return to launch point
D. Hover in place
Solution
Step 1: Check the value of failsafe variable
The variable failsafe is set to 'SmartRTL'.
Step 2: Follow the if-elif conditions
The code matches the 'SmartRTL' condition and sets action to 'Return home avoiding obstacles'.
Final Answer:
Return home avoiding obstacles -> Option A
Quick Check:
SmartRTL triggers obstacle-avoiding return [OK]
Hint: Match variable value to condition branches carefully [OK]
Common Mistakes:
Choosing the default else action
Confusing SmartRTL with simple RTL
Ignoring case sensitivity in strings
4. Identify the error in this failsafe action code snippet: