Page 1 of 1

Sending commands through client

Posted: Mon Feb 26, 2018 3:02 am
by Abanoub.G
Hi,
Is it possible to send commands for thrust, yaw, roll and pitch for certain intervals of time through the client??

Regards
AG

Re: Sending commands through client

Posted: Mon Feb 26, 2018 1:22 pm
by arnaud
Hi,
It is possible using the ZMQ interface. You can find some documentation for it on the wiki: https://wiki.bitcraze.io/doc:crazyflie: ... put_device.

Re: Sending commands through client

Posted: Tue Feb 27, 2018 7:19 pm
by Abanoub.G
How would I enable the zmq from the client??

Re: Sending commands through client

Posted: Tue Feb 27, 2018 8:24 pm
by Abanoub.G
Also in one of the examples in your VM where the CF is ramed using the zmq, it needs to import at zmq file that is not included. I have looked up a lot on the internet but it's really confusing to get it working.

The zmq files that I have managed to get from the web are missing a subfolder called context thus the code keeps on giving me errors. Is it possible if you upload the zmq file you guys are using in your VM.

Thanks

Re: Sending commands through client

Posted: Tue Feb 27, 2018 9:33 pm
by Abanoub.G
Right I have managed to install zmq by following the steps on this website https://tuananh.org/2015/06/16/how-to-i ... on-ubuntu/

However, I am still getting this error of 'module' object has no attribute 'Context'
i.e. there is nothing called context inside of the zmq folder

Re: Sending commands through client

Posted: Wed Feb 28, 2018 12:39 pm
by arnaud
I am assuming you want to write scripts in python. You should be able to get started with "pip3 install zmq", this will install the zmq module for python and will allow you so connect the client zmq socket. There should be no need to compile anything manually. If zmq is installed, Context is there:

Code: Select all

$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import zmq
>>> zmq.Context
<class 'zmq.sugar.context.Context'>
Have you managed to enable the zmq commander in the client? It is disabled by default but can be enabled in the config json file as documented in the wiki page. You can find the configuration folder by opening the menu "settings/open config folder" in the client.

Re: Sending commands through client

Posted: Wed Feb 28, 2018 2:20 pm
by arnaud
Hi, I though I would make a quick example to get you started.

This will set the thrust to 20% in the client:

Code: Select all

$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import zmq
>>> context = zmq.Context()
>>> socket = context.socket(zmq.PUSH)
>>> socket.connect("tcp://localhost:1212")
>>> command = {"version": 1, "client_name": "test", "ctrl": { "roll": 0.0, "pitch": 0.0, "yaw": 0.0, "thrust": 20.0}}
>>> socket.send_json(command)
You should be able to see the thrust setpoint changing in the client.