Flying Multiple Crazyfiles

Discussions about autonomous flight in general, regardless of positioning method
Post Reply
yuhsiang
Beginner
Posts: 22
Joined: Wed Mar 03, 2021 11:53 am

Flying Multiple Crazyfiles

Post by yuhsiang »

Hi all,

I am planning to implement high-level formation control for various purpose with multiple Crazyflies. So far, I have tested autonomous flying with one Crazyflie 2.1 by Python scripting using cflib. I have no problem getting data by creating logging configurations, and commanding the Crazyflie by different commander functions such as position setpoints, velocity setpoints and motion commander.

The next step of my research is to implement high-level formation control with less than 10 Crazyflies. The high-level formation control will take the position or attitude data of each Crazyflies as inputs and compute the control outputs as velocity or position commands at runtime. I am planning to use Flow Deck2 together with LPS. Now, I am not sure whether it is possible to achieve this by using the swarm class in cflib and just coding in Python script. Or do I have to use ROS platforms, such as Crazyswarm or Crazyflie ROS to fly multiple Crazyflies 2.1? I have no experience with Ubuntu and ROS. So I would prefer to code in Python script if possible.

Also, can someone explain what is the difference and the pros and cons between using cflib Python API, Crazyflie ROS and Crazyswarm?

Regarding Crazyswarm, I have several questions about the function of the simulation :

1. In the simulation, do you consider the dynamical model of the Crazyflie2.0? How about Crazyflie 2.1?
2. What is the controller used in the simulation, is it the same as the cascaded PID controller from Bitcraze?
3. I would like to use this simulation to test my high-level formation control if possible. When running the simulation, can we access the logging configuration, such as position, attitude data, etc.? If yes, is it possible that I can get the position and attitude data and use them as my high-level formation control input and send the formation control output as a velocity or position command to the Crazyflies at runtime in the simulation?

Other than simulation, I also have some questions about real hardware:
1. Can we use the cflib Python API from Bitcraze together with the Crazyswarm and fly a swarm of Crazylies by only Python scripts? Or is it somehow necessary to interact with ROS? (I don't have any experience with ROS, but I am comfortable programming Python script to fly Crazyflie by using cflib.)
2. I understand that we can create a logging configuration and get the data directly through the cflib Python API. How about Crazyswarm? Can we create a logging configuration and get the data through a Python script?
3. I have looked at the sample code of hello.world.py and niceHover.py. I understand that it is fairly easy to command multiple Crazyflies at the same time. But how do we create logging configurations? Is there a sample code regarding this?

Thank you in advance.

Yu-Hsiang
whoenig
Expert
Posts: 395
Joined: Mon Oct 27, 2014 2:55 am

Re: Flying Multiple Crazyfiles

Post by whoenig »

Re: cflib Python API, Crazyflie ROS and Crazyswarm

Crazyflie_ROS is deprecated for standalone use and new projects. You can find a good discussion on cflib vs. Crazyswarm at https://crazyswarm.readthedocs.io/en/la ... python-api.

Re: Crazyswarm Simulation:

1. No, this "simulation" only visualizes the setpoints, there are no dynamics involved. In my experience, this is sufficient for testing swarm applications, if you limit your setpoint change (I use v_max = 0.2m/s; a_max=2m/s^2). If you need a dynamics simulator, take a look at CrazyS (https://github.com/gsilano/CrazyS).
2. None, see #1.
3. Yes, you can access the current state.

Re: Crazyswarm Hardware:

1. No, both are exclusive and you have to pick one. The APIs and feature sets are different.
2. Yes, you can also configure logging through a config file.
3. This can be enabled for all CFs: https://github.com/USC-ACTLab/crazyswar ... ch#L12-L14. There is currently no way to enable different settings per Crazyflie.

In your use case (LPS + Flow; off-board computation), the Crazyswarm has very limited advantages, so I think you should keep working using cflib. The Crazyswarm is mostly useful if you have a motion capture system or have some other good use-case to use broadcast communication (a feature that is currently not available in cflib). For unicast communication, you might have a slight performance gain with the Crazyswarm, but cflib might be fast enough, especially if you switch to one of the native backends (see https://www.bitcraze.io/2021/02/communi ... liability/).
yuhsiang
Beginner
Posts: 22
Joined: Wed Mar 03, 2021 11:53 am

Re: Flying Multiple Crazyfiles

Post by yuhsiang »

Thank you whoenig for your reply.

So, you mentioned that in the simulation of Crazyswarm, we can still access the state of the Crazyflie at runtime. And if I understand correctly, we need to set up the logging configurations in the ROS environment before starting the main Python script. So how do we exactly call the logging configuration in the main script? For example in this Python script https://github.com/USC-ACTLab/crazyswar ... Hover.py , we can command each Crazyflie by goTo function. How do we call the logging configuration in this Python script? Because I would like to compute the command setpoints by using the position and attitude data as the input, I need to import the logging configuration in the Python script.

Thank you.

Yu-Hsiang
whoenig
Expert
Posts: 395
Joined: Mon Oct 27, 2014 2:55 am

Re: Flying Multiple Crazyfiles

Post by whoenig »

You can use the ROS Python API for subscribers (see http://wiki.ros.org/ROS/Tutorials/Writi ... 8python%29 for a tutorial). Essentially, you would set-up a subscriber to listen on the "cf<id>/pose" topic. Then, every time you receive new data, a function will be called with the new data. The advantage of this publisher/subscriber system is that you can easily visualize internal states, for example by using rviz.

For using the Crazyswarm, it is helpful to learn a little bit of ROS basics. The online tutorials or part 1 of http://wiki.ros.org/Books/Programming_Robots_with_ROS are a good starting point in my opinion.
Post Reply