Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gnss_utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
labrobotica
algorithms
gnss_utils
Commits
d438dde7
Commit
d438dde7
authored
5 years ago
by
Joan Vallvé Navarro
Browse files
Options
Downloads
Patches
Plain Diff
test adapted to new api
parent
19139a42
No related branches found
No related tags found
2 merge requests
!20
new tag
,
!19
new tag
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/examples/gnss_utils_test.cpp
+17
-169
17 additions, 169 deletions
src/examples/gnss_utils_test.cpp
with
17 additions
and
169 deletions
src/examples/gnss_utils_test.cpp
+
17
−
169
View file @
d438dde7
...
...
@@ -15,148 +15,33 @@ extern "C"
using
namespace
GNSSUtils
;
int
createObsAndNav
(
Observations
&
observations
,
const
char
*
obs_path
,
Navigation
&
navigation
,
const
char
*
nav_path
)
int
main
(
int
argc
,
char
*
argv
[])
{
// Time
double
ts_d
[]
=
{
2018
,
5
,
17
,
14
,
1
,
2
};
gtime_t
ts
=
epoch2time
(
ts_d
);
double
te_d
[]
=
{
2018
,
5
,
17
,
14
,
42
,
8
};
gtime_t
te
=
epoch2time
(
te_d
);
double
tint
=
0.1
;
// Create options container
const
char
*
opt
=
"-SYS=G"
;
// Create receiver identifier
int
rcv
=
1
;
// Create object types
// rnxopt_t rnx_opt;
// Create obsd_t object to hold the observations
obs_t
obs
;
obs
.
data
=
(
obsd_t
*
)
malloc
(
sizeof
(
obsd_t
)
*
MAXSAT
);
obs
.
n
=
0
;
obs
.
nmax
=
MAXSAT
;
/* header */
std
::
cout
<<
"------------"
<<
std
::
endl
;
std
::
cout
<<
"Observations"
<<
std
::
endl
;
std
::
cout
<<
"------------"
<<
std
::
endl
;
if
(
readrnx
(
obs_path
,
rcv
,
opt
,
&
obs
,
NULL
,
NULL
))
{
sortobs
(
&
obs
);
//obs.data[0].P[0] = 21597659.275;
//obs.data[1].P[0] = 22348322.550;
//obs.data[2].P[0] = 20873167.574;
//obs.data[3].P[0] = 20920707.830;
std
::
cout
<<
"Obs number: "
<<
obs
.
n
<<
std
::
endl
;
}
else
{
std
::
cout
<<
"Couldn't load provided observation file"
<<
std
::
endl
;
return
0
;
}
for
(
int
i
=
0
;
i
<
obs
.
n
;
i
++
)
{
std
::
cout
<<
"time: "
<<
time_str
(
obs
.
data
[
i
].
time
,
3
)
<<
" | sat: "
<<
int
(
obs
.
data
[
i
].
sat
)
<<
" | rcv: "
<<
int
(
obs
.
data
[
i
].
rcv
)
<<
" | SNR: "
<<
int
(
obs
.
data
[
i
].
SNR
[
0
])
<<
" | LLI: "
<<
int
(
obs
.
data
[
i
].
LLI
[
0
])
<<
" | code: "
<<
int
(
obs
.
data
[
i
].
code
[
0
])
<<
" | L: "
<<
obs
.
data
[
i
].
L
[
0
]
<<
" | P: "
<<
obs
.
data
[
i
].
P
[
0
]
<<
" | D: "
<<
obs
.
data
[
i
].
D
[
0
]
<<
std
::
endl
;
observations
.
addObservation
(
obs
.
data
[
i
]);
}
free
(
obs
.
data
);
observations
.
print
();
/* header */
std
::
cout
<<
"----------"
<<
std
::
endl
;
std
::
cout
<<
"Navigation"
<<
std
::
endl
;
std
::
cout
<<
"----------"
<<
std
::
endl
;
/* Load _nav attribute into nav variable */
//nav_t nav = navigation.getNavigation();
if
(
readrnx
(
nav_path
,
1
,
opt
,
NULL
,
&
navigation
.
getNavigation
(),
NULL
))
{
std
::
cout
<<
"Navigation file loaded."
<<
std
::
endl
;
std
::
cout
<<
"GPS satellites in navigation file: "
<<
navigation
.
getNavigation
().
n
<<
std
::
endl
;
std
::
cout
<<
"GLONASS satellites in navigation file: "
<<
navigation
.
getNavigation
().
ng
<<
std
::
endl
;
std
::
cout
<<
"SBAS satellites in navigation file: "
<<
navigation
.
getNavigation
().
ns
<<
std
::
endl
;
std
::
cout
<<
"Almanac satellites in navigation file: "
<<
navigation
.
getNavigation
().
na
<<
std
::
endl
;
uniqnav
(
&
navigation
.
getNavigation
());
}
else
{
std
::
cout
<<
"Couldn't load provided navigation file"
<<
std
::
endl
;
return
0
;
}
/* Print Constellation Satellites ids */
for
(
int
i
=
0
;
i
<
navigation
.
getNavigation
().
n
;
i
++
)
{
std
::
cout
<<
i
<<
" GPS Sat Id: "
<<
navigation
.
getNavigation
().
eph
[
i
].
sat
<<
std
::
endl
;
}
for
(
int
i
=
0
;
i
<
navigation
.
getNavigation
().
ng
;
i
++
)
{
std
::
cout
<<
i
<<
" GLONASS Sat Id: "
<<
navigation
.
getNavigation
().
geph
[
i
].
sat
<<
std
::
endl
;
}
for
(
int
i
=
0
;
i
<
navigation
.
getNavigation
().
ns
;
i
++
)
{
std
::
cout
<<
i
<<
" SBAS Sat Id: "
<<
navigation
.
getNavigation
().
seph
[
i
].
sat
<<
std
::
endl
;
}
std
::
cout
<<
"--------------------------"
<<
std
::
endl
;
std
::
cout
<<
"GNSS Utils Library Example"
<<
std
::
endl
;
std
::
cout
<<
"--------------------------"
<<
std
::
endl
;
/* Load nav into Navigation object*/
//navigation.setNavigation(nav);
std
::
cout
<<
"Navigation message loaded to Navigation class."
<<
std
::
endl
;
// create Observations object
Observations
observations
;
return
1
;
}
// create Navigation object
Navigation
navigation
;
void
createObsAndNavNew
(
Observations
&
observations
,
const
std
::
string
&
obs_path
,
Navigation
&
navigation
,
const
std
::
string
&
nav_path
)
{
gtime_t
t_start
{
0
,
0
};
// no limit
gtime_t
t_end
{
0
,
0
};
// no limit
double
dt
=
0.0
;
// no limit
const
char
*
opt
=
"-SYS=G"
;
// only GPS | GPS+GAL: "-SYS=G,L" | ALL: ""
observations
.
loadFromRinex
(
obs_path
,
t_start
,
t_end
,
dt
,
opt
);
// load observations from RINEX file
observations
.
loadFromRinex
(
"../src/examples/raw_201805171357.obs"
,
t_start
,
t_end
,
dt
,
opt
);
observations
.
print
();
navigation
.
loadFromRinex
(
nav_path
,
t_start
,
t_end
,
dt
,
opt
);
// load navigation from RINEX file
navigation
.
loadFromRinex
(
"../src/examples/raw_201805171357.nav"
,
t_start
,
t_end
,
dt
,
opt
);
navigation
.
print
();
}
int
main
(
int
argc
,
char
*
argv
[])
{
/* header */
std
::
cout
<<
"--------------------------"
<<
std
::
endl
;
std
::
cout
<<
"GNSS Utils Library Example"
<<
std
::
endl
;
std
::
cout
<<
"--------------------------"
<<
std
::
endl
;
// create Observations object
Observations
observations
,
observations2
;
// create Navigation object
Navigation
navigation
,
navigation2
;
createObsAndNav
(
observations
,
"../src/examples/raw_201805171357.obs"
,
navigation
,
"../src/examples/raw_201805171357.nav"
);
createObsAndNavNew
(
observations2
,
"../src/examples/raw_201805171357.obs"
,
navigation2
,
"../src/examples/raw_201805171357.nav"
);
/* Set processing options */
...
...
@@ -198,49 +83,12 @@ int main(int argc, char *argv[])
char
msg
[
128
]
=
""
;
std
::
cout
<<
"OBS1:
\n
"
;
std
::
vector
<
obsd_t
>
obs
=
observations
.
getObservations
();
for
(
int
i
=
0
;
i
<
obs
.
size
();
i
++
)
{
std
::
cout
<<
"time: "
<<
time_str
(
obs
[
i
].
time
,
3
)
<<
" | sat: "
<<
int
(
obs
[
i
].
sat
)
<<
" | rcv: "
<<
int
(
obs
[
i
].
rcv
)
<<
" | SNR: "
<<
int
(
obs
[
i
].
SNR
[
0
])
<<
" | LLI: "
<<
int
(
obs
[
i
].
LLI
[
0
])
<<
" | code: "
<<
int
(
obs
[
i
].
code
[
0
])
<<
" | L: "
<<
obs
[
i
].
L
[
0
]
<<
" | P: "
<<
obs
[
i
].
P
[
0
]
<<
" | D: "
<<
obs
[
i
].
D
[
0
]
<<
std
::
endl
;
}
std
::
cout
<<
"obs.size(): "
<<
obs
.
size
()
<<
std
::
endl
;
stat
=
pntpos
(
&
obs
[
0
],
obs
.
size
(),
&
navigation
.
getNavigation
(),
&
prcopt
,
&
solb
,
NULL
,
NULL
,
msg
);
std
::
cout
<<
"msg: "
<<
msg
<<
std
::
endl
;
std
::
cout
<<
"sol.stat: "
<<
int
(
solb
.
stat
)
<<
std
::
endl
;
std
::
cout
<<
"Position: "
<<
solb
.
rr
[
0
]
<<
", "
<<
solb
.
rr
[
1
]
<<
", "
<<
solb
.
rr
[
2
]
<<
std
::
endl
;
std
::
cout
<<
"Position GT: "
<<
latLonToEcef
(
lla_gt
).
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"Position LLA: "
<<
ecefToLatLon
(
Eigen
::
Vector3d
(
solb
.
rr
[
0
],
solb
.
rr
[
1
],
solb
.
rr
[
2
])).
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"Position GT LLA: "
<<
lla_gt
.
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"OBS2:
\n
"
;
std
::
vector
<
obsd_t
>
obs2
=
observations2
.
getObservations
();
for
(
int
i
=
0
;
i
<
obs2
.
size
();
i
++
)
{
std
::
cout
<<
"time: "
<<
time_str
(
obs2
[
i
].
time
,
3
)
<<
" | sat: "
<<
int
(
obs2
[
i
].
sat
)
<<
" | rcv: "
<<
int
(
obs2
[
i
].
rcv
)
<<
" | SNR: "
<<
int
(
obs2
[
i
].
SNR
[
0
])
<<
" | LLI: "
<<
int
(
obs2
[
i
].
LLI
[
0
])
<<
" | code: "
<<
int
(
obs2
[
i
].
code
[
0
])
<<
" | L: "
<<
obs2
[
i
].
L
[
0
]
<<
" | P: "
<<
obs2
[
i
].
P
[
0
]
<<
" | D: "
<<
obs2
[
i
].
D
[
0
]
<<
std
::
endl
;
}
std
::
cout
<<
"obs2.size(): "
<<
obs2
.
size
()
<<
std
::
endl
;
stat
=
pntpos
(
&
obs2
[
0
],
obs2
.
size
(),
&
navigation
.
getNavigation
(),
&
prcopt
,
&
solb
,
NULL
,
NULL
,
msg
);
stat
=
pntpos
(
observations
.
data
(),
observations
.
size
(),
&
navigation
.
getNavigation
(),
&
prcopt
,
&
solb
,
NULL
,
NULL
,
msg
);
std
::
cout
<<
"msg: "
<<
msg
<<
std
::
endl
;
std
::
cout
<<
"sol.stat: "
<<
int
(
solb
.
stat
)
<<
std
::
endl
;
std
::
cout
<<
"Position: "
<<
solb
.
rr
[
0
]
<<
", "
<<
solb
.
rr
[
1
]
<<
", "
<<
solb
.
rr
[
2
]
<<
std
::
endl
;
std
::
cout
<<
"Position GT: "
<<
latLonToEcef
(
lla_gt
).
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"Position LLA: "
<<
ecefToLatLon
(
Eigen
::
Vector3d
(
solb
.
rr
[
0
],
solb
.
rr
[
1
],
solb
.
rr
[
2
])).
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"Position GT LLA: "
<<
lla_gt
.
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"Position: "
<<
solb
.
rr
[
0
]
<<
", "
<<
solb
.
rr
[
1
]
<<
", "
<<
solb
.
rr
[
2
]
<<
std
::
endl
;
std
::
cout
<<
"Position (GT): "
<<
latLonToEcef
(
lla_gt
).
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"Position LLA: "
<<
ecefToLatLon
(
Eigen
::
Vector3d
(
solb
.
rr
[
0
],
solb
.
rr
[
1
],
solb
.
rr
[
2
])).
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"Position LLA (GT): "
<<
lla_gt
.
transpose
()
<<
std
::
endl
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment