Page 1 of 1
Control with UDP
Posted: Thu Aug 13, 2015 2:20 pm
by scamwell
Hello everyone,
I've been looking for a while to send commands to the crazyflie from simulink. I stumbled across this project:
https://www.youtube.com/watch?v=oKKKeknc3Ek
Which has managed to link up with simulink by sending UDP packets to the crazyflie with commands for thrust, pitch, yaw etc so I know it's possible. I don't really understand much about UDP and how the crazyflie itself would connect via UDP, as far as I understand it must be connected to the internet and have an IP address? If anyone could point me in the right direction to get started that would be much appreciated!
Thanks
Re: Control with UDP
Posted: Thu Aug 13, 2015 7:41 pm
by whoenig
I don't think UDP makes that much sense unless you want to run Matlab on a different machine. I think there are two good approaches:
1. Use ZMQ from Matlab. There seem to be projects on github already (e.g.
https://github.com/smcgill3/zeromq-matlab). More information about the ZMQ support in the official cf-client can be found here:
https://wiki.bitcraze.io/doc:crazyflie: ... put_device.
2. Call C(++) functions from Matlab. You would need to work on the binding, but there are C++ libraries for the crazyflie already (e.g.
https://github.com/fairlight1337/libcflie)
Re: Control with UDP
Posted: Fri Aug 14, 2015 8:08 am
by scamwell
I've done a bit more digging and I think the idea is to use the UDP blocks in simulink to send/receive data to/from a python script (using the CF python library) in real-time. So you have both the simulink model and python script running at the same time communicating with each other via UDP.
My experience with C code is pretty limited at the moment whoenig but thanks for the information. I'll keep this post updated if I make any progress
Re: Control with UDP
Posted: Wed Aug 26, 2015 6:22 pm
by arnaud
Hi,
ZeroMQ is very similar to UDP in the sense that both program will run independently and ZMQ is optimised to induce as low latency as possible, so if you can use ZMQ from matlab it would be the best as we already have implemented log/param and input drivers for it (and it is documented:
https://wiki.bitcraze.io/doc:crazyflie: ... put_device)
As for raw USB, unfortunately there is no implementation. If you want to make one you can add it as an input interface like we did for ZMQ:
https://github.com/bitcraze/crazyflie-c ... zmqpull.py. If you know some python it should not be very hard to get a driver working.
Re: Control with UDP
Posted: Thu Aug 27, 2015 8:54 am
by arnaud
I have been thinking a bit more about it and I could help you with making a UDP driver, I would really like to solve the matlab issue (we have been asked for how to connect to matlab but we do not use matlab so it is hard for us to really solve the problem).
So I am curious about a couple of things:
- Is UDP commonly used for this kind of application in matlab.
- What format the packet should have? Intuitively I would have used the same JSON as for ZMQ (with a sprintf or fprintf in matlab), would that work?
Re: Control with UDP
Posted: Sat Sep 12, 2015 7:23 pm
by rshum19
Hi whoeining,
I have a simulink "library" that I created from wrapping c++ code. If you are interested let me know and I can share it. I also have a zmq input from matlab working. It's still need some cleaning up but it works very good.
- Roberto
Re: Control with UDP
Posted: Wed Sep 16, 2015 2:24 pm
by scamwell
Hi Roberto,
I'd love to see the matlab zmq input script you've got working.
Re: Control with UDP
Posted: Thu Sep 17, 2015 9:02 am
by marcus
Glad to hear that it's working. It would be great if you wanted to share your Matlab solution for ZMQ.
Control with UDP
Posted: Wed Nov 04, 2015 4:39 pm
by meghgopabhat
Hi guys,
I am trying to communicate my crazyflie with simulink model through UDP.
Can someone please provide the code/model?
Any help appreciated.
Thank you,
Meghana