Control with UDP
Control with UDP
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
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
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)
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
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
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
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.
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
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?
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
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
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
Hi Roberto,
I'd love to see the matlab zmq input script you've got working.
I'd love to see the matlab zmq input script you've got working.
Re: Control with UDP
Glad to hear that it's working. It would be great if you wanted to share your Matlab solution for ZMQ.
-
- Beginner
- Posts: 1
- Joined: Wed Nov 04, 2015 8:21 am
Control with UDP
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
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