Xvt.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: Xvt.cpp 3140 2012-06-18 15:03:02Z susancummins $"
00002 
00008 //============================================================================
00009 //
00010 //  This file is part of GPSTk, the GPS Toolkit.
00011 //
00012 //  The GPSTk is free software; you can redistribute it and/or modify
00013 //  it under the terms of the GNU Lesser General Public License as published
00014 //  by the Free Software Foundation; either version 2.1 of the License, or
00015 //  any later version.
00016 //
00017 //  The GPSTk is distributed in the hope that it will be useful,
00018 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //  GNU Lesser General Public License for more details.
00021 //
00022 //  You should have received a copy of the GNU Lesser General Public
00023 //  License along with GPSTk; if not, write to the Free Software Foundation,
00024 //  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
00025 //  
00026 //  Copyright 2004, The University of Texas at Austin
00027 //
00028 //============================================================================
00029 
00030 //============================================================================
00031 //
00032 //This software developed by Applied Research Laboratories at the University of
00033 //Texas at Austin, under contract to an agency or agencies within the U.S. 
00034 //Department of Defense. The U.S. Government retains all rights to use,
00035 //duplicate, distribute, disclose, or release this software. 
00036 //
00037 //Pursuant to DoD Directive 523024 
00038 //
00039 // DISTRIBUTION STATEMENT A: This software has been approved for public 
00040 //                           release, distribution is unlimited.
00041 //
00042 //=============================================================================
00043 
00044 #include <iostream>
00045 #include "Xvt.hpp"
00046 
00047 // Output operator for Xvt
00048 // @param os output stream to which \c xvt is sent
00049 // @param xvt Xvt that is sent to \c os
00050 std::ostream& operator<<(std::ostream& os, const gpstk::Xvt& xvt) throw()
00051 {
00052    os << "x:" << xvt.x
00053      << ", v:" << xvt.v
00054      << ", clk bias:" << xvt.clkbias
00055      << ", clk drift:" << xvt.clkdrift
00056      << ", relcorr:" << xvt.relcorr;
00057    return os;
00058 }
00059 
00060 // compute the relativity correction
00061 double gpstk::Xvt::computeRelativityCorrection(void)
00062 {
00063    relcorr = -2.0*( (x[0]/C_MPS)*(v[0]/C_MPS)
00064                    +(x[1]/C_MPS)*(v[1]/C_MPS)
00065                    +(x[2]/C_MPS)*(v[2]/C_MPS) );
00066    return relcorr;
00067 }
00068 
00069 // Function to find the range and position from a ground
00070 // location, rxPos, to the spacecraft position (*this).x
00071 // Use the pseudorange corrected for SV clock effects to get a
00072 // rough time of flight (dt).  Account directly for Earth
00073 // rotation, then compute a rough receiver bias by differencing
00074 // the initial time of flight with the new estimate.  Then
00075 // correct the rotation by a small amount.
00076 double gpstk::Xvt::preciseRho(const Triple& rxPos,
00077                               const EllipsoidModel& ellips,
00078                               double correction) const 
00079    throw()
00080 {
00081    // Compute initial time of flight estimate using the
00082    // geometric range at transmit time.  This fails to account
00083    // for the rotation of the earth, but should be good to
00084    // within about 40 m
00085    double sr1 = rxPos.slantRange(x);
00086    double dt = sr1 / ellips.c();
00087 
00088    // compute rotation angle in the time of signal transit
00089    double rotation_angle = -ellips.angVelocity() * dt;
00090 
00091    // rotate original GS coordinates to new values to correct for
00092    // rotation of ECEF frame
00093    // Ref: Satellite Geodesy, Gunter Seeber, 1993, pg 291  and the 
00094    // ICD-GPS-200 sheet 102 May 1993 version
00095    //   xnew[0]=xg[0]*cos(rotation_angle)-xg[1]*sin(rotation_angle);
00096    //   xnew[1]=xg[1]*cos(rotation_angle)+xg[0]*sin(rotation_angle);
00097    //   xnew[2]=xg[2];
00098    // since cosine and sine are small, approximate by the first
00099    // order terms in an expansion.
00100    gpstk::Triple xnew;
00101    for (int i = 0; i < 2; i++)
00102    {
00103       xnew[0] = x[0] - x[1] * rotation_angle;
00104       xnew[1] = x[1] + x[0] * rotation_angle;
00105       xnew[2] = x[2];
00106 
00107       // Compute geometric slant range from ground station to
00108       // the rotated new coord's
00109       sr1 = rxPos.slantRange(xnew);
00110    
00111       // Recompute the time of flight (dt) based on PR, with the
00112       // time of flight based on geometric range.  Note that
00113       // this is a really unneeded, in that the change in PR is
00114       // < 40 m, hence the change in tof is < 20 ns
00115       dt = sr1 / ellips.c();
00116    
00117       // Compute new rotation in this time 
00118       rotation_angle = -ellips.angVelocity() * dt;  
00119    }
00120 
00121    // Account for SV clock drift, relativity and user input correction
00122    double rho = sr1 - (clkbias + relcorr) * ellips.c() - correction;
00123 
00124    return rho;
00125 
00126 } // end of preciseRho()
00127 

Generated on Sat May 18 03:31:12 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1