Sending commands through client

Discussions about all things Bitcraze
Post Reply
Abanoub.G
Beginner
Posts: 12
Joined: Mon Jan 29, 2018 3:46 pm

Sending commands through client

Post 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
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Sending commands through client

Post 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.
Abanoub.G
Beginner
Posts: 12
Joined: Mon Jan 29, 2018 3:46 pm

Re: Sending commands through client

Post by Abanoub.G »

How would I enable the zmq from the client??
Abanoub.G
Beginner
Posts: 12
Joined: Mon Jan 29, 2018 3:46 pm

Re: Sending commands through client

Post 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
Abanoub.G
Beginner
Posts: 12
Joined: Mon Jan 29, 2018 3:46 pm

Re: Sending commands through client

Post 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
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Sending commands through client

Post 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.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Sending commands through client

Post 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.
Post Reply