USB Radio: Difference between revisions
Jump to navigation
Jump to search
m Removed tabs on delete radio and param modification |
m Added brief description to Radio init |
||
| Line 6: | Line 6: | ||
=== Radio Initialization === | === Radio Initialization === | ||
The following steps are how to Initialize a Radio. This code is currently run at the start of <code> main </code> in [[eris_vrpn.cpp]]. The process below can be extended to '''any number of Radios''' (currently 2 Radios shown) | |||
:1. Create CrazyRadio Pointers and Crazyflie Pointers | :1. Create CrazyRadio Pointers and Crazyflie Pointers | ||
<blockquote> | <blockquote> | ||
<code> | <code> | ||
<pre> | |||
CCrazyRadio *crRadio1 = 0; | |||
CCrazyRadio *crRadio2 = 0; | CCrazyRadio *crRadio2 = 0; | ||
| Line 17: | Line 19: | ||
CCrazyflie *cflieCopter3 = 0; | CCrazyflie *cflieCopter3 = 0; | ||
CCrazyflie *cflieCopter4 = 0; | CCrazyflie *cflieCopter4 = 0; | ||
</pre> | </pre> | ||
</code> | </code> | ||
Revision as of 18:48, 9 July 2016
The USB Radio Dongle acts as the bridge between the Client and the Firmware. It sends control setpoints generated from the Client to the Firmware controllers, as well as receives sensor data from the Firmware to the Client for logging.
Modifying the Radio
The Radio functions can be found in the CCrazyRadio.cpp source file.
Radio Initialization
The following steps are how to Initialize a Radio. This code is currently run at the start of main in eris_vrpn.cpp. The process below can be extended to any number of Radios (currently 2 Radios shown)
- 1. Create CrazyRadio Pointers and Crazyflie Pointers
CCrazyRadio *crRadio1 = 0; CCrazyRadio *crRadio2 = 0; CCrazyflie *cflieCopter1 = 0; CCrazyflie *cflieCopter2 = 0; CCrazyflie *cflieCopter3 = 0; CCrazyflie *cflieCopter4 = 0;
Note: You must have a pointer for EACH Radio you want to initialize.
- 2. Initialize First CrazyRadio
crRadio1 = new CCrazyRadio(0); // dongle number (starting at 0) if( crRadio1->startRadio() ) //assigns pointer to USB location { cflieCopter1 = new CCrazyflie(crRadio1, 5); //Assigns Crazyflie1 to Radio1 on Channel 5 cflieCopter2 = new CCrazyflie(crRadio1, 80); //Assigns Crazyflie2 to Radio1 on Channel 80 } else { std::cerr << "Could not connect to dongle 1. Did you plug it in?" << std::endl; exit(-1); } usleep(10000);
- 3. Initialize Second CrazyRadio (repeat as necessary...)
crRadio2 = new CCrazyRadio(1); // dongle number if( crRadio2->startRadio() ) { cflieCopter3 = new CCrazyflie(crRadio2, 25); //Assigns Crazyflie3 to Radio2 on Channel 25 cflieCopter4 = new CCrazyflie(crRadio2, 45); //Assigns Crazyflie4 to Radio2 on Channel 45 } else { std::cerr << "Could not connect to dongle 2. Did you plug it in?" << std::endl; exit(-1); } usleep(10000);
- 4. (OPTIONAL) Modify Radio Parameters
crRadio1->setARDTime(2000); //Sets Wait Time (in μs) between Packet Retries (**MUST BE IN INCREMENTS OF 250**) crRadio1->setARC(0); //Sets Number of times Retries Packet Send crRadio1->setPower(P_0DBM); //Sets Radio Power (See CCrazyRadio.h for allowed ENUM values)
- 5. Always Delete Radio Pointers Before Ending Program
delete crRadio1; delete crRadio2;
Note: If you don't delete the pointers then you need to unplug the Radio and plug it back into the USB!