MOOS 0.2375
/home/toby/moos-ivp/MOOS-2375-Oct0611/NavigationAndControl/MOOSNavLib/LBLMaths.cpp
Go to the documentation of this file.
00001 
00002 //
00003 //   MOOS - Mission Oriented Operating Suite 
00004 //  
00005 //   A suit of Applications and Libraries for Mobile Robotics Research 
00006 //   Copyright (C) 2001-2005 Massachusetts Institute of Technology and 
00007 //   Oxford University. 
00008 //    
00009 //   This software was written by Paul Newman and others
00010 //   at MIT 2001-2002 and Oxford University 2003-2005.
00011 //   email: pnewman@robots.ox.ac.uk. 
00012 //      
00013 //   This file is part of a  MOOS Basic (Common) Application. 
00014 //        
00015 //   This program is free software; you can redistribute it and/or 
00016 //   modify it under the terms of the GNU General Public License as 
00017 //   published by the Free Software Foundation; either version 2 of the 
00018 //   License, or (at your option) any later version. 
00019 //          
00020 //   This program is distributed in the hope that it will be useful, 
00021 //   but WITHOUT ANY WARRANTY; without even the implied warranty of 
00022 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
00023 //   General Public License for more details. 
00024 //            
00025 //   You should have received a copy of the GNU General Public License 
00026 //   along with this program; if not, write to the Free Software 
00027 //   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 
00028 //   02111-1307, USA. 
00029 //
00031 // MOOSObservation.cpp: implementation of the CLBLMaths class.
00032 //
00034 
00035 #include <math.h>
00036 #include "MOOSNavEntity.h"
00037 #include "MOOSNavVehicle.h"
00038 
00039 #include "MOOSNavBeacon.h"
00040 
00041 #include "MOOSNavSensor.h"
00042 #include "LBLMaths.h"
00043 #include "MOOSNavLibGlobalHelper.h"
00044 
00045 #define Diff1_TT_wrt_State(a,b,c,a1,b1,c1,T) \
00046     ((((T)==0)&&((b)==0))?0:(-((c1)+(b1)*(T)+(a1)*((c)+(T)*((b)+2*(a)*(T)))/(a))/((b)+2*(a)*(T))))
00047 
00048 
00049 
00050 bool CLBLMaths::CalculateTwoWayTOF(CMOOSNavSensor *pInterrogatorSensor,
00051                                           CMOOSNavSensor *pResponderSensor,
00052                                           Matrix * pXEvaluate,
00053                                           double dfSV,
00054                                           double & dfTotalTOF
00055                                           )
00056 {
00058     //I tested speed of thi function on a P3
00059     //took on average 20 uSeconds to complete
00060     //not a problem by any means
00061     //running on a machine 100 times slower it
00062     //would only take 2000uS = 2ms. No problem.
00063     
00064     
00065     
00066     //pointers to sensors (we shall swap what they point to
00067     //for different legs 
00068     CMOOSNavSensor * pTx;
00069     CMOOSNavSensor * pRx;
00070     
00072     //            calculate last leg:
00074     double dfLastLegTOF=0;
00075     
00076     pTx = pResponderSensor;
00077     pRx = pInterrogatorSensor;
00078     
00079     if(!CalculateLegTravelTime(0,pTx,pRx,pXEvaluate,dfSV,dfLastLegTOF))
00080     {
00081         return false;
00082     }
00083     
00085     //            now calculate first leg:
00087     
00088     double dfTAT=0;
00089     CMOOSNavBeacon * pBeacon = dynamic_cast<CMOOSNavBeacon*>(pResponderSensor->GetParent());        
00090     if(pBeacon!=NULL)
00091     {
00092         dfTAT = pBeacon->m_dfTAT;
00093     }
00094     
00095     double dfTimeAgo = (dfLastLegTOF+dfTAT);
00096     
00097     pTx = pInterrogatorSensor;
00098     pRx = pResponderSensor;
00099     
00100     double dfFirstLegTOF=0;
00101     
00102     if(!CalculateLegTravelTime(dfTimeAgo,pTx,pRx,pXEvaluate,dfSV,dfFirstLegTOF))
00103     {
00104         return false;
00105     }
00106     
00107 
00108     //finally we get our result :-)
00109     dfTotalTOF = dfLastLegTOF+dfTAT+dfFirstLegTOF;
00110     
00111     return true;
00112 }
00113 
00114 
00115 
00116 bool CLBLMaths::CalculateTwoWayTOFJacobians(CMOOSNavSensor *pInterrogatorSensor,
00117                                           CMOOSNavSensor *pResponderSensor,
00118                                           Matrix * pXEvaluate,
00119                                           double dfSV,
00120                                           Matrix & jH
00121                                           )
00122 {
00123 
00124     int nCols = pXEvaluate->Nrows();
00125 
00126     if(jH.Nrows()!=1 || jH.Ncols()!=nCols)
00127     {
00128         jH.ReSize(1,nCols);
00129         jH = 0;
00130     }
00131 
00132        
00133     //pointers to sensors (we shall swap what they point to
00134     //for different legs 
00135     CMOOSNavSensor * pTx;
00136     CMOOSNavSensor * pRx;
00137     
00139     //            calculate last leg:
00141    
00142     double dfTimeAgo = 0;
00143     double dfLastLegTOF;
00144     double dfFirstLegTOF;
00145 
00146     pTx = pResponderSensor;
00147     pRx = pInterrogatorSensor;
00148 
00149     SetUpLBLData(dfTimeAgo,pTx,pRx,pXEvaluate,dfSV);
00150 
00151     if(!CalculateLegTravelTime(dfTimeAgo,pTx,pRx,pXEvaluate,dfSV,dfLastLegTOF))
00152     {
00153         return false;
00154     }
00155 
00156     if(!AddJacobianLegComponent(jH,pTx,pRx,dfLastLegTOF,dfTimeAgo))
00157     {
00158         return false;
00159     }
00160     
00161 
00163     //            now calculate first leg:
00165 
00166     
00167     //look for TAT
00168     double dfTAT=0;
00169     CMOOSNavBeacon * pBeacon = dynamic_cast<CMOOSNavBeacon*>(pResponderSensor->GetParent());        
00170     if(pBeacon!=NULL)
00171     {
00172         dfTAT = pBeacon->m_dfTAT;
00173     }
00174 
00175 
00176 
00177 
00178     dfTimeAgo = (dfLastLegTOF+dfTAT);
00179     
00180     pTx = pInterrogatorSensor;
00181     pRx = pResponderSensor;
00182     
00183     SetUpLBLData(dfTimeAgo,pTx,pRx,pXEvaluate,dfSV);
00184 
00185     if(!CalculateLegTravelTime(dfTimeAgo,pTx,pRx,pXEvaluate,dfSV,dfFirstLegTOF))
00186     {
00187         return false;
00188     }
00189 
00190     if(!AddJacobianLegComponent(jH,pTx,pRx,dfFirstLegTOF,dfTimeAgo))
00191     {
00192         return false;
00193     }
00194 
00195     return true;
00196 }    
00197  
00198 
00199 bool CLBLMaths::CalculateLegTravelTime(double dfTimeAgo,
00200                                               CMOOSNavSensor * pTxSensor,
00201                                               CMOOSNavSensor * pRxSensor,
00202                                                Matrix * pXEvaluate,
00203                                                double dfSV,
00204                                               double & dfTravelTimeResult
00205                                              )
00206 {
00207     
00208 
00209 
00210 
00211     if(!SetUpLBLData(dfTimeAgo,pTxSensor,pRxSensor,pXEvaluate,dfSV))
00212         return false;
00213 
00214 
00215 
00216     dfTravelTimeResult =  (-b-sqrt(b*b-4*a*c))/(2*a);
00217     
00218     return true;
00219 }
00220 
00221 
00222 bool CLBLMaths::SetUpLBLData(double dfTimeAgo,
00223                                     CMOOSNavSensor *pTxSensor,
00224                                     CMOOSNavSensor *pRxSensor,
00225                                     Matrix * pXEvaluate,
00226                                     double dfSV)
00227 {
00228 
00229     m_dfSV = dfSV;
00230 
00231     //get coordinates and rates of vehicles involved in
00232     //cardinal coordinates    
00233     Matrix VehTx,VehRx;
00234     
00235     //her we get the entities to manage things themselves
00236     //they know best...
00237     if(!pTxSensor->GetParent()->GetFullState(VehTx,pXEvaluate))
00238         return false;
00239     
00240     if(!pRxSensor->GetParent()->GetFullState(VehRx,pXEvaluate))
00241         return false;
00242     
00243     //now extract single numbers for use later on
00244     Rx_Veh_X = I_X(VehRx,1);
00245     Rx_Veh_Y = I_Y(VehRx,1);
00246     Rx_Veh_Z = I_Z(VehRx,1);
00247     Rx_Veh_H = I_H(VehRx,1);
00248     
00249     Rx_Veh_Xdot = I_Xdot(VehRx,1);
00250     Rx_Veh_Ydot = I_Ydot(VehRx,1);
00251     Rx_Veh_Zdot = I_Zdot(VehRx,1);
00252     Rx_Veh_Hdot     = I_Hdot(VehRx,1);
00253     
00254     Tx_Veh_X = I_X(VehTx,1);
00255     Tx_Veh_Y = I_Y(VehTx,1);
00256     Tx_Veh_Z = I_Z(VehTx,1);
00257     Tx_Veh_H = I_H(VehTx,1);
00258     
00259     Tx_Veh_Xdot = I_Xdot(VehTx,1);
00260     Tx_Veh_Ydot = I_Ydot(VehTx,1);
00261     Tx_Veh_Zdot = I_Zdot(VehTx,1);
00262     Tx_Veh_Hdot     = I_Hdot(VehTx,1);
00263     
00264     //now get sensor coordinates
00265     
00266     //need to convert to global aligned frame
00267     pRxSensor->GetAlignedOffsets(Rx_Veh_H,Rx_Sen_X,Rx_Sen_Y,Rx_Sen_Z);
00268     pTxSensor->GetAlignedOffsets(Tx_Veh_H,Tx_Sen_X,Tx_Sen_Y,Tx_Sen_Z);
00269     
00270     
00271     /*
00272     dE = (E of Rx Sen - E of Tx Sen) instantaneously.
00273     dN = (N of Rx Sen - N of Tx Sen) instantaneously.
00274     dZ = (Z of Rx Sen - Z of Tx Sen) instantaneously.
00275     
00276       a =  SQR(TxVelE-TxSenN*TxAngVel)+SQR(TxVelN+TxSenE*TxAngVel)+SQR(TxVelD)-SQR(SVel)
00277       b =  2*((dE*(TxVelE-TxSenN*TxAngVel))+(dN*(TxVelN+TxSenE*TxAngVel))+(dZ*TxVelZ))
00278       c =  SQR(dE)+SQR(dN)+SQR(dZ)
00279     */
00280     //figure out velocity of Tx sensor.. 
00281     Tx_Sen_Xdot = Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot;
00282     Tx_Sen_Ydot = Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot;
00283     
00284     dE = ((Rx_Veh_X+Rx_Sen_X -
00285         (Rx_Veh_Xdot-Rx_Sen_Y*Rx_Veh_Hdot)*dfTimeAgo) -
00286         (Tx_Veh_X+Tx_Sen_X - Tx_Sen_Xdot*dfTimeAgo));
00287     
00288     dN = ((Rx_Veh_Y+Rx_Sen_Y -
00289         (Rx_Veh_Ydot+Rx_Sen_X*Rx_Veh_Hdot)*dfTimeAgo) -
00290         (Tx_Veh_Y+Tx_Sen_Y - Tx_Sen_Ydot*dfTimeAgo));
00291     
00292     dZ = ((Rx_Veh_Z+Rx_Sen_Z-Rx_Veh_Zdot*dfTimeAgo) -
00293         (Tx_Veh_Z+Tx_Sen_Z-Tx_Veh_Zdot*dfTimeAgo));
00294     
00295         /* Ugly bodge to prevent possibility of solution
00296         becoming trapped on one of the cardinal axes... 
00297     interesting*/
00298     
00299     dE=fabs(dE)<1e-3?MOOSWhiteNoise(1e-4):dE;
00300     dN=fabs(dN)<1e-3?MOOSWhiteNoise(1e-4):dN;
00301     dZ=fabs(dZ)<1e-3?MOOSWhiteNoise(1e-4):dZ;
00302     
00303     a = SQR(Tx_Sen_Xdot)+SQR(Tx_Sen_Ydot)+SQR(Tx_Veh_Zdot)-SQR(m_dfSV);
00304     b = 2*(dE*Tx_Sen_Xdot+dN*Tx_Sen_Ydot+dZ*Tx_Veh_Zdot);
00305     c = SQR(dE)+SQR(dN)+SQR(dZ);       
00306     
00307 
00308   
00309     return true;
00310 
00311 }
00312 
00313 
00314 bool CLBLMaths::AddJacobianLegComponent(Matrix & H,
00315                                         CMOOSNavSensor* pTxSensor,
00316                                         CMOOSNavSensor* pRxSensor,
00317                                          double TTime,
00318                                          double dt)
00319 {
00320 
00321     CMOOSNavVehicle* pVehRx = dynamic_cast< CMOOSNavVehicle * >(pRxSensor->GetParent());
00322     CMOOSNavVehicle* pVehTx = dynamic_cast< CMOOSNavVehicle * >(pTxSensor->GetParent());
00323 
00324 
00325     bool bRxIsVehicle = pVehRx!=NULL;
00326     bool bTxIsVehicle = pVehTx!=NULL;
00327 
00328     int nObsNdx = 1;
00329 
00330     if(bRxIsVehicle)
00331     {
00332         int RxNdx = pVehRx->m_nStart;
00333 
00334         H(nObsNdx,RxNdx+iiX)+= dTTbydEr(TTime);
00335         H(nObsNdx,RxNdx+iiY)+= dTTbydNr(TTime);
00336         H(nObsNdx,RxNdx+iiZ)+= dTTbydZr(TTime);
00337         H(nObsNdx,RxNdx+iiH)+= dTTbydHr(TTime,dt);
00338         
00339         if(pVehRx->m_eType==CMOOSNavVehicle::POSE_AND_RATE)
00340         {
00341             H(nObsNdx,RxNdx+iiXdot)+= dTTbydErvel(TTime,dt);
00342             H(nObsNdx,RxNdx+iiYdot)+= dTTbydNrvel(TTime,dt);
00343             H(nObsNdx,RxNdx+iiZdot)+= dTTbydZrvel(TTime,dt);
00344             H(nObsNdx,RxNdx+iiHdot)+= dTTbydHrvel(TTime,dt);
00345         }
00346     }
00347 
00348     //if we are imuune to acoustic observations don't add any thing here..
00349     if( bTxIsVehicle)
00350     {
00351         int TxNdx = pVehTx->m_nStart;
00352 
00353         
00354         H(nObsNdx,TxNdx+iiX)+= dTTbydEt(TTime);
00355         H(nObsNdx,TxNdx+iiY)+= dTTbydNt(TTime);
00356         H(nObsNdx,TxNdx+iiZ)+= dTTbydZt(TTime);
00357         H(nObsNdx,TxNdx+iiH)+= dTTbydHt(TTime,dt);
00358         
00359         if(pVehTx->m_eType==CMOOSNavVehicle::POSE_AND_RATE)
00360         {
00361             H(nObsNdx,TxNdx+iiXdot)+= dTTbydEtvel(TTime,dt);
00362             H(nObsNdx,TxNdx+iiYdot)+= dTTbydNtvel(TTime,dt);
00363             H(nObsNdx,TxNdx+iiZdot)+= dTTbydZtvel(TTime,dt);
00364             H(nObsNdx,TxNdx+iiHdot)+= dTTbydHtvel(TTime,dt);
00365         }
00366     }
00367 
00368 
00369     return true;
00370 }
00371 
00372 
00373 
00374 
00375 double CLBLMaths::dTTbydEt( double T)
00376 {
00377 
00378 
00379     return Diff1_TT_wrt_State(a, b, c,
00380         0.0,                                                                        /* a1 */
00381        -2*(Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot),                         /* b1 */
00382        -2*dE,                                                                       /* c1 */
00383         T);                         /* Estimated travel time                              */
00384 }
00385 
00386 double CLBLMaths::dTTbydNt( double T)
00387 {
00388 
00389 
00390     return Diff1_TT_wrt_State(a,b, c,
00391         0.0,                                                                        /* a1 */
00392        -2*(Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot),                         /* b1 */
00393        -2*dN,                                                                       /* c1 */
00394         T);                         /* Estimated travel time                              */
00395 }
00396 
00397 double CLBLMaths::dTTbydZt( double T)
00398 {
00399 
00400     return Diff1_TT_wrt_State(a,b, c,
00401         0.0,                                                                        /* a1 */
00402        -2*Tx_Veh_Zdot,                                                         /* b1 */
00403        -2*dZ,                                                                       /* c1 */
00404         T);                         /* Estimated travel time                              */
00405 }
00406 
00407 double CLBLMaths::dTTbydHt ( double T, double dT)
00408 {
00409 
00410     return Diff1_TT_wrt_State(a,b, c,
00411        -2 * ((Tx_Sen_X*Tx_Veh_Xdot +                                     /* al */
00412               Tx_Sen_Y*Tx_Veh_Ydot) * Tx_Veh_Hdot),
00413        -2 * (Tx_Sen_X*(Tx_Veh_Hdot*(dE+Tx_Sen_X+dT*Tx_Veh_Xdot)+Tx_Veh_Ydot)+
00414              Tx_Sen_Y*(Tx_Veh_Hdot*(dN+Tx_Sen_Y+dT*Tx_Veh_Ydot)-Tx_Veh_Xdot)),
00415        -2 * ((dE*Tx_Sen_X+dN*Tx_Sen_Y)*Tx_Veh_Hdot*dT +
00416               dN*Tx_Sen_X-dE*Tx_Sen_Y),
00417         T);                         /* Estimated travel time                              */
00418 }
00419 
00420 double CLBLMaths::dTTbydEtvel( double T, double dT)
00421 {
00422 
00423     
00424     return Diff1_TT_wrt_State(a,b, c,
00425         2 * (Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot),                       /* a1 */
00426         2 * (dE + (Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot)*dT),             /* b1 */
00427         2 * dE * dT,                                                                /* c1 */
00428         T);                         /* Estimated travel time                              */
00429 }
00430 
00431 double CLBLMaths::dTTbydNtvel( double T, double dT)
00432 {
00433 
00434     
00435     return Diff1_TT_wrt_State(a,b, c,
00436         2 * (Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot),                       /* a1 */
00437         2 * (dN + (Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot)*dT),             /* b1 */
00438         2 * dN * dT,                                                                /* c1 */
00439         T);                         /* Estimated travel time                              */
00440 }
00441 
00442 double CLBLMaths::dTTbydZtvel( double T, double dT)
00443 {
00444 
00445     
00446     
00447     return Diff1_TT_wrt_State(a,b, c,
00448         2 * Tx_Veh_Zdot,                                                       /* a1 */
00449         2 * (dZ + Tx_Veh_Zdot*dT),                                             /* b1 */
00450         2 * dZ * dT,                                                                /* c1 */
00451         T);                         /* Estimated travel time                              */
00452 }
00453 
00454 double CLBLMaths::dTTbydHtvel( double T, double dT)
00455 {
00456 
00457     
00458     
00459     return Diff1_TT_wrt_State(a,b, c,
00460         2 * (Tx_Sen_X*(Tx_Veh_Ydot+Tx_Veh_Hdot*Tx_Sen_X)-       /* a1 */
00461              Tx_Sen_Y*(Tx_Veh_Xdot-Tx_Veh_Hdot*Tx_Sen_Y)+ 
00462             (Tx_Sen_X*(Tx_Veh_Xdot-Tx_Veh_Hdot*Tx_Sen_Y)+
00463              Tx_Sen_Y*(Tx_Veh_Ydot+Tx_Veh_Hdot*Tx_Sen_X))*
00464              Tx_Veh_Hdot*(dT+T)),
00465         2 * (Tx_Sen_X*(dN+dT*(Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot)+/* b1 */
00466             (Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot+
00467              Tx_Veh_Hdot*(dE+dT*(Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot)))*(dT+T))-
00468              Tx_Sen_Y*(dE+dT*(Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot)+ 
00469             (Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot-
00470              Tx_Veh_Hdot*(dN+dT*(Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot)))*(dT+T))),
00471         2 * (Tx_Sen_X*(dN*dT+(dN+dE*dT*Tx_Veh_Hdot)*(dT+T)) -              /* c1 */
00472              Tx_Sen_Y*(dE*dT+(dE-dN*dT*Tx_Veh_Hdot)*(dT+T))),
00473         T);                         /* Estimated travel time                              */
00474 }
00475 
00476 double CLBLMaths::dTTbydEr( double T)
00477 {
00478 
00479         double dfVal = Diff1_TT_wrt_State(a,b, c,
00480         0.0,                                                                        /* a1 */
00481         2 * (Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot),                       /* b1 */
00482         2 * dE,                                                                     /* c1 */
00483         T);                         /* Estimated travel time                              */
00484 
00485         return dfVal;
00486 }
00487 
00488 double CLBLMaths::dTTbydNr( double T)
00489 {
00490 
00491     
00492     return Diff1_TT_wrt_State(a,b, c,
00493         0.0,                                                                        /* a1 */
00494         2 * (Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot),                       /* b1 */
00495         2 * dN,                                                                     /* c1 */
00496         T);                         /* Estimated travel time                              */
00497 }
00498 
00499 double CLBLMaths::dTTbydZr( double T)
00500 {
00501 
00502     return Diff1_TT_wrt_State(a,b, c,
00503         0.0,                                                                        /* a1 */
00504         2 * Tx_Veh_Zdot,                                                       /* b1 */
00505         2 * dZ,                                                                     /* c1 */
00506         T);                         /* Estimated travel time                              */
00507 }
00508 
00509 double CLBLMaths::dTTbydHr(  double T, double dT)
00510 {
00511 
00512 
00513 
00514     return Diff1_TT_wrt_State(a,b, c,
00515         0.0,                                                                        /* a1 */
00516         2 * ((Rx_Sen_X+Rx_Sen_Y*Rx_Veh_Hdot*dT)*                              /* b1 */
00517               (Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot)-
00518              (Rx_Sen_Y-Rx_Sen_X*Rx_Veh_Hdot*dT)*
00519               (Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot)),
00520         2 * (Rx_Sen_X*(dN+dE*Rx_Veh_Hdot*dT)-                              /* c1 */
00521              Rx_Sen_Y*(dE-dN*Rx_Veh_Hdot*dT)),
00522         T);                         /* Estimated travel time                              */
00523 }
00524 
00525 double CLBLMaths::dTTbydErvel( double T, double dT)
00526 {
00527 
00528     return Diff1_TT_wrt_State(a,b, c,
00529         0.0,                                                                        /* a1 */
00530        -2 * (Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot) * dT,                  /* b1 */
00531        -2 * dE * dT,                                                                /* c1 */
00532         T);                         /* Estimated travel time                              */
00533 }
00534 
00535 double CLBLMaths::dTTbydNrvel( double T, double dT)
00536 {
00537 
00538     
00539     return Diff1_TT_wrt_State(a,b, c,
00540         0.0,                                                                        /* a1 */
00541        -2 * (Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot)*dT,                    /* b1 */
00542        -2 * dN * dT,                                                                /* c1 */
00543         T);                         /* Estimated travel time                              */
00544 }
00545 
00546 double CLBLMaths::dTTbydZrvel( double T, double dT)
00547 {
00548     
00549     
00550     return Diff1_TT_wrt_State(a,b, c,
00551         0.0,                                                                        /* a1 */
00552        -2 * Tx_Veh_Zdot * dT,                                                  /* b1 */
00553        -2 * dZ * dT,                                                                /* c1 */
00554         T);                         /* Estimated travel time                              */
00555 }
00556 
00557 double CLBLMaths::dTTbydHrvel( double T, double dT)
00558 {
00559 
00560     
00561     
00562     return Diff1_TT_wrt_State(a,b, c,
00563         0.0,                                                                        /* a1 */
00564         2 * ((Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot)*                      /* b1 */
00565               (2*Rx_Sen_Y-Rx_Sen_X*Rx_Veh_Hdot*dT)-
00566              (Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot)*
00567               (2*Rx_Sen_X+Rx_Sen_Y*Rx_Veh_Hdot*dT))*dT,
00568        -2 * (dN*(2*Rx_Sen_X+Rx_Sen_Y*Rx_Veh_Hdot*dT)-                /* c1 */
00569              dE*(2*Rx_Sen_Y-Rx_Sen_X*Rx_Veh_Hdot*dT))*dT,
00570         T);                         /* Estimated travel time                              */
00571 }
00572 
00573 double CLBLMaths::dTTbydxt( double T, double dT)
00574 {
00575 
00576     return Diff1_TT_wrt_State(a,b, c,
00577         2 * (CosTx*(Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot)-                /* a1 */
00578              SinTx*(Tx_Veh_Xdot-Tx_Veh_Hdot*Tx_Sen_Y))*Tx_Veh_Hdot,
00579        -2 * (CosTx*(Tx_Veh_Xdot-(dN+Tx_Sen_Y+                            /* b1 */
00580                 (Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot)*dT)*Tx_Veh_Hdot)+
00581              SinTx*(Tx_Veh_Ydot+(dE+Tx_Sen_X+
00582                 (Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot)*dT)*Tx_Veh_Hdot)),
00583        -2 * (CosTx*(dE-dN*Tx_Veh_Hdot*dT)+SinTx*(dN+dE*Tx_Veh_Hdot*dT)),      /* c1 */
00584         T);                         /* Estimated travel time                              */
00585 }
00586 
00587 double CLBLMaths::dTTbydyt( double T, double dT)
00588 {
00589     
00590     
00591     return Diff1_TT_wrt_State(a,b, c,
00592        -2 * (CosTx*(Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot)+                /* a1 */
00593              SinTx*(Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot))*Tx_Veh_Hdot,
00594         2 * (SinTx*(Tx_Veh_Xdot-(dN+Tx_Sen_Y+                            /* b1 */
00595                         (Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot)*dT)*Tx_Veh_Hdot)-
00596              CosTx*(Tx_Veh_Ydot+(dE+Tx_Sen_X+
00597                         (Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot)*dT)*Tx_Veh_Hdot)),
00598        -2 * (CosTx*(dN+dE*Tx_Veh_Hdot*dT)-SinTx*(dE-dN*Tx_Veh_Hdot*dT)),
00599         T);                         /* Estimated travel time                              */
00600 }
00601 
00602 double CLBLMaths::dTTbydxr(  double T, double dT)
00603 {
00604 
00605     
00606     return Diff1_TT_wrt_State(a,b, c,
00607         0.0,                                                                        /* a1 */
00608         2 * (CosRx*((Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot)-               /* b1 */
00609                     (Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot)*Rx_Veh_Hdot*dT)+
00610              SinRx*((Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot)+
00611                     (Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot)*Rx_Veh_Hdot*dT)),
00612         2 * (CosRx*(dE-dN*Rx_Veh_Hdot*dT)+SinRx*(dN+dE*Rx_Veh_Hdot*dT)),      /* c1 */
00613         T);                         /* Estimated travel time                              */
00614 }
00615 
00616 double CLBLMaths::dTTbydyr (  double T, double dT)
00617 {
00618     
00619     return Diff1_TT_wrt_State(a,b, c,
00620         0.0,                                                                        /* a1 */
00621         2 * (CosRx*((Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot)*Rx_Veh_Hdot*dT+
00622                     (Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot))+
00623              SinRx*((Tx_Veh_Ydot+Tx_Sen_X*Tx_Veh_Hdot)*Rx_Veh_Hdot*dT-
00624                     (Tx_Veh_Xdot-Tx_Sen_Y*Tx_Veh_Hdot))),
00625         2 * (CosRx*(dN+dE*Rx_Veh_Hdot*dT)-SinRx*(dE-dN*Rx_Veh_Hdot*dT)),      /* c1 */
00626         T);                         /* Estimated travel time                              */
00627 }
00628 
00629 void CLBLMaths::DoDebug()
00630 {
00631 
00632     
00633 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines