Page 1 of 1

Crazyradio to Crazyradio C / C++ library

Posted: Mon Dec 19, 2016 9:08 pm
by trackedrobot
Hey, I want to convert my robot project controls over to use radio in order to achieve close to real time communication compared to my current method which is wifi.

Does anyone have any resources for how to get the Crazyradio to communicate with other Crazyradio units? I plan on having one plugged into my robot's raspberry pi and one plugged into my control unit (laptop).

Any examples or tutorials showing connection and data transmission would be awesome!

Thanks in advance.

Re: Crazyradio to Crazyradio C / C++ library

Posted: Tue Dec 20, 2016 12:03 am
by whoenig
You would need to put one radio into PRX (primary receiver) mode and another one into PTX (primary transmitter). There is no "full-duplex" communication mode with the NRF-chip. A Python example is available here: https://github.com/bitcraze/crazyradio- ... r/examples. I don't think it is fully implemented in C++, but it is pretty straight forward using libusb. A Crazyradio C++ library is here: https://github.com/whoenig/crazyflie_ro ... yradio.cpp, perhaps not supporting PRX yet. Another C++ library is here: https://github.com/fairlight1337/libcflie.

Re: Crazyradio to Crazyradio C / C++ library

Posted: Tue Dec 20, 2016 12:22 pm
by trackedrobot
Thanks! I'll have a look. These examples seem to be pretty close to what I need. I'll update this thread with my results after I get the units in.

Re: Crazyradio to Crazyradio C / C++ library

Posted: Sat Feb 11, 2017 4:30 pm
by trackedrobot
whoenig wrote:You would need to put one radio into PRX (primary receiver) mode and another one into PTX (primary transmitter). There is no "full-duplex" communication mode with the NRF-chip. A Python example is available here: https://github.com/bitcraze/crazyradio- ... r/examples. I don't think it is fully implemented in C++, but it is pretty straight forward using libusb. A Crazyradio C++ library is here: https://github.com/whoenig/crazyflie_ro ... yradio.cpp, perhaps not supporting PRX yet. Another C++ library is here: https://github.com/fairlight1337/libcflie.
I've taken the existing samples and I've been able to get my robot to communicate with my PC using 2 crazyradio pa dongles.

Question - I'm a bit confused as to why all of the samples require the sending of a 'ping' packet before receiving packets from the other dongle. Does this have to do with the specific protocol bitcraze implemented for these dongles?

My github repo is below for those interested (code is still messy - just got it working).

https://github.com/voidsstr/robot/tree/master/src

The robot:

http://imgur.com/a/zHGgn

Thanks!

Re: Crazyradio to Crazyradio C / C++ library

Posted: Mon Feb 13, 2017 11:55 am
by arnaud
Hi,

Using crazyradio to communicate with a Raspi is really interesting, how it is working? :)

Yes the ping part is just the way we have implemented the protocol. When controlling Crazyflie the PC is the master and sends packet to the quadcopter, the downlink is implemented by piggy-packing data to the radio automatic ack packet. This way the packet synchronisation is made very simple as long as the computer is the sole master.

Another way would be to allow any radio to send a packet when needed, it allows for peer-to-peer communication but makes things more complicated when having only one master since it will increase the risk of collision.

The way to allow any radio to send packet would be to set the Crazyradio in PRX mode by default, when a packet needs to be sent, the crazyradio has to be switched in PTX mode to send the packet and receive the ACK, it can then be switched back to PRX again to be able to receive packets. Anyone in the network will then have this same behavior.

/Arnaud

Re: Crazyradio to Crazyradio C / C++ library

Posted: Mon Feb 13, 2017 1:27 pm
by trackedrobot
arnaud wrote:Hi,

Using crazyradio to communicate with a Raspi is really interesting, how it is working? :)

/Arnaud
Its working great! I wanted better 'real time' communication with my robot (compared to wifi) so I can focus on my navigation code. So far its working very quickly and at a longer range than wifi.

I had it working 2 days ago but for some reason my PRX code is not working anymore so I have to figure out whats going on with that - seems to be getting stuck while waiting for the ACK packet. Anways - so far so good, great product!