guest-post

This week we have a guest blog post by Giuseppe Silano, Postdoctoral Researcher at the Czech Technical University (CTU) in Prague, Multi-Robot System (MRS) group, who maintains CrazyS, a simulator of the Crazyflie for ROS and Gazebo. Enjoy!

Where CrazyS comes from

Back in 2017, at the University of Sannio in Benevento, we wanted a way to try control algorithms on the Crazyflie 2.0 before risking a real drone. RotorS, the MAV simulator from ETH Zurich, already gave a good model of motors, propellers and sensors for Gazebo. What was missing was the Crazyflie: its physical parameters and, above all, its flight controller.

CrazyS fills that gap. It adds a model of the Crazyflie to RotorS and re-implements the control architecture of the firmware (release 2018.01): the cascade of position, attitude and rate controllers, the complementary filter that estimates the attitude from the IMU, and the mixer that turns the controller outputs into motor commands. You can tune a controller in simulation, look at every signal, and only then move to the real drone. We presented the platform at MED 2018 and later in a chapter of the Springer book Robot Operating System (ROS): The Complete Reference (Volume 4).

A note on how CrazyS differs from CrazySim, which was presented on this blog in 2024. CrazySim compiles and runs the actual Crazyflie firmware against Gazebo. CrazyS instead re-writes the controllers as ROS nodes in C++, so they can be read, changed and logged like any other ROS code. The two approaches answer different questions. If you want to test the firmware you will fly, use CrazySim. If you want to design a new controller and compare it with the stock one, CrazyS is a good fit.

Over the years CrazyS grew one branch per ROS distribution (Kinetic, Melodic, Noetic), picked up an Internal Model Controller and swarm examples, and slowly fell behind ROS 2. This autumn I finally found the time to catch up.

What’s new

ROS 2 Jazzy and Gazebo Sim

The biggest change is the new dev/ros2-jazzy branch, which runs on Ubuntu 24.04 with ROS 2 Jazzy and Gazebo Harmonic. Here the port turned out simpler than I expected. Gazebo Sim already ships the RotorS motor model as the MulticopterMotorModel system, together with odometry, IMU and joint state systems, so CrazyS no longer needs custom Gazebo plugins at all. The drone model is a xacro file that uses these systems, and ros_gz_bridge moves the data to ROS 2. As a check, I fed the same motor speeds to the old and the new simulator: the drone moves the same way in both.

The control code was split into a library that does not depend on ROS, plus thin ROS 2 nodes, and the library now has unit tests. All the Crazyflie examples are ported: hovering with the firmware controller (with or without the state estimator), the Internal Model Controller, swarms, joystick control and a “no controller” mode where you send motor speeds yourself.

ros2 launch rotors_gazebo crazyflie2_hovering_example.launch.pyCode language: CSS (css)

Lee’s geometric controller

The second novelty is a geometric tracking controller on SE(3), from the well-known paper by Lee, Leok and McClamroch. Stefano Grossi developed and tuned it for the Crazyflie in his MSc thesis at the University of Modena and Reggio Emilia, supervised by Lorenzo Sabattini, Beatrice Capelli and Federico Pratissoli. His pull request had been waiting in the repository since 2021, and it is now part of every release, ROS 1 and ROS 2.

Trajectories are written as a list of segments in a YAML file, so a new scenario does not need any code. This is the half circle from the thesis:

segments:
  - {type: line, goal: [0.0, 0.0, 1.0], duration: 2.0, profile: linear}
  - {type: hold, duration: 4.0}
  - {type: line, goal: [1.0, 0.0, 1.0], duration: 2.0, profile: linear}
  - {type: hold, duration: 4.0}
  - {type: arc, center: [0.0, 0.0], angle: 3.14159265359, duration: 5.0, profile: linear}Code language: CSS (css)

A cubic profile instead of linear starts and stops each segment with zero velocity.

The repository includes the scenarios from the thesis (hovering, straight lines, half circles) and a three-drone swarm. In simulation the controller follows them within about 10 cm at the fastest points and settles to a few millimetres at the end.

ros2 launch rotors_gazebo crazyflie2_lee_geometric_controller.launch.py trajectory:=semicircle
ros2 launch rotors_gazebo crazyflie2_swarm_lee_geometric_controller.launch.py

In the video below, you can see the swarm example: three Crazyflies, each with its own geometric controller and its own trajectory, flying in Gazebo Harmonic. All three take off to 1 m. Drone 2 then flies a half circle around the origin, from (1, 0) to (−1, 0). Drone 3 moves into the spot drone 2 has just left. Drone 1 waits a few seconds before heading to (1, 1), so that its path does not cross drone 2’s. The video plays at real speed: each frame was rendered from the simulation clock, 30 frames per simulated second.

A bug that hid for years

This one is a good story for anyone who writes controllers. Over the years, several issues on GitHub were about the hovering example not behaving as it should, and I had always put the drift down to tuning. While porting the code I finally measured it: on ROS Noetic, after 60 s of plain hovering the drone was 0.9 m off and had turned by 9 degrees, and in Gazebo Harmonic it hit the ground after 67 s.

The cause was much simpler than tuning. Without the state estimator, the controller runs at every odometry message, which arrives at 1 kHz. Its integrators, however, added ki * error * 0.01, as if each step were 10 ms long. Every integral gain was therefore ten times larger than intended. The altitude swung between 0.6 and 1.6 m after take-off, and then the lateral loops slowly built up an oscillation until the drone left. Using the real time between two odometry messages fixed it: the drone now holds its position for as long as you like.

The same lesson came up again in the ROS 2 port. Under load, ROS 2 timers drifted by up to 20% with respect to the simulation time, and the fourth-order derivatives inside the geometric controller turned that jitter into instability in the swarm example. The controller now samples on the odometry time stamps and computes every derivative with the actual time between samples. In short: never trust that dt is what you think it is.

Keeping the old versions alive

Many people still use CrazyS on ROS 1, so the Kinetic, Melodic and Noetic branches received the same fixes and the new controller. Each branch now has its own GitHub Actions workflow that builds it in a Docker container with the matching Ubuntu version. The end-of-life distributions come from the final snapshots on snapshots.ros.org. For the ROS 2 branch, CI also builds the Debian packages the way the ROS buildfarm does, which is the first step towards an apt install.

What CrazyS is not

To be clear about the limits: everything above was tested in simulation, not on a real Crazyflie. The controllers are re-implementations, not the firmware itself. They follow the firmware’s structure, but they are not the code you flash. The firmware position controller in CrazyS also still tracks lateral waypoints poorly: its attitude loop is too slow, and fixing that means re-tuning the whole cascade. For trajectories, the geometric controller and the Internal Model Controller are the better choice today.

Try it

mkdir -p ~/crazys_ws/src && cd ~/crazys_ws/src
git clone -b dev/ros2-jazzy https://github.com/gsilano/CrazyS.git
cd ~/crazys_ws && rosdep install --from-paths src --ignore-src -y
colcon build && source install/setup.bash
ros2 launch rotors_gazebo crazyflie2_lee_geometric_controller.launch.py trajectory:=semicircleCode language: PHP (php)

The ROS 1 instructions are in the README on the master branch.

Links

Final thoughts

If you use CrazyS, whether in a course, a thesis or a paper, I would love to hear about it, and issues and pull requests are always welcome. For questions and bug reports, the best place is the GitHub issues; for anything else, you can find my contacts on my website.

What does it take to bring a new coordination stack to the Crazyflie? In this guest post, Jim Steele, founder of Tapestry OS, shares his experience building a Zephyr-based firmware port for the Crazyflie 2.1 Brushless and using it to explore decentralized coordination with three drones. We’re happy to welcome Jim to the blog to share the work and what he learned along the way.

The Crazyflie platform has an excellent answer to the question of how to fly a drone autonomously. The firmware is well-documented and actively maintained with hardware abstraction, sensor drivers, and state estimators providing solid infrastructure that a research team can build on confidently.

The question I kept running into is one layer above that: once you have drones that can fly reliably, how do you coordinate what a collective of them does together? Not at the trajectory level (Crazyswarm2 handles that well) but at the level of distributed state: what does each drone know about where the others are, how fresh is that information, and how does the collective continue functioning correctly when a drone fails or communication is interrupted?

3 Brushless flying seen on a beige workplace background

Most research teams answer this question by writing custom coordination firmware specific to their experiment. The result works, but it does not transfer to the next experiment or the next platform. I wanted an answer that would.

Tapestry OS provides this layer as an open-source coordination stack built on Zephyr RTOS. It includes a distributed world model, gossip-based state propagation, fault-tolerant consensus, and a declarative application API that lets domain experts express collective behavior without touching the underlying firmware. This post is about porting Tapestry to the Crazyflie 2.1 Brushless and validating its core coordination claim on three drones flying in collective formation.

The port

Tapestry’s stack has seven layers, L1 through L7. For the Crazyflie port, the work lives in L1: the Physical Substrate Interface, Tapestry’s equivalent of a board support package. We began by developing a native Zephyr port for the Crazyflie 2.1 Brushless. This had to include the flight control itself: attitude (rate + angle), altitude-hold, position-hold loops, sensor drivers, and a Lighthouse V2 deck driver. Bitcraze stock firmware was an invaluable reference (the control cascade architecture and the Lighthouse calibration math especially) though Tapestry’s implementation is written from scratch and shares no code with it. 

Bring-up including L2 had some surprises, including two real bugs in Zephyr’s STM32 I2C driver that the Tapestry repository carries as patches until they are upstreamed. Streaming console output over the Crazyradio early in the port made debugging much less painful.

Lighthouse positioning took the longest. The interesting problems were pairing the base station’s sweep planes correctly from raw deck timestamps, and rejecting phantom rays from specular room reflections. The eventual implemented solution gates rays against the base station’s optical field of view (a hardware constant that survives recalibration) plus triangulation-consistency and rate-of-motion checks. Once resolved, position accuracy is solid.

Tapestry’s higher layers, including the L3 gossip transport and the L4 Collective State Manager, required no changes. That is the point: once the foundation is in place, the coordination logic does not care whether it is running on a ground robot or a drone.

The formation demo

Three Crazyflie 2.1 Brushless drones, each running Zephyr with the Tapestry substrate and collective world model, were flown in a simple formation. Each drone reads its own absolute position from the Lighthouse deck and gossips it to its peers every 500 ms over the nRF51’s peer-to-peer radio channel. The resulting world model holds fresh entries for its two peers, with staleness tracking, and continually compares its distance to each fresh peer against a target spacing: too close pushes away, too far pulls closer. 

The example formation in the following video shows two drones hover and align in equilibrium. When a third powers on and flies among them, the three maintain separation until the third drone ends its mission, lands itself, and the remaining two close back into their line before landing.

There is no leader, no ground station, and no phase script: each drone runs Tapestry’s decentralized world model and shares only its own position over gossip. The recovery behavior is the part to watch closely. When one drone ends its mission, it lands and goes silent. The remaining two re-form their line about ten seconds after the departure, without any instruction from an external system. This is deliberately the same code path that would handle a real mid-flight interruption. 

This is Tapestry’s first demonstration on real Crazyflie drones: a coherent shared understanding of collective state, maintained entirely through peer-to-peer gossip, driving behavior through local rules. The demo logic can be expressed as a declarative L7 Choreo with the Tapestry SDK without touching firmware.

What is available

The Crazyflie 2.1 Brushless support is in the Tapestry OS repository under Apache 2.0. It includes the steps to recreate this demo: per-drone configuration, Lighthouse calibration, and ESC provisioning.

This is an initial port. We chose Zephyr to unlock a standardized, scalable ecosystem that allows the Crazyflie to integrate with industrial-grade RTOS tooling. We chose standard PWM for this port to simplify the initial Zephyr hardware abstraction with a stable and reliable baseline for our formation coordination logic. A number of Crazyflie capabilities are not yet available on the Zephyr-based stack (Kalman estimation, flow deck, and DSHOT among them), and contributions are welcome.

If you are doing swarm research on the Crazyflie and want coordination infrastructure you do not have to build yourself, the Tapestry repository is a good starting point. Try the port, open an issue if you hit hardware-specific bugs, and share your formation experiments on GitHub or in the Bitcraze forum.