Triangulate example for iBeacons

后端 未结 13 2256
梦毁少年i
梦毁少年i 2020-11-28 17:14

I am looking into the possibility to use multiple iBeacons to do a \'rough\' indoor position location. The application is a kind of \'museum\' setting, and it would be easie

相关标签:
13条回答
  • 2020-11-28 18:02

    Here is an open source java library that will perform the trilateration/multilateration: https://github.com/lemmingapex/Trilateration

    It uses a popular nonlinear least squares optimizer, the Levenberg-Marquardt algorithm, from Apache Commons Math.

    double[][] positions = new double[][] { { 5.0, -6.0 }, { 13.0, -15.0 }, { 21.0, -3.0 }, { 12.42, -21.2 } };
    double[] distances = new double[] { 8.06, 13.97, 23.32, 15.31 };
    
    NonLinearLeastSquaresSolver solver = new NonLinearLeastSquaresSolver(new TrilaterationFunction(positions, distances), new LevenbergMarquardtOptimizer());
    Optimum optimum = solver.solve();
    
    // the answer
    double[] calculatedPosition = optimum.getPoint().toArray();
    
    // error and geometry information
    RealVector standardDeviation = optimum.getSigma(0);
    RealMatrix covarianceMatrix = optimum.getCovariances(0);
    

    Most scholarly examples, like the one on wikipedia, deal with exactly three circles and assume perfectly accurate information. These circumstances allow for much simpler problem formulations with exact answers, and are usually not satisfactory for practical situations.

    The problem in R2 or R3 euclidean space with distances that contain measurement error, an area (ellipse) or volume (ellipsoid) of interest is usually obtained instead of a point. If a point estimate is desired instead of a region, the area centroid or volume centroid should be used. R2 space requires at least 3 non-degenerate points and distances to obtain a unique region; and similarly R3 space requires at least 4 non-degenerate points and distances to obtain a unique region.

    0 讨论(0)
  • 2020-11-28 18:02

    I've implemented a very simple Fingerprint algorithm for android 4.4, tested in a relative 'bad' environment:

    • nearly 10 wifi AP nearby.
    • several other Bluetooth signals nearby.

    the accurate seems in 5-8 meters and depends on how I placed that 3 Ibeacon broadcaster. The algorithm is quite simple and I think you can implemented one by yourself, the steps are:

    1. load the indoor map.
    2. sampling with the map for all the pending positioning point.
    3. record all the sampling data, the data should include: map coordinate, position signals and their RSSI.

    so when you start positioning, it's just a reverse of proceeding steps.

    0 讨论(0)
  • 2020-11-28 18:03

    If you're anything like me and don't like maths you might want to do a quick search for "indoor positioning sdk". There's lots of companies offering indoor positioning as a service.

    Shameless plug: I work for indoo.rs and can recommend this service. It also includes routing and such on top of "just" indoor positioning.

    0 讨论(0)
  • 2020-11-28 18:03

    We are also trying to find the best way to precisely locate someone into a room using iBeacons. The thing is that the beacon signal power is not constant, and it is affected by other 2.4 Ghz signals, metal objects etc, so to achieve maximum precision it is necessary to calibrate each beacon individually, and once it has been set in the desired position. (and make some field test to see signal fluctuations when other Bluetooth devices are present). We have also some iBeacons from Estimote (the same of the Konrad Dzwinel's video), and they have already developed some tech demo of what can be done with the iBeacons. Within their App it is possible to see a Radar in which iBeacons are shown. Sometimes is pretty accurate, but sometimes it is not, (and seems phone movement is not being considered to calculate positions). Check the Demo in the video we made here: http://goo.gl/98hiza

    Although in theory 3 iBeacons should be enough to achieve a good precision, maybe in real world situations more beacons are needed to ensure the precision you are looking for.

    0 讨论(0)
  • 2020-11-28 18:03

    The thing that really helped me was this project on Code.Google.com: https://code.google.com/p/wsnlocalizationscala/ it contains lots of code, several trilateration algorithms, all written in C#. It's a big library, but not really meant to be used "out-of-the-box".

    0 讨论(0)
  • 2020-11-28 18:06

    I have been making some experiments to get a precise position using three beacons.

    Results of trilateration

    Unluckily, the results were very disappointing in terms of quality. There were mainly two issues:

    1. In non-controlled environments, where you can find metals, and other objects that affect the signal, the received signal strength of the beacons changes so often that it seems impossible to get error range below 5 meters.
    2. Depending on the way that the user is handling the receiver device, the readings can change a lot as well. If the user puts his/her hand over the bluetooth antenna, then the algorithm will have low signals as input, and thus the beacons will supposed to be very far from the device. See this image to see the precise location of the Bluetooth antenna.

    Possible solutions

    After talking with an Apple engineer who actively discouraged me to go down this way, the option I feel more inclined to use right now is brute force. Try to set up a beacon every X meters (X being the maximum error tolerated in the system) so we can track on this beacons grid the position of a given device by calculating which beacon on the grid is the closest to the device and assuming that the device is on the same position.

    Trilateration algorithm

    However, for the sake of completeness, I share below the core function of the trilateration algorithm. It's based on the paragraph 3 ("Three distances known") of this article.

    - (CGPoint)getCoordinateWithBeaconA:(CGPoint)a beaconB:(CGPoint)b beaconC:(CGPoint)c distanceA:(CGFloat)dA distanceB:(CGFloat)dB distanceC:(CGFloat)dC {
        CGFloat W, Z, x, y, y2;
        W = dA*dA - dB*dB - a.x*a.x - a.y*a.y + b.x*b.x + b.y*b.y;
        Z = dB*dB - dC*dC - b.x*b.x - b.y*b.y + c.x*c.x + c.y*c.y;
    
        x = (W*(c.y-b.y) - Z*(b.y-a.y)) / (2 * ((b.x-a.x)*(c.y-b.y) - (c.x-b.x)*(b.y-a.y)));
        y = (W - 2*x*(b.x-a.x)) / (2*(b.y-a.y));
        //y2 is a second measure of y to mitigate errors
        y2 = (Z - 2*x*(c.x-b.x)) / (2*(c.y-b.y));
    
        y = (y + y2) / 2;
        return CGPointMake(x, y);
    }
    
    0 讨论(0)
提交回复
热议问题