Sirf Protocol Help

Hello Everybody:

Im trying to use the binary mode in this GPS: http://www.sparkfun.com/commerce/produc … ts_id=8621

The problem is that i have no idea how to convert the position XYZ data (in meters),

to degrees (lat and lon) and altitude…

To give an idea what im talking about, please check the page 48 on this data sheet:

http://www.usglobalsat.com/downloads/Si … otocol.pdf

On message ID #4

Any idea?

Thanks very much JOrdi

It looks like message ID 41 (page 87) contains the lat and lon you are looking for.

Hope this helps.

gm

If you want to tackle it head on, here is some code based on Kai and Borre’s “Linear algebra, Geodesy and GPS”. The routine converts xyz coordinates to lat/lon in radians. (The open source “gps toolkit” also has a version.)

“a” and “f” are constants describing the shape of the earth ellipsoid. For WGS84, they are set to 6378137.0 and 1.0/298.2572235630 respectively.

void XYZToGeod(double a, double f,

double x, double y, double z,

double& phi, double& lambda, double& h)

{

debug(“XYZToGeod a=%.3f f=%.6f x=%.3f y=%.3f z=%.3f\n”, a,f,x,y,z);

// set up some constants

double r = sqrt(xx + yy);

// Iterate. Converges quickly. Do a fixed number of iterations for now.

h = 0;

double sinphi = 0;

for (int i=0; i<10; i++) {

double N = a / sqrt(1 - f*(2-f)sinphisinphi);

phi = atan2(z, r*(1 - f*(2-f)*N/(N+h)));

h = r / cos(phi) - N;

sinphi = sin(phi);

debug(" N=%.3f h=%.3f phi=%.6f\n", N, h, RadToDeg(phi));

}

// calculate longitude

lambda = atan2(y,x);

debug(" lambda=%.3f phi=%.3f h=%.3f\n",

RadToDeg(lambda),RadToDeg(phi),h);

}