  Visual-Inertial odometry (VIO) is known to suffer from drifting especially
over long-term runs. In this paper, we present GVINS, a non-linear optimization
based system that tightly fuses GNSS raw measurements with visual and inertial
information for real-time and drift-free state estimation. Our system aims to
provide accurate global 6-DoF estimation under complex indoor-outdoor
environment where GNSS signals may be intermittent or even totally unavailable.
To connect global measurements with local states, a coarse-to-fine
initialization procedure is proposed to efficiently calibrate the
transformation online and initialize GNSS states from only a short window of
measurements. The GNSS code pseudorange and Doppler shift measurements, along
with visual and inertial information, are then modelled and used to constrain
the system states in a factor graph framework. For complex and GNSS-unfriendly
areas, the degenerate cases are discussed and carefully handled to ensure
robustness. Thanks to the tightly-coupled multi-sensor approach and system
design, our system fully exploits the merits of three types of sensors and is
capable to seamlessly cope with the transition between indoor and outdoor
environments, where satellites are lost and reacquired. We extensively evaluate
the proposed system by both simulation and real-world experiments, and the
result demonstrates that our system substantially eliminates the drift of VIO
and preserves the local accuracy in spite of noisy GNSS measurements. The
challenging indoor-outdoor and urban driving experiments verify the
availability and robustness of GVINS in complex environments. In addition,
experiments also show that our system can gain from even a single satellite
while conventional GNSS algorithms need four at least.
