B_POINT.M
上传用户:sfyaiting
上传日期:2009-10-25
资源大小:320k
文件大小:2k
源码类别:

GPS编程

开发平台:

Matlab

  1. function pos = b_point(pr,sv,time,Eph)
  2. %B_POINT Prepares input to the Bancroft algorithm for finding
  3. %        a preliminary position of a receiver. The input is
  4. %       four or more pseudoranges and the coordinates of the
  5. %       satellites.
  6. %Kai Borre and C.C. Goad 11-24-96
  7. %Copyright (c) by Kai Borre
  8. %$Revision: 1.1 $ $Date: 1997/11/10 $
  9. v_light = 299792458;
  10. dtr = pi/180;
  11. m = size(pr,1);
  12. for t = 1:m
  13.    col_Eph(t) = find_eph(Eph,sv(t),time);
  14. end
  15. pos = zeros(4,1);       % First guess Earth center
  16. for l = 1:2
  17.    B = [];
  18.    for jsat = 1:m
  19.       k = col_Eph(jsat);
  20.       tx_RAW = time - pr(jsat)/v_light;
  21.       t0c = Eph(21,k);
  22.       dt = check_t(tx_RAW-t0c);
  23.       tcorr = (Eph(2,k)*dt + Eph(20,k))*dt + Eph(19,k);
  24.       tx_GPS = tx_RAW-tcorr;
  25.       dt = check_t(tx_GPS-t0c);
  26.       tcorr = (Eph(2,k)*dt + Eph(20,k))*dt + Eph(19,k);
  27.       tx_GPS = tx_RAW-tcorr;
  28.       X = satpos(tx_GPS, Eph(:,k));
  29.       if l ~= 1
  30.          rhosq = (X(1)-pos(1))^2+(X(2)-pos(2))^2+(X(3)-pos(3))^2;     
  31.          traveltime = sqrt(rhosq)/v_light;       
  32.          Rot_X = e_r_corr(traveltime,X);
  33.          rhosq = (Rot_X(1)-pos(1))^2 + ...
  34.                     (Rot_X(2)-pos(2))^2 + ...
  35.                              (Rot_X(3)-pos(3))^2;
  36.          traveltime = sqrt(rhosq)/v_light;                                                                                            
  37.          [az,el,dist] = topocent(pos(1:3,:),Rot_X-pos(1:3,:));                                                            
  38.          % [phi,lambda,h] = togeod(6378137, 298.257223563, ...
  39.          %                              pos(1), pos(2), pos(3));                                   
  40.          trop = tropo(sin(el*dtr),0.0,1013.0,293.0,50.0,...
  41.                                                      0.0,0.0,0.0);                      
  42.       else trop = 0;
  43.       end
  44.       corrected_pseudorange = pr(jsat)+v_light*tcorr-trop;
  45.       B(jsat,1) = X(1);
  46.       B(jsat,2) = X(2);
  47.       B(jsat,3) = X(3);
  48.       B(jsat,4) = corrected_pseudorange;
  49.    end; % jsat-loop
  50.    pos = bancroft(B);
  51.    [phi,lambda,h] = togeod(6378137, 298.257223563, ...
  52.                                           pos(1), pos(2), pos(3));
  53. end; % l-loop
  54. clock_offset = pos(4)/v_light;
  55. pos(4) = clock_offset*1.e+9;      % ns
  56. %%%%%%%%%%% b_point.m  %%%%%%%%%%%%%%%%%%%%%%%%%