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
- CrazyS on GitHub: https://github.com/gsilano/CrazyS
- ROS 2 branch: https://github.com/gsilano/CrazyS/tree/dev/ros2-jazzy
- Wiki: https://github.com/gsilano/CrazyS/wiki
- G. Silano, E. Aucone, L. Iannelli, “CrazyS: A Software-In-The-Loop Platform for the Crazyflie 2.0 Nano-Quadcopter”, in 2018 26th Mediterranean Conference on Control and Automation (MED), pp. 352–357, June, 2018, Zadar, Croatia. Preprint: https://giuseppesilano.net/publications/med18.pdf
- Video of the original release: https://youtu.be/qsrYCUSQ-S4
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.