Merge pull request #13 from scateu/master

Add static location mode
This commit is contained in:
OSQZSS 2015-07-15 08:57:23 +09:00
commit d7a65c2e69
2 changed files with 65 additions and 25 deletions

View File

@ -37,13 +37,14 @@ Doppler for the GPS satellites in view. This simulated range data is
then used to generate the digitized I/Q samples for the GPS signal. then used to generate the digitized I/Q samples for the GPS signal.
The bladeRF command line interface requires I/Q pairs stored as signed The bladeRF command line interface requires I/Q pairs stored as signed
16-bit integers, while the hackrf_transfere supports signed bytes. 16-bit integers, while the hackrf_transfer supports signed bytes.
``` ```
Usage: gps-sdr-sim [options] Usage: gps-sdr-sim [options]
Options: Options:
-e <gps_nav> RINEX navigation file for GPS ephemerides (required) -e <gps_nav> RINEX navigation file for GPS ephemerides (required)
-u <user_motion> User motion file (required) -u <user_motion> User motion file
-l <location> Latitude,Longitude,Height (static mode) eg: 30.286502,120.032669,100
-o <output> I/Q sampling data file (default: gpssim.bin) -o <output> I/Q sampling data file (default: gpssim.bin)
-s <frequency> Sampling frequency [Hz] (default: 2600000) -s <frequency> Sampling frequency [Hz] (default: 2600000)
-b <iq_bits> I/Q data format [8/16] (default: 8) -b <iq_bits> I/Q data format [8/16] (default: 8)
@ -55,6 +56,10 @@ For example:
> gps-sdr-sim -e brdc3540.14n -u circle.csv -b 16 > gps-sdr-sim -e brdc3540.14n -u circle.csv -b 16
``` ```
```
> gps-sdr-sim -e brdc3540.14n -l 30.286502,120.032669,100 -b 16
```
### Transmitting the samples ### Transmitting the samples
The TX port of a particular SDR platform is connected to the GPS receiver The TX port of a particular SDR platform is connected to the GPS receiver

View File

@ -12,6 +12,12 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifndef bool
typedef int bool;
#define true 1
#define false 0
#endif
#define MAX_CHAR (100) #define MAX_CHAR (100)
#define MAX_SAT (32) #define MAX_SAT (32)
@ -299,7 +305,7 @@ void xyz2llh(double *xyz, double *llh)
return; return;
} }
/*
void llh2xyz(double *llh, double *xyz) void llh2xyz(double *llh, double *xyz)
{ {
double n; double n;
@ -333,7 +339,7 @@ void llh2xyz(double *llh, double *xyz)
return; return;
} }
*/
void ltcmat(double *llh, double t[3][3]) void ltcmat(double *llh, double t[3][3])
{ {
double slat, clat; double slat, clat;
@ -1070,7 +1076,8 @@ void usage(void)
printf("Usage: gps-sdr-sim [options]\n" printf("Usage: gps-sdr-sim [options]\n"
"Options:\n" "Options:\n"
" -e <gps_nav> RINEX navigation file for GPS ephemerides (required)\n" " -e <gps_nav> RINEX navigation file for GPS ephemerides (required)\n"
" -u <user_motion> User motion file (required)\n" " -u <user_motion> User motion file \n"
" -l <location> Latitude,Longitude,Height (static mode) eg: 30.286502,120.032669,100\n"
" -o <output> I/Q sampling data file (default: gpssim.bin)\n" " -o <output> I/Q sampling data file (default: gpssim.bin)\n"
" -s <frequency> Sampling frequency [Hz] (default: 2600000)\n" " -s <frequency> Sampling frequency [Hz] (default: 2600000)\n"
" -b <iq_bits> I/Q data format [8/16] (default: 8)\n"); " -b <iq_bits> I/Q data format [8/16] (default: 8)\n");
@ -1125,6 +1132,7 @@ int main(int argc, char *argv[])
int iumd; int iumd;
int numd; int numd;
char umfile[MAX_CHAR]; char umfile[MAX_CHAR];
bool staticLocationMode = false;
double xyz[USER_MOTION_SIZE][3]; double xyz[USER_MOTION_SIZE][3];
char navfile[MAX_CHAR]; char navfile[MAX_CHAR];
@ -1153,7 +1161,7 @@ int main(int argc, char *argv[])
exit(1); exit(1);
} }
while ((result=getopt(argc,argv,"e:u:o:s:b:"))!=-1) while ((result=getopt(argc,argv,"e:u:l:o:s:b:"))!=-1)
{ {
switch (result) switch (result)
{ {
@ -1163,6 +1171,14 @@ int main(int argc, char *argv[])
case 'u': case 'u':
strcpy(umfile, optarg); strcpy(umfile, optarg);
break; break;
case 'l':
// static llh coordinate input mode.
// add by scateu@gmail.com
staticLocationMode = true;
sscanf(optarg,"%lf,%lf,%lf",&llh[0],&llh[1],&llh[2]);
llh[0] = llh[0] / R2D; // convert to RAD
llh[1] = llh[1] / R2D; // convert to RAD
break;
case 'o': case 'o':
strcpy(outfile, optarg); strcpy(outfile, optarg);
break; break;
@ -1197,9 +1213,10 @@ int main(int argc, char *argv[])
exit(1); exit(1);
} }
if (umfile[0]==0) if (umfile[0]==0 && !staticLocationMode)
{ {
printf("User motion file is not specified.\n"); printf("User motion file is not specified.\n");
printf("Or you may use -l to specify llh coordinate directly.\n");
exit(1); exit(1);
} }
@ -1214,27 +1231,45 @@ int main(int argc, char *argv[])
// Receiver position // Receiver position
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Read user motion file
numd = readUserMotion(xyz, umfile);
if (numd==-1) if (!staticLocationMode)
{ {
printf("Failed to open user motion file.\n"); // Read user motion file
exit(1); numd = readUserMotion(xyz, umfile);
if (numd==-1)
{
printf("Failed to open user motion file.\n");
exit(1);
}
else if (numd==0)
{
printf("Failed to read user motion data.\n");
exit(1);
}
printf("User motion data = %d\n", numd);
// Initial location in Geodetic coordinate system
xyz2llh(xyz[0], llh);
printf("xyz = %11.1f, %11.1f, %11.1f\n", xyz[0][0], xyz[0][1], xyz[0][2]);
printf("llh = %11.6f, %11.6f, %11.1f\n", llh[0]*R2D, llh[1]*R2D, llh[2]);
} else {
// static llh coordinate input mode. "-l"
// add by scateu@gmail.com
printf("Using static location mode.\n");
llh2xyz(llh,xyz[0]); // convert llh to xyz
printf("xyz = %11.1f, %11.1f, %11.1f\n", xyz[0][0], xyz[0][1], xyz[0][2]);
printf("llh = %11.6f, %11.6f, %11.1f\n", llh[0]*R2D, llh[1]*R2D, llh[2]);
numd = USER_MOTION_SIZE;
for (int i=1;i<numd;i++) {
xyz[i][0] = xyz[0][0];
xyz[i][1] = xyz[0][1];
xyz[i][2] = xyz[0][2];
}
} }
else if (numd==0)
{
printf("Failed to read user motion data.\n");
exit(1);
}
printf("User motion data = %d\n", numd);
// Initial location in Geodetic coordinate system
xyz2llh(xyz[0], llh);
printf("xyz = %11.1f, %11.1f, %11.1f\n", xyz[0][0], xyz[0][1], xyz[0][2]);
printf("llh = %11.6f, %11.6f, %11.1f\n", llh[0]*R2D, llh[1]*R2D, llh[2]);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Read ephemeris // Read ephemeris