Page 1 of 1

Send Data From Crazyflie to Simulink with ZeroMQ

Posted: Thu Mar 17, 2022 3:05 am
by HazarB
Hi everyone,i hope you are doing great!

I'm working with crazyflie 2.1 , and i'm working on communication between Simulink and Crazyflie using ZeroMQ, i could manage the communication from simulink to crazyflie.
Now i'm working on getting data from crazyflie 2.1 and used it in Matlab , and for that Id like to Know if i can take data from Crazyflie2.1 using a specific port (like 1212 to send commands).
I have tried 2001,2000 and 1213 but they didn't work for me.
I'm trying another method which is: a python script logging data from crazyflie2.1 then send it to c function which is my s_function block on simulink but i'm challenging some issues ,also if there is a port that matlab can use to log data from crazyflie 2.1 directly with ZeroMq it will be much faster.
.
I hope you can help me and thank you in advance :)

Apdate; you can do this by Matlab Engine for python ,check this link https://www.mathworks.com/help/matlab/m ... ython.html

Re: Send Data From Crazyflie to Simulink with ZeroMQ

Posted: Wed Mar 23, 2022 8:39 am
by marcus
Hi!

Unfortunately I don't have access to Matlab/Simulink, but I'll try to see if I can help out.

I have a few questions, just to make sure I understand correctly:
  • Are you using our ZMQ server (this one)?
  • Are you using any other libs on the Simulink side to interface this?
  • Is the goal to get access to CRTP from Simulink or is it something else?

Re: Send Data From Crazyflie to Simulink with ZeroMQ

Posted: Thu Mar 24, 2022 3:42 pm
by HazarB
Thank you so much for your answer.

so for your questions:

1/ For this, yes im using ZMQ as input device in cfclient.
2/ Yes,Im using the library ZMQ in Matlab to establish the communication between Matlab and Crazyflie: https://github.com/fagg/matlab-zmq
3/ My goal is to establish a communication between matlab and crazyflie 2.1 without using CRTP in simulink (but now im using it because i didn't make it with zmq in terms of reading data from crazyflie using Matlab using a specif port).

Thank you.

Re: Send Data From Crazyflie to Simulink with ZeroMQ

Posted: Fri Mar 25, 2022 9:13 am
by marcus
OK, thanks for the info. I'm not sure about the state of the ZMQ server, we haven't used it in a long time. I can have a look and see if it's working. Otherwise there's also the option of trying this out.

I'll give the ZMQ server a try and let you know how it goes.

Re: Send Data From Crazyflie to Simulink with ZeroMQ

Posted: Fri Mar 25, 2022 9:45 am
by marcus
I've tested this out and it seems to work.

The way to use it to first start the server by running the following in the client repository:

Code: Select all

python bin/cfzmq
Once the server is up and running you will see the following printout.

Code: Select all

INFO:cfzmq:Biding ZMQ cmd serverat tcp://127.0.0.1:2000
INFO:cfzmq:Biding ZMQ log serverat tcp://127.0.0.1:2001
INFO:cfzmq:Biding ZMQ param serverat tcp://127.0.0.1:2002
INFO:cfzmq:Biding ZMQ ctrl serverat tcp://127.0.0.1:2004
INFO:cfzmq:Biding ZMQ conn serverat tcp://127.0.0.1:2003
Now you can connect to these and use the Crazyflie. The script I tested is located here, and it will scan, connect, list the TOCs, do some logging and then stop the logging and disconnect.

Let me know how it goes!

Re: Send Data From Crazyflie to Simulink with ZeroMQ

Posted: Tue Mar 29, 2022 3:44 pm
by HazarB
Thank you so much for your time and your help.

so i tried to test this but i have this error , i checked if zmq installed and yes it is.

Re: Send Data From Crazyflie to Simulink with ZeroMQ

Posted: Thu Mar 31, 2022 6:26 am
by marcus
Hmm, looks like it can't find the CF lib. Do you have it installed? Can you run the normal client?

Re: Send Data From Crazyflie to Simulink with ZeroMQ

Posted: Fri Apr 01, 2022 4:28 pm
by HazarB
sorry for the delay,
yes, im working with it (cfclient).

Re: Send Data From Crazyflie to Simulink with ZeroMQ

Posted: Mon Apr 04, 2022 10:51 am
by marcus
I'm not sure what the problem might be. I'm running the latest commit of the client and the cf-lib. I also tried to pip install the library, version cflib-0.1.18.1 and this also works.

It looks strange since when I tried to uninstall the cflib to try to replicate the problem, I get errors about crtp includes which you're not getting.

One option would be to uninstall the cf-lib and make sure it's completely uninstalled for Python 3/2, keep uninstalling until it says that it can't find it. Then install it again either from the repository or from the packages in pip. It's possible it might be using an old version that's somehow incompatible.

Re: Send Data From Crazyflie to Simulink with ZeroMQ

Posted: Wed Apr 06, 2022 7:42 pm
by HazarB
thank you so much for your help. i will try to do that