Choose the best description of what a flight controller does in a drone.
Think about what helps the drone stay balanced and follow commands.
The flight controller reads sensors like gyroscopes and accelerometers to keep the drone stable and controls the motors to move it as directed.
What will be the output of this simplified flight controller code snippet?
sensor_data = {'gyro': 0.05, 'accel': -0.02}
stabilize = sensor_data['gyro'] * 10 + sensor_data['accel'] * 5
print(round(stabilize, 2))Calculate: (0.05 * 10) + (-0.02 * 5)
0.05 times 10 is 0.5, -0.02 times 5 is -0.1, sum is 0.4, rounded to 0.4.
What error will this flight controller code cause?
motors = [1000, 1000, 1000, 1000] for i in range(4): motors[i] += throttle print(motors)
Check if all variables used are defined before the loop.
The variable 'throttle' is used but never defined, causing a NameError.
Choose the correct syntax to create a PID controller object with gains P=1.0, I=0.5, D=0.1.
class PIDController: def __init__(self, P, I, D): self.P = P self.I = I self.D = D
Remember that positional arguments must come before keyword arguments.
Option C uses only keyword arguments, which is valid. Option C is also valid but option C is the only fully keyword argument call here. Options B and D mix positional and keyword arguments incorrectly, causing SyntaxError.
Given this code, how many motor speeds will be updated to a new value?
motors = [900, 900, 900, 900] updates = [50, -20, 30] for i in range(len(updates)): motors[i] += updates[i] print(motors)
Count how many elements are in the updates list and how many motors get changed.
The updates list has 3 values, so only the first 3 motors are updated. The last motor remains unchanged.
