How to setup two USRPs B210 in GNU Radio - gnuradio

I am trying to setup two USRP B210 with external Octoclock in GNU Radio in order to achieve 4 RX channels.
What is the right way?
1.One USRP source with Num Mboards = 2, and Num Channels = 4.
or
2.Two USRP source, each with Num Mbords = 1, and Num Channels = 2.

1.One USRP source with Num Mboards = 2, and Num Channels = 4.
Probably can't do that, UHD's multi_usrp doesn't deal with multiple b2xx devices, so only your other option
2.Two USRP source, each with Num Mbords = 1, and Num Channels = 2.
works.

Related

How to Optimize an Overuse of If Statements in Roblox Studio

The goal of this code is to spawn a ball "GlowyBall" in 1 of 5 preset locations randomly. This script activates when a player hits a button. The ball also needs to spawn as 1 of 3 colors randomly. The code works for the most part, but I am struggling when it comes to making this code optimized. I don't know which datatype I should or even can use to replace these if statements. I am just trying to learn different avenues that can be taken. The reason this code needs to be optimized is that it could be used thousands of times per minute, and I don't want the game to be held back by the code.
...
-- Says that there will be 3 colors
local ColorRange = 3
-- Says that there will be 5 spawn locations
local range = 5
-- Makes the code run continuously
while true do
local ColorNumber = math.random(1, ColorRange)
local Number = math.random(1, range)
-- Chooses the random color
if ColorNumber == 1 then
game.ServerStorage.GlowyBallsSideA.GlowyBallGroup1.Glowyball1.Color = Color3.new(1, 0, 0)
end
if ColorNumber == 2 then
game.ServerStorage.GlowyBallsSideA.GlowyBallGroup1.Glowyball2.Color = Color3.new(0, 1, 0)
end
if ColorNumber == 3 then
game.ServerStorage.GlowyBallsSideA.GlowyBallGroup1.Glowyball3.Color = Color3.new(0, 0, 1)
end
-- Chooses which ball will get cloned
if Number == 1 then
ClonePart = game.ServerStorage.GlowyBallsSideA.GlowyBallGroup1.Glowyball1
end
if Number == 2 then
ClonePart = game.ServerStorage.GlowyBallsSideA.GlowyBallGroup1.Glowyball2
end
if Number == 3 then
ClonePart = game.ServerStorage.GlowyBallsSideA.GlowyBallGroup1.Glowyball3
end
if Number == 4 then
ClonePart = game.ServerStorage.GlowyBallsSideA.GlowyBallGroup1.Glowyball4
end
if Number == 5 then
ClonePart = game.ServerStorage.GlowyBallsSideA.GlowyBallGroup1.Glowyball5
end
wait(.6)
local Clone = ClonePart:Clone()
script.Parent.ClickDetector.MouseClick:connect(function()
Clone.Parent = game.Workspace
Clone.Anchored = false
end)
end
...
I am fairly new to programming as a whole so feel free to teach me a few things, thanks.
Instances in Roblox can be accessed in a few different ways; the most common is dot notation (eg. game.Workspace.Part). It's also possible to access instances like items in a table (eg. game["Workspace"]["Part"]). This is useful when accessing an instance with a space in its name, or to add something to the start/end of a string before accessing it.
The if statements for choosing which ball to clone can then be reduced to the following:
-- Chooses which ball will get cloned
ClonePart = game.ServerStorage.GlowyBallsSideA.GlowyBallGroup1["Glowyball" .. Number] -- Add Number to the end of "Glowyball" before accessing it
The same could be done with choosing the random color, as well as substituting multiple if statements for one if-elseif statement could make the code more readable.
-- Chooses the random color
local Glowyball = game.ServerStorage.GlowyBallsSideA.GlowyBallGroup1["Glowyball" .. ColorNumber]
if ColorNumber == 1 then
Glowyball.Color = Color3.new(1, 0, 0)
elseif ColorNumber == 2 then
Glowyball.Color = Color3.new(0, 1, 0)
elseif ColorNumber == 3 then
Glowyball.Color = Color3.new(0, 0, 1)
end
Heliodex did a good job explaining how to simplify finding the instances, but you could take it a step further and remove the if-statements entirely by replacing them with arrays.
Typically, from a general programming standpoint, when you find that you have a lot of very similar if-statements, the solution is to use a switch-statement instead of if-elseif chains. Switch statements allow you to define a bunch of possible cases and when it executes, it will jump specifically to the case that matches. However, neither lua nor luau support switch statements, but we can get the benefit of switch-statements.
Since you are using random numbers already, you can pre-define your colors into an array and have the random number simply pick an index to use...
-- make some colors to pick from
local colors = {
Color3.new(1, 0, 0),
Color3.new(0, 1, 0),
Color3.new(0, 0, 1),
}
-- Set up the list of spawn locations
local locationGroup = game.ServerStorage.GlowyBallsSideA.GlowyBallGroup1
local spawnLocations = {
locationGroup.Glowyball1,
locationGroup.Glowyball2,
locationGroup.Glowyball3,
locationGroup.Glowyball4,
locationGroup.Glowyball5,
}
-- could this be simplified to ...?
-- local spawnLocations = locationGroup:GetChildren()
-- when someone clicks the button, spawn the part
script.Parent.ClickDetector.MouseClick:Connect(function()
-- choose a color and spawn location
local colorNumber = math.random(1, #colors)
local spawnNumber = math.random(1, #spawnLocations)
local clonePart = spawnLocations[spawnNumber]
local color = colors[colorNumber]
-- spawn it
local clone = clonePart:Clone()
clone.Color = color
clone.Parent = game.Workspace
clone.Anchored = false
end)
The advantage of this approach is that you can simply add more colors and spawn locations to those arrays, and the rest of your code will still work.

STM32f4 HID receive data

How to receive OUT report data from HOST PC in STM32f407 discovery board running as HID(USB) in device mode?
Is it possible?
I am thinking to send data from host using hidapi.
There is an official USB library. It is not easy, but you may try to run the examples and adapt them to your needs.
http://www.st.com/en/embedded-software/stsw-stm32046.html
Be careful with clock settings. I experienced problems with that. Here are the values I setup in system_stm32f4.c:
HSE = 8000000
PLL_M = 8
PLL_Q = 7
PLL_N = 336
PLL_P = 4
HSE is the crystal on the board. It replaces the embedded clock on the MCU. The other settings are slightly different from the values in the original configuration file. Here are the calculations of the different clocks:
PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
= 8000000 / 8 * 336 = 336000000
USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ
= 336000000 / 7
= 48000000
SYSCLK = PLL_VCO / PLL_P
= 336000000 / 4
= 84000000
HCLK = SYSCLK / 1
= 84000000
PCLK2 = HCLK / 1
= 84000000
PCLK1 = HCLK / 2
= 84000000 / 2
= 42000000
The “USB OTG FS” clock HAS to be >= 48MHz if you use USB FS. Otherwise the device won't be recognized.

How to make training and testing data files for LIBSVM and/or TinySVM

when I open the sample files for training data of LIBSVM, I can't understand the file structure. Can someone please show me how to make it ?
Below is my training data to predict song writers of a song(as an example):
Feature 1: Number of "love" word in the lyric
Feature 2: Number of "friend" word in the lyric
Feature 3: Number of "zone" word in the lyrics
Training data:
Song A (3, 0, 0), song writer is David
Song B (0, 3, 1), song writer is Peter
Song C (1, 3, 1), song writer is Tom
Testing data:
Song D (3, 0, 1)
Thank you very much.
Libsvm ReadMe file can help you
The training data must be something like this
label feature1:value1 feature2:value2 ..... -1:? (? can be any number)
but in the Libsvm there is something called svm_node that do the same thing:
sample code in java:
for (int k = 0; k < dataCount; k++) {
prob.x[k] = new svm_node[features.length];
for (int j = 0; j < features.length; j++) {
svm_node node = new svm_node();
node.index = featuresIndex[j];
node.value = features[j];
prob.x[k][j] = node;
}
prob.y[k] = lable;
}
In this problem of classification we have three classes for our whole dataset David, Peter, Tom and we assign them values 0, 1 and 2 receptively.
The format of data set will be.
[label] [feature number] : [the no of times that feature occurs] .... ....
Our training data file will look like this.
0 1:3 2:0 3:0
1 1:0 3:1 3:1
2 1:1 2:3 3:1
This file can be used to train our model. In this file there are 3 rows and four columns, the first column represents the actual result and the other columns represent the feature number : the number of times that feature occurs.
The testing data will be treated as.
1:3 2:0 3:1
this will be passed to svm model and then prediction can be drawn.

What is the most elegant way to pick a random value from a set defined in NS_OPTION in objective-c?

I have an NS_OPTION that I'm defining as such :
typedef NS_OPTIONS(NSInteger, PermittedSize) {
SmallSize = 1 << 0,
MediumSize = 1 << 1,
LargeSize = 1 << 2
};
And later I set the values I need :
PermittedSize size = SmallSize | MediumSize;
I'm using it to randomly generate an various objects of small and medium sizes(duh) for a particular level of a game.
What is the best way to go about selecting which size of an object to generate? Meaning, I'd like to choose randomly for each object I'm generating whether it will be one of the 2 options allowed (small and medium in this case). Normally I would use an arc4random function with the range of numbers I need - but in this case, how can it be done with bits? (and then mapped back to the values of the PermittedSize type?
Use the result from arc4random to determine the amount of bit shifting you want to do. Something like this:
int bitShiftAmount = arc4random_uniform(numberOfPermittedSizes);
PermittedSize size = 1 << bitShiftAmount;
You are still working with integers. SmallSize is 1. MediumSize is 2. And LargeSize is 4.
So pick a random number from 1 to 3. 1 is small, 2 is medium, 3 is both.
Once you have a random number, assign it.
NSInteger val = arc4random_uniform(3) + 1; // give 1-3
PermittedSize size = (PermittedSize)val;

GPS sentence: GPRMA

I'm writting a NMEA sentences parser, and couldn't find ant documentation about GPRMA sentence except that it is: "Recommended minimum specific Loran-C data". does anyone know what is the meaning of this sentence?
does the longitude and latitude in it refer to the gps device current location?
thanks
From the very handy guide at http://aprs.gids.nl/nmea/#rma:
eg. $GPRMA,A,llll.ll,N,lllll.ll,W,,,ss.s,ccc,vv.v,W*hh
1 = Data status
2 = Latitude
3 = N/S
4 = longitude
5 = W/E
6 = not used
7 = not used
8 = Speed over ground in knots
9 = Course over ground
10 = Variation
11 = Direction of variation E/W
12 = Checksum
Now, LORAN data is not GPS. It is similar, but an old standard of ground stations that were used to find positions. So to specifically answer your question, no, this is not GPS data. If you want GPS data, you will need $GPRMC.