iBeacon三角定位示例

77

我正在研究使用多个iBeacon进行“粗略”的室内位置定位的可能性。该应用程序是一种“博物馆”设置,如果能够形成一个带有不同对象位置的网格,则会更容易,而不是单个信标(尽管这也可能不可能)。

是否有使用多个信标三角定位到某种位置或某种逻辑的实例和经验,可以帮助我自己编写代码?


5
请查看我的演示:https://www.youtube.com/watch?v=dMWEl6GBGqk 。在评论区中,您会发现Jakub Krzych的回复,他的公司生产了我正在使用的信标。 - Konrad Dzwinel
谢谢,这非常有用。如果Estimote将发布API,那么我可能会等待并查看它的工作方式,而不是自己研究数学,并尝试按评论中建议的方式动态校准和纠正信标。 - Luuk D. Jansen
@LuukD.Jansen 我也在关注这个问题... 有什么消息吗? - Leonardo
我还没有进一步研究它。我认为在我需要的规模(楼层空间)上,三角定位将无法足够精确。在所有重要位置放置信标会更容易/更便宜。 - Luuk D. Jansen
13个回答

2

1

我发现Vishnu Prahbu的解决方案非常有用。如果有人需要,我将其移植到C#。

public static PointF GetLocationWithCenterOfGravity(PointF a, PointF b, PointF c, float dA, float dB, float dC)
    {
        //https://dev59.com/22Ij5IYBdhLWcg3wYUGQ
        var METERS_IN_COORDINATE_UNITS_RATIO = 1.0f;

        //https://dev59.com/jXRB5IYBdhLWcg3wv5tA#524770
        //Find Center of Gravity
        var cogX = (a.X + b.X + c.X) / 3;
        var cogY = (a.Y + b.Y + c.Y) / 3;
        var cog = new PointF(cogX,cogY);

        //Nearest Beacon
        PointF nearestBeacon;
        float shortestDistanceInMeters;
        if (dA < dB && dA < dC)
        {
            nearestBeacon = a;
            shortestDistanceInMeters = dA;
        }
        else if (dB < dC)
        {
            nearestBeacon = b;
            shortestDistanceInMeters = dB;
        }
        else
        {
            nearestBeacon = c;
            shortestDistanceInMeters = dC;
        }

        //http://www.mathplanet.com/education/algebra-2/conic-sections/distance-between-two-points-and-the-midpoint
        //Distance between nearest beacon and COG
        var distanceToCog =  (float)(Math.Sqrt(Math.Pow(cog.X - nearestBeacon.X, 2)
                + Math.Pow(cog.Y - nearestBeacon.Y, 2)));

        //Convert shortest distance in meters into coordinates units.
        var shortestDistanceInCoordinationUnits = shortestDistanceInMeters * METERS_IN_COORDINATE_UNITS_RATIO;

        //http://math.stackexchange.com/questions/46527/coordinates-of-point-on-a-line-defined-by-two-other-points-with-a-known-distance?rq=1
        //On the line between Nearest Beacon and COG find shortestDistance point apart from Nearest Beacon
        var t = shortestDistanceInCoordinationUnits / distanceToCog;
        var pointsDiff = new PointF(cog.X - nearestBeacon.X, cog.Y - nearestBeacon.Y);
        var tTimesDiff = new PointF(pointsDiff.X * t, pointsDiff.Y * t);

        //Add t times diff with nearestBeacon to find coordinates at a distance from nearest beacon in line to COG.
        var userLocation = new PointF(nearestBeacon.X + tTimesDiff.X, nearestBeacon.Y + tTimesDiff.Y);

        return userLocation;
    }

0

备选方程式

- (CGPoint)getCoordinateWithBeaconA:(CGPoint)a beaconB:(CGPoint)b beaconC:(CGPoint)c distanceA:(CGFloat)dA distanceB:(CGFloat)dB distanceC:(CGFloat)dC {


CGFloat x, y;
x = ( ( (pow(dA,2)-pow(dB,2)) + (pow(c.x,2)-pow(a.x,2)) + (pow(b.y,2)-pow(a.y,2)) ) * (2*c.y-2*b.y) - ( (pow(dB,2)-pow(dC,2)) + (pow(c.x,2)-pow(c.x,2)) + (pow(c.y,2)-pow(b.y,2)) ) *(2*b.y-2*a.y) ) / ( (2*b.x-2*c.x)*(2*b.y-2*a.y)-(2*a.x-2*b.x)*(2*c.y-2*b.y) );

y = ( (pow(dA,2)-pow(dB,2)) + (pow(c.x,2)-pow(a.x,2)) + (pow(b.y,2)-pow(a.y,2)) + x*(2*a.x-2*b.x)) / (2*b.y-2*a.y);



return CGPointMake(x, y);
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接