USB Radio: Difference between revisions

From Distributed Autonomous and Networked Control Lab
Jump to navigation Jump to search
Jnoronha (talk | contribs)
Page setup and adding basic info
 
Jnoronha (talk | contribs)
Added first 3 steps of radio initialization
Line 3: Line 3:


== Modifying the Radio ==
== Modifying the Radio ==
The Radio functions can be found in the CCrazyRadio.cpp source file.  
The Radio functions can be found in the [[CCrazyRadio.cpp]] source file.  
 
=== Radio Initialization ===
:1. Create CrazyRadio Pointers and Crazyflie Pointers
<blockquote>
<code>
 
''CCrazyRadio *crRadio1 = 0;<br/>''
''CCrazyRadio *crRadio2 = 0;<br/>''
<br/>
''CCrazyflie *cflieCopter1 = 0;''<br/>
''CCrazyflie *cflieCopter2 = 0;''<br/>
''CCrazyflie *cflieCopter3 = 0;''<br/>
''CCrazyflie *cflieCopter4 = 0;''<br/>
 
</code>
</blockquote>
'''Note:''' You must have a pointer for EACH Radio you want to initialize.
 
:2. Initialize First CrazyRadio
 
<blockquote>
<code>
crRadio1 = new CCrazyRadio(0);  // dongle number (starting at 0)<br/>
if( crRadio1->startRadio() )  //assigns pointer to USB location<br/>
{<br/>
cflieCopter1 = new CCrazyflie(crRadio1, 5);  //Assigns Crazyflie1 to Radio1 on Channel 5 <br/>
cflieCopter2 = new CCrazyflie(crRadio1, 80);  //Assigns Crazyflie2 to Radio1 on Channel 80<br/>
}<br/>
else <br/>
{ <br/>
        std::cerr << "Could not connect to dongle 1. Did you plug it in?" << std::endl; <br/>
        exit(-1); <br/>
} <br/>
usleep(10000);<br/>
<br/>
</code>
</blockquote>
:3. Initialize Second CrazyRadio (repeat as necessary...)
 
<blockquote>
<code>
crRadio2 = new CCrazyRadio(1); // dongle number<br/>
<br/>
if( crRadio2->startRadio() ) <br/>
{ <br/>
cflieCopter3 = new CCrazyflie(crRadio2, 25); <br/>
cflieCopter4 = new CCrazyflie(crRadio2, 45); <br/>
} <br/>
else <br/>
{ <br/>
        std::cerr << "Could not connect to dongle 2. Did you plug it in?" << std::endl; <br/>
        exit(-1); <br/>
} <br/>
 
usleep(10000);
</code>
</blockquote>


=== Changing Radio Channel ===
=== Changing Radio Channel ===

Revision as of 18:24, 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

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);
cflieCopter4 = new CCrazyflie(crRadio2, 45);
}
else
{
std::cerr << "Could not connect to dongle 2. Did you plug it in?" << std::endl;
exit(-1);
}

usleep(10000);

Changing Radio Channel