Crazyradio to Crazyradio C / C++ library

Firmware/software/electronics/mechanics
Post Reply
trackedrobot
Beginner
Posts: 5
Joined: Mon Dec 19, 2016 9:04 pm

Crazyradio to Crazyradio C / C++ library

Post by trackedrobot » Mon Dec 19, 2016 9:08 pm

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.



whoenig
Expert
Posts: 310
Joined: Mon Oct 27, 2014 2:55 am

Re: Crazyradio to Crazyradio C / C++ library

Post by whoenig » Tue Dec 20, 2016 12:03 am

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.

trackedrobot
Beginner
Posts: 5
Joined: Mon Dec 19, 2016 9:04 pm

Re: Crazyradio to Crazyradio C / C++ library

Post by trackedrobot » Tue Dec 20, 2016 12:22 pm

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.

trackedrobot
Beginner
Posts: 5
Joined: Mon Dec 19, 2016 9:04 pm

Re: Crazyradio to Crazyradio C / C++ library

Post by trackedrobot » Sat Feb 11, 2017 4:30 pm

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!

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

Re: Crazyradio to Crazyradio C / C++ library

Post by arnaud » Mon Feb 13, 2017 11:55 am

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

trackedrobot
Beginner
Posts: 5
Joined: Mon Dec 19, 2016 9:04 pm

Re: Crazyradio to Crazyradio C / C++ library

Post by trackedrobot » Mon Feb 13, 2017 1:27 pm

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!

Post Reply