Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtkpos: rework antenna offsets, line of sight vectors per freq #543

Open
wants to merge 8 commits into
base: demo5
Choose a base branch
from
89 changes: 52 additions & 37 deletions app/consapp/rtkrcv/rtkrcv.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,41 +362,52 @@ static int readcmd(const char *file, char *cmd, int type)
fclose(fp);
return 1;
}
/* read antenna file ---------------------------------------------------------*/
static void readant(vt_t *vt, prcopt_t *opt, nav_t *nav)
{
const pcv_t pcv0={0};
pcvs_t pcvr={0},pcvs={0};
pcv_t *pcv;
gtime_t time=timeget();
int i;

trace(3,"readant:\n");

opt->pcvr[0]=opt->pcvr[1]=pcv0;
if (!*filopt.rcvantp) return;

if (readpcv(filopt.rcvantp,&pcvr)) {
for (i=0;i<2;i++) {
if (!*opt->anttype[i]) continue;
if (!(pcv=searchpcv(0,opt->anttype[i],time,&pcvr))) {
vt_printf(vt,"no antenna %s in %s",opt->anttype[i],filopt.rcvantp);
continue;
}
opt->pcvr[i]=*pcv;
/* Read antenna file ---------------------------------------------------------*/
static void readant(vt_t *vt, prcopt_t *opt, nav_t *nav, pcvs_t *pcvsr) {
trace(3, "readant:\n");

const pcv_t pcv0 = {0};
opt->pcvr[0] = opt->pcvr[1] = pcv0;

if (*filopt.rcvantp) {
gtime_t time = timeget();
if (readpcv(filopt.rcvantp, 2, pcvsr)) {
for (int i = 0; i < 2; i++) {
if (!*opt->anttype[i]) continue;
pcv_t *pcv = searchpcv(0, opt->anttype[i], time, NULL, pcvsr);
if (!pcv) {
vt_printf(vt, "no antenna %s in %s", opt->anttype[i], filopt.rcvantp);
continue;
}
}
else vt_printf(vt,"antenna file open error %s",filopt.rcvantp);

if (readpcv(filopt.satantp,&pcvs)) {
for (i=0;i<MAXSAT;i++) {
if (!(pcv=searchpcv(i+1,"",time,&pcvs))) continue;
nav->pcvs[i]=*pcv;
copy_pcv(&opt->pcvr[i], pcv);
}
} else
vt_printf(vt, "antenna file open error %s", filopt.rcvantp);
}

if (*filopt.satantp) {
satsvns_t satsvns = {0};
if (*filopt.satmeta && !readsinex(filopt.satmeta, &satsvns))
vt_printf(vt, "error : reading sat meta sinex %s", filopt.satmeta);

pcvs_t pcvs = {0};
if (readpcv(filopt.satantp, 1, &pcvs)) {
gtime_t time = timeget();
for (int i = 0; i < MAXSAT; i++) {
pcv_t *pcv = searchpcv(i + 1, "", time, &satsvns, &pcvs);
if (!pcv) {
char id[8];
satno2id(i + 1, id);
vt_printf(vt, "no satellite %s pcv in %s", id, filopt.satantp);
continue;
}
}
else vt_printf(vt,"antenna file open error %s",filopt.satantp);

free(pcvr.pcv); free(pcvs.pcv);
copy_pcv(&nav->pcvs[i], pcv);
}
free_pcvs(&pcvs);
} else
vt_printf(vt, "antenna file open error %s", filopt.satantp);
free(satsvns.satsvn);
}
}
/* start rtk server ----------------------------------------------------------*/
static int startsvr(vt_t *vt)
Expand Down Expand Up @@ -440,9 +451,9 @@ static int startsvr(vt_t *vt)
pos[1]=nmeapos[1]*D2R;
pos[2]=nmeapos[2];
pos2ecef(pos,npos);

/* read antenna file */
readant(vt,&prcopt,&svr.nav);
readant(vt,&prcopt,&svr.nav,&svr.pcvsr);

/* read dcb file */
if (*filopt.dcb) {
Expand Down Expand Up @@ -523,6 +534,10 @@ static void stopsvr(vt_t *vt)
#endif
if (solopt[0].geoid>0) closegeoid();

for (int i = 0; i < 2; i++) free_pcv(&prcopt.pcvr[i]);
free_pcvs(&svr.pcvsr);
for (int i = 0; i < MAXSAT; i++) free_pcv(&svr.nav.pcvs[i]);

vt_printf(vt,"stop rtk server\n");
}
/* print time ----------------------------------------------------------------*/
Expand Down Expand Up @@ -771,10 +786,10 @@ static void prstatus(vt_t *vt)
vt_printf(vt,"%-28s: %d\n","# of average single pos base",nave);
vt_printf(vt,"%-28s: %s\n","ant type rover",rtk.opt.pcvr[0].type);
del=rtk.opt.antdel[0];
vt_printf(vt,"%-28s: %.3f %.3f %.3f\n","ant delta rover",del[0],del[1],del[2]);
vt_printf(vt,"%-28s: %.4f %.4f %.4f\n","ant delta rover",del[0],del[1],del[2]);
vt_printf(vt,"%-28s: %s\n","ant type base" ,rtk.opt.pcvr[1].type);
del=rtk.opt.antdel[1];
vt_printf(vt,"%-28s: %.3f %.3f %.3f\n","ant delta base",del[0],del[1],del[2]);
vt_printf(vt,"%-28s: %.4f %.4f %.4f\n","ant delta base",del[0],del[1],del[2]);
ecef2enu(pos,rtk.rb+3,vel);
vt_printf(vt,"%-28s: %.3f,%.3f,%.3f\n","vel enu (m/s) base",
vel[0],vel[1],vel[2]);
Expand Down
60 changes: 48 additions & 12 deletions app/qtapp/appcmn_qt/navi_post_opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ OptDialog::OptDialog(QWidget *parent, int opts)
fileOptions.geoid[0] = '\0';
fileOptions.iono[0] = '\0';
fileOptions.rcvantp[0] = '\0';
fileOptions.satmeta[0] = '\0';
fileOptions.satantp[0] = '\0';
fileOptions.solstat[0] = '\0';
fileOptions.stapos[0] = '\0';
Expand Down Expand Up @@ -200,6 +201,7 @@ OptDialog::OptDialog(QWidget *parent, int opts)
fileCompleter->setModel(fileModel);
ui->lEStationPositionFile->setCompleter(fileCompleter);
ui->lEAntennaPcvFile->setCompleter(fileCompleter);
ui->lESatelliteMetaFile->setCompleter(fileCompleter);
ui->lESatellitePcvFile->setCompleter(fileCompleter);
ui->lEDCBFile->setCompleter(fileCompleter);
ui->lEGeoidDataFile->setCompleter(fileCompleter);
Expand All @@ -220,7 +222,14 @@ OptDialog::OptDialog(QWidget *parent, int opts)
acStationPositionFileView->setToolTip(tr("View File"));
acStationPositionFileView->setEnabled(false);

// satllite PCV line edit actions
// Satellite meta data line edit actions
QAction *acSatelliteMetaFileSelect = ui->lESatelliteMetaFile->addAction(QIcon(":/buttons/folder"), QLineEdit::TrailingPosition);
acSatelliteMetaFileSelect->setToolTip(tr("Select File"));
QAction *acSatelliteMetaFileView = ui->lESatelliteMetaFile->addAction(QIcon(":/buttons/doc"), QLineEdit::TrailingPosition);
acSatelliteMetaFileView->setToolTip(tr("View File"));
acSatelliteMetaFileView->setEnabled(false);

// satellite PCV line edit actions
QAction *acSatellitePcvFileSelect = ui->lESatellitePcvFile->addAction(QIcon(":/buttons/folder"), QLineEdit::TrailingPosition);
acSatellitePcvFileSelect->setToolTip(tr("Select File"));
QAction *acSatellitePcvFileView = ui->lESatellitePcvFile->addAction(QIcon(":/buttons/doc"), QLineEdit::TrailingPosition);
Expand Down Expand Up @@ -271,6 +280,8 @@ OptDialog::OptDialog(QWidget *parent, int opts)
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &OptDialog::reject);
connect(ui->btnLoad, &QPushButton::clicked, this, &OptDialog::loadSettings);
connect(ui->btnSave, &QPushButton::clicked, this, &OptDialog::saveSettings);
connect(acSatelliteMetaFileSelect, &QAction::triggered, this, &OptDialog::selectSatelliteMetaFile);
connect(acSatelliteMetaFileView, &QAction::triggered, this, &OptDialog::viewSatelliteMetaFile);
connect(acAntennaPcvFileSelect, &QAction::triggered, this, &OptDialog::selectAntennaPcvFile);
connect(acAntennaPcvFileView, &QAction::triggered, this, &OptDialog::viewAntennaPcvFile);
connect(ui->lEAntennaPcvFile, &QLineEdit::textChanged, this, [acAntennaPcvFileView, this]()
Expand Down Expand Up @@ -504,6 +515,23 @@ void OptDialog::selectReferencePosition()
setPosition(ui->cBReferencePositionType->currentIndex(), edit, p);
}
//---------------------------------------------------------------------------
void OptDialog::viewSatelliteMetaFile()
{
if (ui->lESatelliteMetaFile->text().isEmpty()) return;

textViewer->read(ui->lESatelliteMetaFile->text());

textViewer->show();
}
//---------------------------------------------------------------------------
void OptDialog::selectSatelliteMetaFile()
{
QString filename = QFileDialog::getOpenFileName(this, tr("Satellite Meta Data Sinex File"), ui->lESatelliteMetaFile->text(), tr("Sinex File (*.snx);All (*.*)"));

if (!filename.isEmpty())
ui->lESatelliteMetaFile->setText(QDir::toNativeSeparators(filename));
}
//---------------------------------------------------------------------------
void OptDialog::viewSatellitePcvFile()
{
if (ui->lESatellitePcvFile->text().isEmpty()) return;
Expand Down Expand Up @@ -650,13 +678,14 @@ void OptDialog::updateOptions()
QLineEdit *editu[] = {ui->lERoverPosition1, ui->lERoverPosition2, ui->lERoverPosition3 };
QLineEdit *editr[] = {ui->lEReferencePosition1, ui->lEReferencePosition2, ui->lEReferencePosition3 };
pcvs_t pcvr;
pcv_t *pcv, pcv0;
pcv_t pcv0;
gtime_t time = timeget();

memset(&pcvr, 0, sizeof(pcvs_t));
memset(&pcv0, 0, sizeof(pcv_t));

// file options
strncpy(fileOptions.satmeta, qPrintable(ui->lESatelliteMetaFile->text()), MAXSTRPATH-1);
strncpy(fileOptions.satantp, qPrintable(ui->lESatellitePcvFile->text()), MAXSTRPATH-1);
strncpy(fileOptions.rcvantp, qPrintable(ui->lEAntennaPcvFile->text()), MAXSTRPATH-1);
strncpy(fileOptions.stapos, qPrintable(ui->lEStationPositionFile->text()), MAXSTRPATH-1);
Expand Down Expand Up @@ -797,24 +826,27 @@ void OptDialog::updateOptions()
}

processingOptions.pcvr[0] = processingOptions.pcvr[1] = pcv0; // initialize antenna PCV
if ((ui->cBRoverAntennaPcv->isChecked() || ui->cBReferenceAntennaPcv->isChecked()) && !readpcv(fileOptions.rcvantp, &pcvr)) {
if ((ui->cBRoverAntennaPcv->isChecked() || ui->cBReferenceAntennaPcv->isChecked()) && !readpcv(fileOptions.rcvantp, 2, &pcvr)) {
QMessageBox::warning(this, tr("Error"), tr("Antenna file read error: \"%1\"").arg(fileOptions.rcvantp));
return;
}
if (ui->cBRoverAntennaPcv->isChecked() && (processingOptions.anttype[0] != QStringLiteral("*"))) {
if ((pcv = searchpcv(0, processingOptions.anttype[0], time, &pcvr)))
processingOptions.pcvr[0] = *pcv;
pcv_t *pcv = searchpcv(0, processingOptions.anttype[0], time, NULL, &pcvr);
if (pcv)
copy_pcv(&processingOptions.pcvr[0], pcv);
else
QMessageBox::warning(this, tr("Error"), tr("No rover antenna PCV: \"%1\"").arg(processingOptions.anttype[0]));
}
if (ui->cBReferenceAntennaPcv->isChecked()&& (processingOptions.anttype[1] != QStringLiteral("*"))) {
if ((pcv = searchpcv(0, processingOptions.anttype[1], time, &pcvr)))
processingOptions.pcvr[1] = *pcv;
pcv_t *pcv = searchpcv(0, processingOptions.anttype[1], time, NULL, &pcvr);
if (pcv)
copy_pcv(&processingOptions.pcvr[1], pcv);
else
QMessageBox::warning(this, tr("Error"), tr("No reference station antenna PCV: \"%1\"").arg(processingOptions.anttype[1]));
}
if (ui->cBRoverAntennaPcv->isChecked() || ui->cBReferenceAntennaPcv->isChecked())
free(pcvr.pcv);
if (ui->cBRoverAntennaPcv->isChecked() || ui->cBReferenceAntennaPcv->isChecked()) {
free_pcvs(&pcvr);
}
fillExcludedSatellites(&processingOptions, ui->lEExcludedSatellites->text());
processingOptions.maxaveep = ui->sBMaxAveEp->value();
processingOptions.initrst = ui->cBInitRestart->isChecked();
Expand Down Expand Up @@ -1041,6 +1073,7 @@ void OptDialog::load(const QString &file)
ui->sBMaxSolutionStd->setValue(solopt.maxsolstd);

// file options
ui->lESatelliteMetaFile->setText(filopt.satmeta);
ui->lESatellitePcvFile->setText(filopt.satantp);
ui->lEAntennaPcvFile->setText(filopt.rcvantp);
ui->lEStationPositionFile->setText(filopt.stapos);
Expand Down Expand Up @@ -1215,6 +1248,7 @@ void OptDialog::save(const QString &file)
strncpy(solOpts.sep, qPrintable(ui->lEFieldSeperator->text()), 63);
solOpts.maxsolstd = ui->sBMaxSolutionStd->value();

strncpy(filopt.satmeta, qPrintable(ui->lESatelliteMetaFile->text()), MAXSTRPATH-1);
strncpy(filopt.satantp, qPrintable(ui->lESatellitePcvFile->text()), MAXSTRPATH-1);
strncpy(filopt.rcvantp, qPrintable(ui->lEAntennaPcvFile->text()), MAXSTRPATH-1);
strncpy(filopt.stapos, qPrintable(ui->lEStationPositionFile->text()), MAXSTRPATH-1);
Expand Down Expand Up @@ -1388,6 +1422,7 @@ void OptDialog::saveOptions(QSettings &settings)
settings.setValue("prcopt/outsingle", processingOptions.outsingle);
settings.setValue("solopt/maxsolstd", ui->sBMaxSolutionStd->value());

settings.setValue("setting/satmetafile", ui->lESatelliteMetaFile->text());
settings.setValue("setting/satpcvfile", ui->lESatellitePcvFile->text());
settings.setValue("setting/antpcvfile", ui->lEAntennaPcvFile->text());
settings.setValue("setting/staposfile", ui->lEStationPositionFile->text());
Expand Down Expand Up @@ -1533,6 +1568,7 @@ void OptDialog::loadOptions(QSettings &settings)
ui->sBBaselineLen->setValue(settings.value("prcopt/baseline1", 0.0).toDouble());
ui->sBBaselineSig->setValue(settings.value("prcopt/baseline2", 0.0).toDouble());

ui->lESatelliteMetaFile->setText(settings.value("setting/satmetafile", "").toString());
ui->lESatellitePcvFile->setText(settings.value("setting/satpcvfile", "").toString());
ui->lEAntennaPcvFile->setText(settings.value("setting/antpcvfile", "").toString());
readAntennaList();
Expand Down Expand Up @@ -1906,7 +1942,7 @@ void OptDialog::readAntennaList()
QString currentRoverAntenna, currentReferenceAntenna;
int i;

if (!readpcv(qPrintable(ui->lEAntennaPcvFile->text()), &pcvs)) return;
if (!readpcv(qPrintable(ui->lEAntennaPcvFile->text()), 2, &pcvs)) return;

/* Save currently defined antennas */
currentRoverAntenna = ui->cBRoverAntenna->currentText();
Expand All @@ -1920,7 +1956,7 @@ void OptDialog::readAntennaList()
ui->cBRoverAntenna->addItem("*"); ui->cBReferenceAntenna->addItem("*");

for (int i = 0; i < pcvs.n; i++) {
if (pcvs.pcv[i].sat) continue;
if (pcvs.pcv[i].sat || pcvs.pcv[i].svn) continue;
if ((p = strchr(pcvs.pcv[i].type, ' '))) *p = '\0';
if (i > 0 && !strcmp(pcvs.pcv[i].type, pcvs.pcv[i - 1].type)) continue;
ui->cBRoverAntenna->addItem(pcvs.pcv[i].type);
Expand All @@ -1933,7 +1969,7 @@ void OptDialog::readAntennaList()
i = ui->cBReferenceAntenna->findText(currentReferenceAntenna);
ui->cBReferenceAntenna->setCurrentIndex(i == -1 ? 0 : i);

free(pcvs.pcv);
free_pcvs(&pcvs);
}
//---------------------------------------------------------------------------
void OptDialog::showKeyDialog()
Expand Down
2 changes: 2 additions & 0 deletions app/qtapp/appcmn_qt/navi_post_opt.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ protected slots:
void selectPanelFont();
void selectSolutionFont();
void selectGeoidDataFile();
void viewSatelliteMetaFile();
void selectSatelliteMetaFile();
void viewSatellitePcvFile();
void selectSatellitePcvFile();
void selectLocalDirectory();
Expand Down
Loading