遗忘海岸

江湖程序员 -Feiph(LM战士)

导航

平面上圆相交求交点——定位模拟

基站发出报文 {基站坐标:(a1,b1),发出时间:2022-06-02: 10:32:35.23422}

移动端传感器采集3个基站的数据,然后计算距离构建3个圆方程,两两相减得到3个线性方程,对方程组求最小二乘解

代码了引入了线性误差e作用于计算的距离上

clear
clc
close()

c1=[8 10];
c2=[-10,12];
c3=[-4,-4];
e=0.01;


p=(rand(1,2)-0.5) * 40

t1= (p -c1).^2;
rr1=sqrt(t1(1)+t1(2));
r1=rr1*e * (rand(1)-0.5*2) + rr1; %noices

t2= (p -c2).^2;
rr2=sqrt(t2(1)+t2(2));
r2=rr2*e * (rand(1)-0.5*2) + rr2;

t3= (p -c3).^2;
rr3=sqrt(t3(1)+t3(2));
r3=rr3*e * (rand(1)-0.5*2) + rr3;

n1=r1^2-c1(1)^2-c1(2)^2 -(r2^2 - c2(1)^2 - c2(2)^2);
n2=r1^2-c1(1)^2-c1(2)^2 -(r3^2 - c3(1)^2 - c3(2)^2);
n3=r2^2-c2(1)^2-c2(2)^2 -(r3^2 - c3(1)^2 - c3(2)^2);
N=[n1;n2;n3];

A=[
    -2*c1(1)+2*c2(1), -2*c1(2)+2*c2(2)
    -2*c1(1)+2*c3(1), -2*c1(2)+2*c3(2)
    -2*c2(1)+2*c3(1), -2*c2(2)+2*c3(2)
   ];
    
C=A\N;
p1=C'

D=C-p'

hold on
axis square

rectangle('Position',[8-rr1,10-rr1,2*rr1,2*rr1],'Curvature',[1,1]);
rectangle('Position',[-10-rr2,12-rr2,2*rr2,2*rr2],'Curvature',[1,1]);
rectangle('Position',[-4-rr3,-4-rr3,2*rr3,2*rr3],'Curvature',[1,1]);
txt=num2str(p)
text(p(1),p(2), txt)
text(c1(1),c1(2), num2str(c1))
text(c2(1),c2(2), num2str(c2))
text(c3(1),c3(2), num2str(c3))
View Code

 

以上需要接受端时钟与发送端同步, 但是不同步的情况下,会采用双曲线定位,双曲线的特性,即到2定焦点距离之差一定的轨迹,而空间中是双曲面,4个基站形成3组双曲面的公共焦点则是所求位置

posted on 2022-06-02 10:31  遗忘海岸  阅读(110)  评论(0编辑  收藏  举报