Python API Reference

The module pycrazyswarm, contained in /ros_ws/src/crazyswarm/scripts, is the main high-level interface to the Crazyswarm platform.

The goal of the Crazyswarm project is to reach a state where many diverse multi-quadrotor research projects can be implemented without going any “deeper” than writing a pycrazyswarm script and modifying configuration files. New projects should try this approach first. If it becomes necessary to modify Crazyswarm or its submodules, we encourage users to contribute those changes back via Github pull request.

All classes in pycrazyswarm.crazyflie are mirrored by an identically named class in pycrazyswarm.crazyflieSim. The Sim version allows testing pycrazyswarm scripts in simulation with a 3D visualization before running anything on real hardware. Since the APIs are identical, the documentation only refers to the non-Sim versions.

Crazyflie class

CrazyflieServer class

TimeHelper class

Switching between simulation and real hardware

Correct pycrazyswarm scripts should be able to run in both simulation and on real hardware without modification. Enable simulation and control the simulation parameters with the command-line flags listed below.

usage: python2 <> [-h] [--sim] [--vis {mpl,vispy,null}]
                                         [--dt DT] [--writecsv]
                                         [--disturbance DISTURBANCE]
                                         [--maxvel MAXVEL] [--video VIDEO]

Named Arguments


Run using simulation.

Default: False



Possible choices: mpl, vispy, null

Visualization backend.

Default: “mpl”


Duration of seconds between rendered visualization frames.

Default: 0.1


Enable CSV output.

Default: False


Simulate Gaussian-distributed disturbance when using cmdVelocityWorld.

Default: 0.0


Limit simulated velocity (meters/sec).

Default: inf

--video Video output path.

Note: rendering video output with the --video option requires an installation of ffmpeg with the libx264 encoder. This is provided in the anaconda environment, but must be installed manually otherwise.