flight – Flight Controller Interface

Interface to CodeAIR’s Flight Control Computer

See also Crazyflie Client Library

High-level flying and sensors:

Basic Hover:

>>> fly.take_off()  # Ascend to default altitude at default speed
>>> fly.steady(4)   # Hold for 4 seconds
>>> fly.land()      # Descend at default speed

Low-level control and flight parameter access:

Watch Flight Controller console output on bootup:

>>> crtp.console_stdout(True)
>>> reset_controller()

Get sensor data:

>>> get_data(RANGERS)

Set and Get parameters (e.g., m1 speed parameter):

>>> set_param('motorPowerSet.m1', 5000)
>>> get_param('motorPowerSet.m1')
codeair.flight.ACCEL = ('acc.x', 'acc.y', 'acc.z')
codeair.flight.BAROMETER = ('baro.asl', 'baro.temp', 'baro.pressure')
codeair.flight.FLOW = ('motion.deltaX', 'motion.deltaY')
codeair.flight.GYRO = ('gyro.xRaw', 'gyro.yRaw', 'gyro.zRaw')
codeair.flight.MAG = ('mag.x', 'mag.y', 'mag.z')
codeair.flight.RANGERS = ('range.front', 'range.up', 'range.zrange')
codeair.flight.STATE_EST_POS = ('stateEstimate.x', 'stateEstimate.y', 'stateEstimate.z', 'stateEstimate.yaw')
codeair.flight.STATE_EST_VEL = ('stateEstimate.vx', 'stateEstimate.vy', 'stateEstimate.vz')
codeair.flight.get_data(log_items)[source]

Get a sensor value tuple from the Flight Controller data log. This will register for periodic logging of the given log items. Pass ‘None’ to stop data logging packets from Flight Controller.

Parameters

log_items (tuple) – Tuple of str names Log Values. Provided reference tuples: GYRO, RANGERS, FLOW, ACCEL, MAG, BAROMETER

codeair.flight.get_param(name)[source]

Get a single parameter value from Flight Controller. Note: these differ from log data.

Parameters

name (str) – See Param Names

codeair.flight.load_fw(file=None, prog=None)[source]

Load new firmware into the flight controller. By default uses Crazyflie controller firmware. Optional progress callback.

codeair.flight.motor_test(do_run)[source]

Run the motors at low speed.

codeair.flight.reset_controller()[source]

Reset the flight controller CPU

codeair.flight.set_param(name, value)[source]

Set a single parameter in Flight Controller

codeair.flight.version()[source]

Get version of flight controller firmware

Download Source