Commands from Simulink to Crazyflie

Post here to get support
Post Reply
die4doby
Beginner
Posts: 6
Joined: Tue Jul 16, 2013 8:31 am

Commands from Simulink to Crazyflie

Post by die4doby » Thu Mar 05, 2020 9:24 pm

Hi,

I have a Crazyflie 2.0 and the Loco Positioning System. I am trying to model the drone in Simulink, create some trajectory and send the commands to the drone so that it follows the desired trajectory.

I have been trying to do this for a very long time but I am starting to give up. Many papers related to trajectory planning for Crazyflie but none of them discuss the steps needed to achieve this by using Crazyflie and Loco Positioning System .

What is the best way to send the commands from Simulink to the drone? Should I use ROS to achieve this? Or Python?
What is the best way to read values from the Loco Positioning System into Simulink?



kimberly
Bitcraze
Posts: 250
Joined: Fri Jul 06, 2018 11:13 am

Re: Commands from Simulink to Crazyflie

Post by kimberly » Fri Mar 06, 2020 10:36 am

This has indeed haven't been done before, but shouldn't be impossible. You just need to find a way for the commands to be read out in python, and then send it to the crazyflie through the crazyflie python library. The same the other way around, you will need to get the state estimate of the position from the log variables from the crazyflie (since the crazyflie estimates its position onboard), then you bridge those values from python to matlab to simulink (https://se.mathworks.com/products/matla ... ython.html).

Just in the case that it really doesn't work, you could use Ros in matlab to send the values to the rospackage for the crazyflie, but I would try to avoid that if I where you... last time I tried ROS with matlab it was not great...

You can look at viewtopic.php?f=6&t=4102&p=18899&hilit=matlab#p18899 for pointers on how to connect matlab with the crazyflie firmware, which is using the zmq server. It is pretty high level, but maybe as an inspiration.

Just some general advice: What you want to achieve is pretty challenging and big, which makes it a bit difficult to help you on the forum. What could help you is to try to chop up this problem in smaller chunks and ask advice for each small part.

die4doby
Beginner
Posts: 6
Joined: Tue Jul 16, 2013 8:31 am

Re: Commands from Simulink to Crazyflie

Post by die4doby » Fri Mar 06, 2020 1:44 pm

I want to be able to test different control algorithms and I think the best way might be to use Simulink. Below are the different clients for Crazyflie. What are the different possible options to achieve this by using Crazyflie and Loco Positioning System? What are the needed clients to be used to achieve these different options?

- Crazyflie python client: The main graphical client used for flying, logging, bootloading and various other tasks
- Crazyflie command-line bootloader: Used to bootload the Crazyflie from the command line
- Crazyflie headless client: A command line client used for flying. The client doesn't have a UI and is used for the Raspberry Pi image
- Crazyflie iOS client: The iOS client used to pilot the Crazyflie via Bluetooth LE
- Crazyflie Android client: The Android client used to pilot the Crazyflie via Bluetooth LE
- Crazyflie ZMQ server: Server which gives access to the Crazyflie though ZMQ.
Last edited by die4doby on Fri Mar 06, 2020 3:45 pm, edited 2 times in total.

die4doby
Beginner
Posts: 6
Joined: Tue Jul 16, 2013 8:31 am

Re: Commands from Simulink to Crazyflie

Post by die4doby » Fri Mar 06, 2020 1:45 pm

kimberly wrote:
Fri Mar 06, 2020 10:36 am
This has indeed haven't been done before, but shouldn't be impossible. You just need to find a way for the commands to be read out in python, and then send it to the crazyflie through the crazyflie python library. The same the other way around, you will need to get the state estimate of the position from the log variables from the crazyflie (since the crazyflie estimates its position onboard), then you bridge those values from python to matlab to simulink (https://se.mathworks.com/products/matla ... ython.html).

Just in the case that it really doesn't work, you could use Ros in matlab to send the values to the rospackage for the crazyflie, but I would try to avoid that if I where you... last time I tried ROS with matlab it was not great...

You can look at viewtopic.php?f=6&t=4102&p=18899&hilit=matlab#p18899 for pointers on how to connect matlab with the crazyflie firmware, which is using the zmq server. It is pretty high level, but maybe as an inspiration.

Just some general advice: What you want to achieve is pretty challenging and big, which makes it a bit difficult to help you on the forum. What could help you is to try to chop up this problem in smaller chunks and ask advice for each small part.
Thanks for your reply.

die4doby
Beginner
Posts: 6
Joined: Tue Jul 16, 2013 8:31 am

Re: Commands from Simulink to Crazyflie

Post by die4doby » Mon Mar 09, 2020 9:03 pm

I think if the Crazyflie developers want this drone to be accessible by everyone and not only expert developers and researchers, then a clear step-by-step guide would be really helpful for everyone (like undergrad students, ...etc).

I think I have to give up since I am spending way too much time just thinking about what should be changed in the code in order to enable custom control algorithms. I was really excited about this drone.

tobias
Bitcraze
Posts: 1965
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Commands from Simulink to Crazyflie

Post by tobias » Tue Mar 10, 2020 12:48 pm

We agree that the documentation is a bit sparse and this is something we are trying to improve, but our resources are limited.

As we don't have simulink it is also hard for us to develop anything for it. It is a quite expensive package and thus only available to limited audience. Is that then the route to take? Difficult question...

There is a master thesis from M Greiff "Modelling and Control of the Crazyflie Quadrotor for Aggressive and Autonomous Flight by Optical Flow Driven State Estimation, M. Greiff, Master’s thesis, Lund University, 2017" which you can find under publications here. It is a lot of information but describes how Greiff simulated and implemented a controller. Could be one path to try.

Post Reply