Control of Crazyflie through Labview

Firmware/software/electronics
Post Reply
jesslarkan
Beginner
Posts: 13
Joined: Sun Jul 22, 2018 8:08 am

Control of Crazyflie through Labview

Post by jesslarkan » Thu Aug 23, 2018 7:26 am

Hi there,

I am very new to programming Crazyflies and would really appreciate a bit of information on trying to achieve communication with a Crazyflie 2.0 through NI Labview.

I have successfully connected to the Crazyradio PA dongle using NI-VISA, however, I am struggling to understand and dissect the radio protocol.
I have monitored the raw data being sent to the drone from connection, to adjusting the pitch/yaw/roll/thrust params, to disconnection. However, I cannot fit this into the protocol given here:
https://wiki.bitcraze.io/doc:crazyradio:usb:index

The protocol seems to be more high level and I am struggling to determine how to reverse engineer what I am reading. Can anyone point me in the direction of examples or some raw code and its relation to the wiki document?

Any help would be greatly appreciated, thanks.

arnaud
Bitcraze
Posts: 1779
Joined: Tue Feb 06, 2007 12:36 pm

Re: Control of Crazyflie through Labview

Post by arnaud » Thu Aug 23, 2018 8:00 am

Hi,

The page you are using is the usb radio protocol is required to send/receive packet over radio. Once you can do that you can start implementing the CRTP protocol that is used to communicate with Crazyflie: https://wiki.bitcraze.io/doc:crazyflie:crtp:index. The commander packet is the one that is used for controlling thrust/roll/pitch/way.

Another solution would be to use the ZMQ python client: there is a python-implemented ZMQ client that would allow you to connect, control and get log telemetry from the Crazyflie just by sending and receiving JSON messages. There seems to be a zmq lib for labview: http://labview-zmq.sourceforge.net/ and the zmq server is documented in the wiki: https://wiki.bitcraze.io/doc:crazyflie: ... fzmq:index. Depending of what you want to do this should be a quicker way to get started.

jesslarkan
Beginner
Posts: 13
Joined: Sun Jul 22, 2018 8:08 am

Re: Control of Crazyflie through Labview

Post by jesslarkan » Mon Aug 27, 2018 6:15 am

Hi Arnaud,

Thanks so much for the speedy reply, I have been looking into the packet structures and think I have found a way to rephrase my question:

Within the radio protocol document there is this packet structure:

0x40 START_SCAN_CHANNELS (0x21) Start Stop Length Packet

My question is - is this the packet where, after configuration (setting up the channels, etc) the data/CRTP packet (such as controlling the parameters - pitch/yaw/etc) fits in? I am trying to determine the final packet format. So for example, I would send the packet mentioned above, with the commander packet in the "packet" space.

Sorry I have little experience with the USB protocol and am trying to understand where the packets fit in, if I was to replicate this structure within Labview.

Thanks so much.

Jess

arnaud
Bitcraze
Posts: 1779
Joined: Tue Feb 06, 2007 12:36 pm

Re: Control of Crazyflie through Labview

Post by arnaud » Mon Aug 27, 2018 9:46 am

The SCAN USB command is one that you do not need, not as a first approach at least.

To send and receive radio packet you need to use the bulk endpoints following this procedures: https://wiki.bitcraze.io/doc:crazyradio ... a_transfer. This will allow you to send packets to the Crazyflie and receive packets from it. Packet from the Crazyflie to the PC are sent in the ACK radio packet, so if you want to implement a continious bidirectional connection you need to send packets to the Crazyflie at regular intervals, we send the NULL CRTP packet port 15 channel 3 for that.

Once you can send and receive packet, the content of the data is CRTP. The first byte is a header packing port and channels, and the following bytes encodes the crtp packet data.

One suggestion I would have is to look at the Python implementation of the Crazyradio driver: the packet transfer function is there: https://github.com/bitcraze/crazyflie-l ... io.py#L269. Generally you can port each method of this python file into a labviview block and you would be done with the Crazyradio driver.

jesslarkan
Beginner
Posts: 13
Joined: Sun Jul 22, 2018 8:08 am

Re: Control of Crazyflie through Labview

Post by jesslarkan » Tue Sep 11, 2018 9:07 am

I have successfully achieved communication with the Crazyradio through Labview - control and bulk transfers are taking place and the Crazyflie will respond with messages such as "Crazyflie 2.0 is up and running!". These messages come through when any bulk transfers take place and the device is starting up. However, I am struggling to receive responses specific to messages such as commander or null packets. The flie will only send (01 f7 01 2c) or (01 fc 01 2c) translating to ÷, (ASCII) and similar characters on receipt. I believe this is to do with where the packets are being sent - control transfers reach the same destination as original operation (addresses such as 1.6.1, but these vary each time I plug the device in again - this is fine), however, bulk transfers go to this same address. In normal operation through the Crazyflie client, these bulk transfers go to the address 1.255.1. I believe this is the source of my issues.

Would the Labview driver be the controller of where these messages are sent to? If I was to edit this to send the bulk transfers to 1.255.1, the same as the original Crazyflie driver, where in the code would I find this part of the original driver? Do you think this is the source of my problem?

Thanks again, I am looking through the code and am just trying to target the problem. The Crazyflie can send and receive from the Labview program but the messages it sends back are not what I am expecting. Any help is really appreciated, I am fairly new to USB comms.

Jess

jesslarkan
Beginner
Posts: 13
Joined: Sun Jul 22, 2018 8:08 am

Re: Control of Crazyflie through Labview

Post by jesslarkan » Tue Sep 11, 2018 3:03 pm

Never mind, I seem to have fixed my issue above. The problem may occur again but at the moment I can work with what I have. Thanks again Arnaud.

Jess

Post Reply