AltBeacon Library shows beacons only once and then stops showing them - altbeacon

I experience an issue and can reproduce it on different devices with different Android OS.
I get the expected behaviour with iBeacon scanning for the first time. When I scan the next time I get no Beacons. The result list in delegate is empty. I printed a count on the setRangeNotifier with the size of the beacons but apparently after it only shows the beacons size to be 1 for the first time after which it continually displays a 0.
beaconManager.setRangeNotifier(new RangeNotifier() {
#Override
public void didRangeBeaconsInRegion(final Collection<Beacon> beacons, Region region) {
Log.d("Beacons count",beacons.size());
}
});
Output:
Beacons Count 1
Beacons Count 0
Beacons Count 0
Beacons Count 0
My ranging period and scanning period is as below
beaconManager.setBackgroundScanPeriod(1000l);
beaconManager.setBackgroundBetweenScanPeriod(31000l);

I have tried to reproduce the symptoms you describe, but have been unable to do so on a Nexus 5 with Android 5 and a transmitting RadBeacon USB.
Reference application modifications:
Added these lines to the BeaconReferenceApplication onCreate() method:
beaconManager.setBackgroundBetweenScanPeriod(1000l);
beaconManager.setBackgroundBetweenScanPeriod(31000l);
beaconManager.setAndroidLScanningDisabled(true);
BeaconManager.setDebug(true);
The third line above is needed because I was testing on a Nexus 5 with Android 5 and I wanted to exercise the 4.x scanning APIs,
like you would be done on a 4.4 phone.
Added this line to the RangingActivity didRangeBeaconsInRegion callback:
Log.d(TAG, "ranged beacon: "+firstBeacon.toString());
Testing steps:
Enable a RadBeacon USB transmitting at 10 HZ.
Log the results with:
$ /Users/dyoung/sdk-android-studio/platform-tools/adb logcat -v time | grep "anged beacon"
Run the reference app, started ranging in the foreground, and after three seconds put it into the background. See the following logging results:
03-01 08:39:00.146 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
03-01 08:39:01.282 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
03-01 08:39:02.482 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
03-01 08:39:03.515 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
03-01 08:39:12.148 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
03-01 08:39:44.274 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
03-01 08:40:16.179 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
03-01 08:40:48.239 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
03-01 08:41:20.272 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
03-01 08:41:52.205 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
03-01 08:42:24.202 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
As you can see, the callbacks come every 1.1 seconds in the foreground, and every 32 seconds in the background. This is as expected.
If you cannot repeat the above steps using the reference application on the OnePlus device with Cyanogenmod 4.4, then the issue may be with the ROM for that device. If you can confirm this
and capture a full Logcat output for the period where the callbacks don't come (with debug turned on as described above), then please open an issue at http://github.com/AltBeacon/android-beacon-library/issues and attach a copy of the log capture.

This is not expected behavior, and I have not seen this on Android 4.4 on other devices. Based on limited information, it is possible it could be an app issue, or it may be an issue with the 4.4 CynogenMod ROM for the One Plus. See my other answer with a detailed test case for a reference device (Nexus 5).
To eliminate the possibility of an app issue, try using the Locate app, which is based on the same library and see if you get the same results.

Upon further reflection I think it is the scan intervals that were the problem. The scan intervals reported were to spend 1 second looking for beacons every 32 seconds. This is not enough of a duty cycle, especially for beacons that transmit at only 1Hz. Not all transmissions are received due to radio noise, and it is important that scan durations be 1100 ms or more in order to prevent the transmission from straddling the boundary where the scanner is starting up or shutting down.

Related

Which Feature Selection Techniques for NLP is this represent

I have a dataset that came from NLP for technical documents
my dataset has 60,000 records
There are 30,000 features in the dataset
and the value is the number of repetitions that word/feature appeared
here is a sample of the dataset
RowID Microsoft Internet PCI Laptop Google AWS iPhone Chrome
1 8 2 0 0 5 1 0 0
2 0 1 0 1 1 4 1 0
3 0 0 0 7 1 0 5 0
4 1 0 0 1 6 7 5 0
5 5 1 0 0 5 0 3 1
6 1 5 0 8 0 1 0 0
-------------------------------------------------------------------------
Total 9,470 821 5 107 4,605 719 25 8
Appearance
There are some words that only appeared less than 10 times in the whole dataset
The technique is to select only words/features that appeared in the dataset for more than a certain number (say 100)
what is this technique called? the one that only uses features that in total appeared more than a certain number.
This technique for feature selection is rather trivial so I don't believe it has a particular name beyond something intuitive like "low-frequency feature filtering", "k-occurrence feature filtering" "top k-occurrence feature selection" in the machine learning sense; and "term-frequency filtering" and "rare word removal" in the Natural Language Processing (NLP) sense.
If you'd like to use more sophisticated means of feature selection, I'd recommend looking into the various supervised and unsupervised methods available. Cai et al. [1] provide a comprehensive survey, if you can't access the article, then this page by JavaTPoint covers some of the supervised methods. A quick web search for supervised/unsupervised feature selection also yields many good blogs, most of which make use of the sciPy and sklean Python libraries.
References
[1] Cai, J., Luo, J., Wang, S. and Yang, S., 2018. Feature selection in machine learning: A new perspective. Neurocomputing, 300, pp.70-79.

SocketCAN error-passive with RevPi CAN Connect. Hardware or Software issue?

We have bought a CAN Connect module for our Revpi Connect, and set it up as can been seen in this thread on the Kunbus forum. As far as we understand this will provide the proper termination.
We have also followed this guide provided by Revolution PI.
When checking that the drivers for the CAN module is properly loaded, everything looks fine:
$ dmesg | grep can
[ 4.616900] hi3110 spi0.0 can0: 3110 successfully initialized.
[ 107.049422] IPv6: ADDRCONF(NETDEV_UP): can0: link is not ready
[ 107.049463] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
Checking ip statistics gives this result:
$ ip -det -statistics link show can0
5: can0: mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
link/can promiscuity 0
can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
bitrate 50000 sample-point 0.875
tq 1250 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
hi3110: tseg1 2..16 tseg2 2..8 sjw 1..4 brp 1..64 brp-inc 1
clock 16000000
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 0 0 0 0 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
RX: bytes packets errors dropped overrun mcast
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
However, when we turn on candump and send a message using cansend, candump does not show any traffic.
If we check dmesg for CAN again, we get this result:
$ dmesg | grep can
[ 4.616900] hi3110 spi0.0 can0: 3110 successfully initialized.
[ 107.049422] IPv6: ADDRCONF(NETDEV_UP): can0: link is not ready
[ 107.049463] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
[ 292.285353] can: controller area network core (rev 20170425 abi 9)
[ 292.297811] can: raw protocol (rev 20170425)
And if we check ip -statistics again, we can see that the state of the connection has gone into ERROR-PASSIVE:
$ ip -det -statistics link show can0
5: can0: mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
link/can promiscuity 0
can state ERROR-PASSIVE (berr-counter tx 128 rx 0) restart-ms 0
bitrate 50000 sample-point 0.875
tq 1250 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
hi3110: tseg1 2..16 tseg2 2..8 sjw 1..4 brp 1..64 brp-inc 1
clock 16000000
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 0 0 1 1 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
RX: bytes packets errors dropped overrun mcast
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
We are trying to communicate with a computer with and Ixxat USB2CAN v2, at 50kbps, with both highspeed and FT settings, but nothing seems to work. Resetting the connection, seems to put it back into ERROR-ACTIVE state.
When trying to communicate with mentioned computer, using another computer with Socketcan and another Ixxat USB2CAN v2 device, everything works fine.
I should perhaps also mention that if we turn loopback on, we can see the messages we are sending.
We are struggling to understand whether this a hardware or software error. Is our termination in order? Are there any magical settings in SocketCAN we have overlooked? Where should we start debugging this issue?
Any help would be greatly appreciated.
As it turns out, the schematic printed directly on the device is wrong.The schematic on their website is correct.
Hopefully this can help someone else avoid pulling their hair out in the future.

Perform basic arithmetic operations on AudioKit FM oscillator parameters: Interpolation & time Transition

Does AudioKit provide a method to calculate interpolated values of discrete array members?
Does AudioKit provide a method to smooth transition operation between parameters of an oscillator like baseFrequency, AKOperation.periodicTrigger or hold?
Below the code I use for FM generation:
let oscillator = AKOperation.fmOscillator(baseFrequency: Synth.frequency,
carrierMultiplier: 2,
modulatingMultiplier: 0.8,
modulationIndex: 1,
amplitude: Synth.amplitude.triggeredWithEnvelope(
trigger: AKOperation.periodicTrigger(period: Synth.cyclic),
attack: 0.01,
hold: Synth.hold,
release: 0.01))
For input parameter interpolated values of Frequency Cycle and Duty shall be calculated by interpolation based on the table (array) below:
P1 Freq. Cycle Duty %
-10 200 100 100
-3.04 405 100 100
-0.51 300 500 100
-0.50 200 800 5
0.09 400 600 10
0.10 400 600 50
1.16 550 552 52
2.67 763 483 55
4.24 985 412 58
6.00 1234 322 62
8.00 1517 241 66
10.00 1800 150 70
The transition of values (for Freq., Cycle ans Duty) shall be smoothen based on input parameter P1. Is this what AKComputedParameter e.g. smoothDelay is made for?
How do I tell AudioKit to apply AKComputedParameter?
Do you have a sample code (code snippet) for achievement of interpolation/transition operation with application to oscillator based on the code above? Either based on AK or vDSP methods.
I’m not quiet sure on how to apply https://audiokit.io/docs/Protocols/AKComputedParameter.html
I think this question was downvoted somewhat because it seems like you're asking for too much of an actual implementation with that table of values. I'm going to ignore that and say that however you decide to change the parameters of the oscillator in your app logic, you can make the transitions smooth by portamento'ing the values.
So, in your case for frequency you would replace Synth.frequency with a parameter you set that you would then portamento like AKOperation.parameters[0].portamento(halfTime: 0.5)
See an example for using parameters here: https://audiokit.io/playgrounds/Synthesis/Plucked%20String%20Operation/

Multi-class classification in sparse dataset

I have a dataset of factory workstations.
There are two types of error in same particular time.
User selects error and time interval (dependent variable-y)
Machines produces errors during production (independent variables-x)
User selected error types are 8 unique in total so I tried to predict those errors using machine-produced errors(total 188 types) and some other numerical features such as avg. machine speed, machine volume, etc.
Each row represents user-selected error in particular time;
For example in first line user selects time interval as:
2018-01-03 12:02:00 - 2018-01-03 12:05:37
and m_er_1(machine error 1) also occured in same time interval 12 times.
m_er_1_dur(machine error 1 duration) is total duration of machine error in seconds
So I matched those two tables and looks like below;
user_error m_er_1 m_er_2 m_er_3 ... m_er_188 avg_m_speed .. m_er_1_dur
A 12 0 0 0 150 217
B 0 0 2 0 10 0
A 3 0 0 6 34 37
A 0 0 0 0 5 0
D 0 0 0 0 3 0
E 0 0 0 0 1000 0
In the end, I have 1900 rows 390 rows( 376( 188 machine error counts + 188 machine error duration) + 14 numerical features) and due to machine errors it is a sparse dataset, lots of 0.
There a none outliers, none nan values, I normalized and tried several classification algorithms( SVM, Logistic Regression, MLPC, XGBoost, etc.)
I also tried PCA but didn't work well, for 165 components explained_variance_ratio is around 0.95
But accuracy metrics are very low, for logistic regression accuracy score is 0.55 and MCC score around 0.1, recall, f1, precision also very low.
Are there some steps that I miss? What would you suggest for multiclass classification for sparse dataset?
Thanks in advance

Feature engineering, handling missing data

Consider this data table
NumberOfAccidents MeanDistance
1 5
3 0
0 NA
0 NA
6 1.2
2 0
the first feature is the number of accidents and the second is the average distance of these accidents to a certain point. It is obvious for a record with zero accident, there won't be a value for MeanDistance. However, imputing these missing values are not logical!
MY SOLUTION: I have decided to discretize the MeanDistance with NAs being a level (bin) and the rest of the data being in bins like: [0,1), [1,2.5), [2.5, Inf). the final table will look like this:
NumberOfAccidents NAs first_bin sec_bin third_bin
1 0 0 0 1
3 0 1 0 0
0 1 0 0 0
0 1 0 0 0
6 0 0 1 0
2 0 1 0 0
What is your idea with these types of missing values that cannot be imputed?
what is your solution to this problem?
It really depends on the domain and what you are trying to predict. Even though your solution is fine, I wouldn't bin the rest of the data as you did. Giving that the NumberOfAccidents feature already tells what MeanDistance have NA values, I would probably just impute 0 into the NA values (for computations) and leave the rest of the data as it is.
Nevertheless, there is no need to limit yourself, just try different approaches and keep the one that boost your KPI (Key Performance Indicator).

Resources