Full Code of ChangwuLiu/InGVIO for AI

master_github eca739e894c6 cached
144 files
1019.3 KB
271.3k tokens
240 symbols
1 requests
Download .txt
Showing preview only (1,070K chars total). Download the full file or copy to clipboard to get everything.
Repository: ChangwuLiu/InGVIO
Branch: master_github
Commit: eca739e894c6
Files: 144
Total size: 1019.3 KB

Directory structure:
gitextract_o7z2p0ui/

├── .gitignore
├── README.md
├── camera_model/
│   ├── CMakeLists.txt
│   ├── LICENSE
│   ├── include/
│   │   ├── MeiCamera.h
│   │   ├── PinholeCamera.h
│   │   ├── camera.h
│   │   └── camera_factory.h
│   ├── package.xml
│   ├── src/
│   │   ├── MeiCamera.cpp
│   │   ├── PinholeCamera.cpp
│   │   ├── camera.cpp
│   │   └── camera_factory.cpp
│   └── test/
│       └── CMakeLists.txt
├── config/
│   ├── fw_zed2i_f9p/
│   │   ├── ingvio_mono.yaml
│   │   ├── ingvio_stereo.yaml
│   │   ├── mono_config.yaml
│   │   ├── stereo_left_config.yaml
│   │   └── stereo_right_config.yaml
│   └── sportsfield/
│       ├── ingvio_mono.yaml
│       ├── ingvio_stereo.yaml
│       ├── mono_config.yaml
│       ├── stereo_left_config.yaml
│       └── stereo_right_config.yaml
├── feature_tracker/
│   ├── CMakeLists.txt
│   ├── LICENSE
│   ├── include/
│   │   ├── Color.h
│   │   ├── mono_parameters.h
│   │   ├── mono_tracker.h
│   │   ├── random_pair.hpp
│   │   ├── stereo_parameters.h
│   │   ├── stereo_tracker.h
│   │   └── tic_toc.hpp
│   ├── launch/
│   │   └── sportsfield/
│   │       ├── mono_tracker_sf.launch
│   │       └── stereo_tracker_sf.launch
│   ├── msg/
│   │   ├── MonoFrame.msg
│   │   ├── MonoMeas.msg
│   │   ├── StereoFrame.msg
│   │   └── StereoMeas.msg
│   ├── package.xml
│   └── src/
│       ├── mono_parameters.cpp
│       ├── mono_tracker.cpp
│       ├── mono_tracker_node.cpp
│       ├── stereo_parameters.cpp
│       ├── stereo_tracker.cpp
│       └── stereo_tracker_node.cpp
├── gnss_comm/
│   ├── .gitignore
│   ├── CMakeLists.txt
│   ├── LICENSE
│   ├── README.md
│   ├── cmake/
│   │   ├── FindEigen.cmake
│   │   └── FindGlog.cmake
│   ├── docker/
│   │   ├── Dockerfile
│   │   └── Makefile
│   ├── include/
│   │   └── gnss_comm/
│   │       ├── gnss_constant.hpp
│   │       ├── gnss_ros.hpp
│   │       ├── gnss_spp.hpp
│   │       ├── gnss_utility.hpp
│   │       └── rinex_helper.hpp
│   ├── msg/
│   │   ├── GnssBestXYZMsg.msg
│   │   ├── GnssEphemMsg.msg
│   │   ├── GnssGloEphemMsg.msg
│   │   ├── GnssMeasMsg.msg
│   │   ├── GnssObsMsg.msg
│   │   ├── GnssPVTSolnMsg.msg
│   │   ├── GnssSvsMsg.msg
│   │   ├── GnssTimeMsg.msg
│   │   ├── GnssTimePulseInfoMsg.msg
│   │   └── StampedFloat64Array.msg
│   ├── package.xml
│   └── src/
│       ├── gnss_ros.cpp
│       ├── gnss_spp.cpp
│       ├── gnss_utility.cpp
│       └── rinex_helper.cpp
└── ingvio_estimator/
    ├── CMakeLists.txt
    ├── LICENSE
    ├── README.md
    ├── cmake/
    │   ├── FindSuiteSparse.cmake
    │   └── ROS1.cmake
    ├── launch/
    │   ├── ingvio_mono_fw.launch
    │   ├── ingvio_mono_fw_record.launch
    │   ├── ingvio_mono_sf.launch
    │   ├── ingvio_mono_sf_record.launch
    │   ├── ingvio_stereo_fw.launch
    │   ├── ingvio_stereo_fw_record.launch
    │   ├── ingvio_stereo_sf.launch
    │   └── ingvio_stereo_sf_record.launch
    ├── package.xml
    ├── rviz/
    │   ├── ingvio_mono.rviz
    │   └── ingvio_stereo.rviz
    ├── src/
    │   ├── AnchoredLandmark.cpp
    │   ├── AnchoredLandmark.h
    │   ├── AuxGammaFunc.cpp
    │   ├── AuxGammaFunc.h
    │   ├── Color.h
    │   ├── GnssData.cpp
    │   ├── GnssData.h
    │   ├── GnssManager.cpp
    │   ├── GnssManager.h
    │   ├── GnssProcessor.cpp
    │   ├── GnssSync.cpp
    │   ├── GnssSync.h
    │   ├── GnssUpdate.cpp
    │   ├── GnssUpdate.h
    │   ├── GvioAligner.cpp
    │   ├── GvioAligner.h
    │   ├── ImuPropagator.cpp
    │   ├── ImuPropagator.h
    │   ├── IngvioFilter.cpp
    │   ├── IngvioFilter.h
    │   ├── IngvioNode.cpp
    │   ├── IngvioParams.cpp
    │   ├── IngvioParams.h
    │   ├── KeyframeUpdate.cpp
    │   ├── KeyframeUpdate.h
    │   ├── LandmarkUpdate.cpp
    │   ├── LandmarkUpdate.h
    │   ├── MapServer.cpp
    │   ├── MapServer.h
    │   ├── MapServerManager.cpp
    │   ├── MapServerManager.h
    │   ├── PoseState.cpp
    │   ├── PoseState.h
    │   ├── RemoveLostUpdate.cpp
    │   ├── RemoveLostUpdate.h
    │   ├── State.cpp
    │   ├── State.h
    │   ├── StateManager.cpp
    │   ├── StateManager.h
    │   ├── SwMargUpdate.cpp
    │   ├── SwMargUpdate.h
    │   ├── TicToc.h
    │   ├── Triangulator.cpp
    │   ├── Triangulator.h
    │   ├── Update.cpp
    │   ├── Update.h
    │   ├── VecState.cpp
    │   └── VecState.h
    └── test/
        ├── GenerateNoise.cpp
        ├── GenerateNoise.h
        ├── TestMapServer.cpp
        ├── TestPropagator.cpp
        ├── TestStateManager.cpp
        └── TestTriangulator.cpp

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
*.kdev4


================================================
FILE: README.md
================================================
# InGVIO

An invariant filter for visual-inertial-raw GNSS fusion.

**Paper:** InGVIO: A Consistent Invariant Filter For Fast and High-Accuracy GNSS-Visual-Inertial Odometry

**Paper Author:** Changwu Liu, Chen Jiang and Haowen Wang

**Paper Status:** Manuscript submitted to RA-L for possible publication. Preprint version available on ArXiv.

**Current Paper Link:** https://arxiv.org/abs/2210.15145

InGVIO is an invariant filter approach for fusion of monocular/stereo camera, IMU and raw GNSS measurements including pseudo ranges and Doppler shifts. InGVIO is intrinsically consistent under conditional infinitesimal invariance of the GNSS-Visual-Inertial system. InGVIO has the following key features: (a) fast due to decoupled IMU propagation, key-frame marginalization strategy and no SLAM-features; (b) accurate due to intrinsic consistency maintenance; (c) better convergence properties than 'naive' EKF-based filters.

Moreover, we offer our fixed-wing datasets in the form of ROS Bags including stereo-visual, IMU and raw-GNSS measurements.

**Fixed-Wing Dataset Link:** https://cloud.tsinghua.edu.cn/d/65ecf6768563421faaed/
                             password to extract: LCW@uav_18
                            
**Fixed-Wing Dataset Videos:** The videos are uploaded to the link that stores the fixed-wing datasets.

The links to the datasets will be continuously updated. The config files for this dataset are contained in the InGVIO code configuration in path 'config/fw_zed2i_f9p'.

## 1. System Requirements

### 1.1  Support of C++ 14 Features

The compiler should at least support c++14 standards.

### 1.2  ROS-Noetic System

InGVIO is developed under [ROS-Noetic](http://wiki.ros.org/noetic/Installation/Ubuntu) with its default OpenCV4 library. However, InGVIO should be working on ROS-Melodic with OpenCV3. In the future, we may add support to ROS 2.

### 1.3  Eigen Library

Eigen is a fantastic matrix computation library. InGVIO is developed under [Eigen3.3.7](https://eigen.tuxfamily.org/index.php?title=Main_Page). Other Eigen 3 versions should be OK for InGVIO.

### 1.4  SuiteSparse Library

We use [SuiteSparse](https://github.com/DrTimothyAldenDavis/SuiteSparse/releases) Library for sparse QR-decomposition in visual updates. 

### 1.5  gnss_comm Library

A wrapper for GNSS messages in ROS. See [gnss_comm](https://github.com/HKUST-Aerial-Robotics/gnss_comm). The fantastic optimization-based work [GVINS](https://github.com/HKUST-Aerial-Robotics/GVINS) also relies on this library. We reserve a copy of gnss_comm in this repo.

## 2. Build InGVIO

Download or clone this repo to your ROS workspace.

```
cd ~/ws_catkin
catkin_make
```

Source the setup file to let ROS recognize the related launch files.

```
source devel/setup.bash
```

## 3. Run with Our Fixed-Wing Datasets

First download and unzip our fixed-wing dataset to your environment.

The 'fw_zed2i_f9p' folder contains the configuration files for fixed-wing datasets. To run InGVIO in your environment, the following should be conducted first.

Please adjust and modify the paths in 'config/fw_zed2i_f9p/ingvio_mono.yaml' and 'config/fw_zed2i_f9p/ingvio_stereo.yaml' to the case in your environment.

If you want to record the output topics, please set your output dir in 'ingvio/launch/ingvio_mono, stereo_fw_record.launch' files.

To run with monocular camera, please enter:

```
roslaunch ingvio_estimator ingvio_mono_fw.launch
```

For stereo-case, please enter:

```
roslaunch ingvio_estimator ingvio_stereo_fw.launch
```

To record the output topics, you can directly use our script file by:

```
roslaunch ingvio_estimator ingvio_mono_fw_record.launch
roslaunch ingvio_estimator ingvio_stereo_fw_record.launch
```

Rviz will be automatically launched. Run the ROS Bag to see the results:

```
rosbag play fw_easy.bag --pause
```

## 4. Run with GVINS Public Datasets

### 4.1 Configuration Settings

The GVINS datasets can be acquired from [GitHub - HKUST-Aerial-Robotics/GVINS-Dataset](https://github.com/HKUST-Aerial-Robotics/GVINS-Dataset). The config files for GVINS Datasets are already integrated in 'config/sportsfield'. It's valid for all 3 datasets provided by GVINS.

To run InGVIO in your environment, the following should be conducted first.

Please adjust and modify the paths in 'config/sports_field/ingvio_mono.yaml' and 'config/sports_field/ingvio_stereo.yaml' to the case in your environment.

If you want to record the output topics, please set your output dir in 'ingvio/launch/ingvio_mono, stereo_sf_record.launch' files.

To run with monocular camera, please enter:

```
roslaunch ingvio_estimator ingvio_mono_sf.launch
```

For stereo-case, please enter:

```
roslaunch ingvio_estimator ingvio_stereo_sf.launch
```

To record the output topics, you can directly use our script file by:

```
roslaunch ingvio_estimator ingvio_mono_sf_record.launch
roslaunch ingvio_estimator ingvio_stereo_sf_record.launch
```

Rviz will be automatically launched. Run the ROS Bag to see the results:

```
rosbag play sports_field.bag --pause
rosbag play complex_environment.bag --pause
rosbag play urban_driving.bag --pause
```

### 4.2 Parameter Tuning Hints

**For sports_field.bag:** Monocular/Stereo Case: max_pts_frame = 150/110, visual_noise = 0.12, gnss_chi2_test = false, imu_buffer_size = 3000.

**For urban_driving.bag:** Monocular/Stereo Case: max_pts_frame = 150/110, visual_noise = 0.12, gnss_chi2_test = true, imu_buffer_size = 3000. To avoid polluted GNSS measurements, a stronger version could be gnss_chi2_test = false, gnss_strong_reject = true.

**For indoors_outdoors.bag:** Monocular/Stereo Case: max_pts_frame = 150/110, visual_noise = 0.18, gnss_chi2_test = false, gnss_strong_reject = true. 

Please modify or try other parameters if the above behave not well. Good parameters may be different under different environment settings.

## 5. Acknowledgements

The realization of the type-based index system in filter framework is inspired by [OpenVINS](https://github.com/rpng/open_vins). The author himself has learned lots of programming skills in SLAM by reading the codes of OpenVINS.

The [gnss_comm](https://github.com/HKUST-Aerial-Robotics/gnss_comm) provided by GVINS is a great wrapper in developing codes involving raw GNSS measurements in ROS.

## 6. License

This software is open-sourced under GPLv3 license. See [GNU GPL v3.0 - GNU](https://www.gnu.org/licenses/gpl-3.0.html).

Please cite our paper if you use either our code or our fixed-wing datasets.


================================================
FILE: camera_model/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 2.8.3)
project(camera_model)

set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

find_package(catkin REQUIRED COMPONENTS
    roscpp
    std_msgs
)

if(EXISTS "/usr/include/eigen3")
    include_directories("/usr/include/eigen3")
else()
    find_package(Eigen3 REQUIRED)
    include_directories(${EIGEN3_INCLUDE_DIR})
endif()

find_package(Boost REQUIRED COMPONENTS filesystem program_options system)
find_package(OpenCV REQUIRED)

catkin_package(
    INCLUDE_DIRS include
    LIBRARIES camera_model
    CATKIN_DEPENDS roscpp std_msgs
)

include_directories(
    ${PROJECT_SOURCE_DIR}/include
    ${catkin_INCLUDE_DIRS}
    ${OpenCV_INCLUDE_DIRS}
    ${Boost_INCLUDE_DIRS}
)

# if(EXISTS "${PROJECT_SOURCE_DIR}/test/")
#     enable_testing()
#     add_subdirectory(${PROJECT_SOURCE_DIR}/test)
# endif()

add_library(camera_model
    src/camera.cpp
    src/MeiCamera.cpp
    src/PinholeCamera.cpp
    src/camera_factory.cpp
)

target_link_libraries(camera_model ${Boost_LIBRARIES} ${OpenCV_LIBS})


================================================
FILE: camera_model/LICENSE
================================================
                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU General Public License is a free, copyleft license for
software and other kinds of works.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.  We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors.  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights.  Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received.  You must make sure that they, too, receive
or can get the source code.  And you must show them these terms so they
know their rights.

  Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

  For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software.  For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

  Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so.  This is fundamentally incompatible with the aim of
protecting users' freedom to change the software.  The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable.  Therefore, we
have designed this version of the GPL to prohibit the practice for those
products.  If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

  Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary.  To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Use with the GNU Affero General Public License.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

    <program>  Copyright (C) <year>  <name of author>
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.

  The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.


================================================
FILE: camera_model/include/MeiCamera.h
================================================
/**   This File is part of Camera Model
 *  
 *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,
 *                                     lcw18@mails.tsinghua.edu.cn (valid until 2023))
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *    
 *    Since some functions are adapted from GVINS <https://github.com/HKUST-Aerial-Robotics/GVINS>
 *    GVINS is under GPLv3 License.
 */

#pragma once

#include "camera.h"
#include <cmath>

namespace camera_model
{
    class MeiCamera: public Camera
    {
    public:
        class Parameters: public Camera::Parameters
        {
        public:
            Parameters();
            Parameters(const std::string& cameraName, int w, int h, double xi, double k1, double k2, double p1, double p2, double gamma1, double gamma2, double u0, double v0);

            double& xi();
            double& k1();
            double& k2();
            double& p1();
            double& p2();
            double& gamma1();
            double& gamma2();
            double& u0();
            double& v0();

            double xi() const;
            double k1() const;
            double k2() const;
            double p1() const;
            double p2() const;
            double gamma1() const;
            double gamma2() const;
            double u0() const;
            double v0() const;
            
            bool readFromYamlFile(const std::string& filename) override;
            void writeToYamlFile(const std::string& filename) const override;
            
            Parameters& operator= (const Parameters& other);
            friend std::ostream& operator<< (std::ostream& out, const Parameters& params);
            
        private:
            double m_xi;
            double m_k1;
            double m_k2;
            double m_p1;
            double m_p2;
            double m_gamma1;
            double m_gamma2;
            double m_u0;
            double m_v0;
        };
        
        MeiCamera();
        
        MeiCamera(const std::string& cameraName, int imageWidth, int imageHeight, double xi, double k1, double k2, double p1, double p2, double gamma1, double gamma2, double u0, double v0);
        
        MeiCamera(const Parameters& params);
        
        Camera::ModelType modelType(void) const override;

        const std::string& cameraName(void) const override;

        int imageWidth(void) const override;

        int imageHeight(void) const override;
        
        double getNormalPixel() const override;
       
        void liftSphere(const Eigen::Vector2d& p, Eigen::Vector3d& P) const override;
        
        void liftProjective(const Eigen::Vector2d& p, Eigen::Vector3d& P) const override;
        
        void spaceToPlane(const Eigen::Vector3d& P, Eigen::Vector2d& p) const override;
        
        void undistToPlane(const Eigen::Vector2d& p_u, Eigen::Vector2d& p) const override;
        
        template <typename T>
        static void spaceToPlane(const T* const params, const T* const q, const T* const t, const Eigen::Matrix<T, 3, 1>& P, Eigen::Matrix<T, 2, 1>& p);
        
        void distortion(const Eigen::Vector2d& p_u, Eigen::Vector2d& d_u) const;
        void distortion(const Eigen::Vector2d& p_u, Eigen::Vector2d& d_u, Eigen::Matrix2d& J) const;
        
        int parameterCount() const override;
        
        const Parameters& getParameters(void) const;

        void setParameters(const Parameters& parameters);  
        
        void readParameters(const std::vector<double>& parameterVec) override;

        void writeParameters(std::vector<double>& parameterVec) const override;

        void writeParametersToYamlFile(const std::string& filename) const override;

        std::string parametersToString(void) const override;
        
    private:
        Parameters mParameters;
        
        double m_inv_K11, m_inv_K13, m_inv_K22, m_inv_K23;
        bool m_noDistortion;
    };
    
    typedef boost::shared_ptr<MeiCamera> MeiCameraPtr;
    typedef boost::shared_ptr<const MeiCamera> MeiCameraConstPtr;
    
    template <typename T>
    void MeiCamera::spaceToPlane(const T* const params, const T* const q, const T* const t, const Eigen::Matrix<T, 3, 1>& P, Eigen::Matrix<T, 2, 1>& p)
    {
        Eigen::Vector3d Pw((double)P(0), (double)P(1), (double)P(2));
        Eigen::Vector3d tw((double)t(0), (double)t(1), (double)t(2));
        Eigen::Quaterniond qw;
        
        qw.w() = (double) q[3];
        qw.x() = (double) q[0];
        qw.y() = (double) q[1];
        qw.z() = (double) q[2];
        qw.normalized();
        
        Eigen::Vector3d transP = qw.toRotationMatrix()*Pw + tw;
        T P_c[3];
        P_c[0] = T(transP(0));
        P_c[1] = T(transP(1));
        P_c[2] = T(transP(2));
        
        T xi = params[0];
        T k1 = params[1];
        T k2 = params[2];
        T p1 = params[3];
        T p2 = params[4];

        T gamma1 = params[5];
        T gamma2 = params[6];
        T alpha = T(0);
        T u0 = params[7];
        T v0 = params[8];
        
        T len = std::sqrt(P_c[0]*P_c[0] + P_c[1]*P_c[1] + P_c[2]*P_c[2]);
        P_c[0] /= len;
        P_c[1] /= len;
        P_c[2] /= len;
        
        T u = P_c[0]/(P_c[2] + xi);
        T v = P_c[1]/(P_c[2] + xi);
        
        T rho_sqr = u*u + v*v;
        T L = T(1.0) + k1*rho_sqr + k2*rho_sqr*rho_sqr;
        T du = T(2.0)*p1*u*v + p2*(rho_sqr + T(2.0)*u*u);
        T dv = p1*(rho_sqr + T(2.0)*v*v) + T(2.0)*p2*u*v;

        u = L*u + du;
        v = L*v + dv;

        p(0) = gamma1*(u + alpha*v) + u0;
        p(1) = gamma2*v + v0;        
    }
}


================================================
FILE: camera_model/include/PinholeCamera.h
================================================
/**   This File is part of Camera Model
 *  
 *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,
 *                                     lcw18@mails.tsinghua.edu.cn (valid until 2023))
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *    
 *    Since some functions are adapted from GVINS <https://github.com/HKUST-Aerial-Robotics/GVINS>
 *    GVINS is under GPLv3 License.
 */

#pragma once

#include "camera.h"
#include <cmath>

namespace camera_model
{
    class PinholeCamera: public Camera
    {
    public:
        class Parameters: public Camera::Parameters
        {
        public:
            Parameters();
            Parameters(const std::string& cameraName, int w, int h, double k1, double k2, double p1, double p2, double fx, double fy, double cx, double cy);

            double& k1(void);
            double& k2(void);
            double& p1(void);
            double& p2(void);
            double& fx(void);
            double& fy(void);
            double& cx(void);
            double& cy(void);

            double xi(void) const;
            double k1(void) const;
            double k2(void) const;
            double p1(void) const;
            double p2(void) const;
            double fx(void) const;
            double fy(void) const;
            double cx(void) const;
            double cy(void) const;

            bool readFromYamlFile(const std::string& filename) override;
            void writeToYamlFile(const std::string& filename) const override;

            Parameters& operator=(const Parameters& other);
            friend std::ostream& operator<< (std::ostream& out, const Parameters& params);

        private:
            double m_k1;
            double m_k2;
            double m_p1;
            double m_p2;
            double m_fx;
            double m_fy;
            double m_cx;
            double m_cy;
        };
        
        PinholeCamera();
        
        PinholeCamera(const std::string& cameraName, int imageWidth, int imageHeight,  double k1, double k2, double p1, double p2, double fx, double fy, double cx, double cy);
        
        PinholeCamera(const Parameters& params);
        
        Camera::ModelType modelType(void) const override;
        const std::string& cameraName(void) const override;
        int imageWidth(void) const override;
        int imageHeight(void) const override;
        
        double getNormalPixel() const override;
        
        void liftSphere(const Eigen::Vector2d& p, Eigen::Vector3d& P) const override;

        void liftProjective(const Eigen::Vector2d& p, Eigen::Vector3d& P) const override;

        void spaceToPlane(const Eigen::Vector3d& P, Eigen::Vector2d& p) const override;

        void spaceToPlane(const Eigen::Vector3d& P, Eigen::Vector2d& p, Eigen::Matrix<double,2,3>& J) const;
        
        void undistToPlane(const Eigen::Vector2d& p_u, Eigen::Vector2d& p) const override;
        
        template <typename T>
        static void spaceToPlane(const T* const params, const T* const q, const T* const t, const Eigen::Matrix<T, 3, 1>& P, Eigen::Matrix<T, 2, 1>& p);
        
        void distortion(const Eigen::Vector2d& p_u, Eigen::Vector2d& d_u) const;
        void distortion(const Eigen::Vector2d& p_u, Eigen::Vector2d& d_u, Eigen::Matrix2d& J) const;
        
        int parameterCount() const override;
        
        const Parameters& getParameters(void) const;

        void setParameters(const Parameters& parameters);  
        
        void readParameters(const std::vector<double>& parameterVec) override;

        void writeParameters(std::vector<double>& parameterVec) const override;

        void writeParametersToYamlFile(const std::string& filename) const override;

        std::string parametersToString(void) const override;
        
    private:
        Parameters mParameters;
        
        double m_inv_K11, m_inv_K13, m_inv_K22, m_inv_K23;
        bool m_noDistortion;
    };
    
    typedef boost::shared_ptr<PinholeCamera> PinholeCameraPtr;
    typedef boost::shared_ptr<const PinholeCamera> PinholeCameraConstPtr;
    
    template <typename T>
    void PinholeCamera::spaceToPlane(const T* const params, const T* const q, const T* const t, const Eigen::Matrix<T, 3, 1>& P, Eigen::Matrix<T, 2, 1>& p)
    {
        Eigen::Vector3d Pw((double)P(0), (double)P(1), (double)P(2));
        Eigen::Vector3d tw((double)t(0), (double)t(1), (double)t(2));
        Eigen::Quaterniond qw;
        
        qw.w() = (double) q[3];
        qw.x() = (double) q[0];
        qw.y() = (double) q[1];
        qw.z() = (double) q[2];
        qw.normalized();
        
        Eigen::Vector3d transP = qw.toRotationMatrix()*Pw + tw;
        T P_c[3];
        P_c[0] = T(transP(0));
        P_c[1] = T(transP(1));
        P_c[2] = T(transP(2));
        
        T k1 = params[0];
        T k2 = params[1];
        T p1 = params[2];
        T p2 = params[3];
        T fx = params[4];
        T fy = params[5];
        T alpha = T(0);
        T cx = params[6];
        T cy = params[7];

        T u = P_c[0]/P_c[2];
        T v = P_c[1]/P_c[2];

        T rho_sqr = u*u + v*v;
        T L = T(1.0) + k1*rho_sqr + k2*rho_sqr*rho_sqr;
        T du = T(2.0)*p1*u*v + p2*(rho_sqr + T(2.0)*u*u);
        T dv = p1*(rho_sqr + T(2.0)*v*v) + T(2.0)*p2*u*v;

        u = L*u + du;
        v = L*v + dv;
        p(0) = fx*(u + alpha*v) + cx;
        p(1) = fy*v + cy;
    }
    
}


================================================
FILE: camera_model/include/camera.h
================================================
/**   This File is part Camera Model
 *  
 *    
 *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,
 *                                     lcw18@mails.tsinghua.edu.cn (valid until 2023))
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *    
 *    Since some functions are adapted from GVINS <https://github.com/HKUST-Aerial-Robotics/GVINS>
 *    GVINS is under GPLv3 License.
 */

#pragma once

#include <boost/shared_ptr.hpp>
#include <Eigen/Dense>
#include <Eigen/Geometry>
#include <vector>
#include <opencv2/core/core.hpp>
#include <string>
#include <iostream>

namespace camera_model
{
    class Camera
    {
    public:
        EIGEN_MAKE_ALIGNED_OPERATOR_NEW
        
        enum ModelType
        {
            MEI,
            PINHOLE
        };
        
        class Parameters
        {
        public:
            EIGEN_MAKE_ALIGNED_OPERATOR_NEW
            
            Parameters(ModelType modelType);
            Parameters(ModelType modelType, const std::string& cameraName, int w, int h);
            
            ModelType& modelType();
            ModelType modelType() const;
            
            std::string& cameraName();
            const std::string& cameraName() const;
            
            int& imageWidth();
            int imageWidth() const;
            
            int& imageHeight();
            int imageHeight() const;
            
            int nIntrinsics() const;
            
            virtual bool readFromYamlFile(const std::string& filename) = 0;
            virtual void writeToYamlFile(const std::string& filename) const = 0;
            
        protected:
            ModelType m_modelType;
            int m_nIntrinsics;
            std::string m_cameraName;
            int m_imageWidth;
            int m_imageHeight;
        };
        
        
        virtual ModelType modelType() const  = 0;
        virtual const std::string& cameraName() const = 0;
        virtual int imageWidth() const = 0;
        virtual int imageHeight() const = 0;
        
        virtual cv::Mat& mask();
        virtual const cv::Mat& mask() const;
        
        virtual double getNormalPixel() const = 0;
        
        // from the image plane to the sphere
        virtual void liftSphere(const Eigen::Vector2d& p, Eigen::Vector3d& P) const = 0;
        
        // from the image plane to the projective space
        virtual void liftProjective(const Eigen::Vector2d& p, Eigen::Vector3d& P) const = 0;
        
        // from 3D points to the image plane
        virtual void spaceToPlane(const Eigen::Vector3d& P, Eigen::Vector2d& p) const = 0;
        
        virtual void undistToPlane(const Eigen::Vector2d& p_u, Eigen::Vector2d& p) const = 0;
        
        virtual int parameterCount(void) const = 0;
        
        virtual void readParameters(const std::vector<double>& parameters) = 0;
        virtual void writeParameters(std::vector<double>& parameters) const = 0;
        virtual void writeParametersToYamlFile(const std::string& filename) const = 0;
        virtual std::string parametersToString() const = 0;
        
        double reprojectionDist(const Eigen::Vector3d& P1, const Eigen::Vector3d& P2) const;

        double reprojectionError(const Eigen::Vector3d& P,
                                 const Eigen::Quaterniond& camera_q,
                                 const Eigen::Vector3d& camera_t,
                                 const Eigen::Vector2d& observed_p) const;
                           
    protected:
        cv::Mat m_mask;
    };
    
    typedef boost::shared_ptr<Camera> CameraPtr;
    typedef boost::shared_ptr<const Camera> CameraConstPtr;
}


================================================
FILE: camera_model/include/camera_factory.h
================================================
/**   This File is part of Camera Model
 *  
 *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,
 *                                     lcw18@mails.tsinghua.edu.cn (valid until 2023))
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *    
 *    Since some functions are adapted from GVINS <https://github.com/HKUST-Aerial-Robotics/GVINS>
 *    GVINS is under GPLv3 License.
 */

#pragma once

#include "camera.h"

namespace camera_model
{
    class CameraFactory
    {
    public:
        EIGEN_MAKE_ALIGNED_OPERATOR_NEW
        
        CameraFactory();
        
        static boost::shared_ptr<CameraFactory> instance(void);
        
        CameraPtr generateCamera(Camera::ModelType modelType, const std::string& cameraName, cv::Size imageSize) const;
        
        CameraPtr generateCameraFromYamlFile(const std::string& filename);
        
    private:
        static boost::shared_ptr<CameraFactory> m_instance;
    };
    
}


================================================
FILE: camera_model/package.xml
================================================
<?xml version="1.0"?>
<package>
  <name>camera_model</name>
  <version>0.0.0</version>
  <description>The camera_model package</description>
  <maintainer email="lcw18@mails.tsinghua.edu.cn">lcw18</maintainer>
  <!-- One license tag required, multiple allowed, one license per tag -->
  <!-- Commonly used license strings: -->
  <!--   BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
  <license>GPLv3</license>

  <!-- The *_depend tags are used to specify dependencies -->
  <!-- Dependencies can be catkin packages or system dependencies -->
  <!-- Examples: -->
  <!-- Use build_depend for packages you need at compile time: -->
  <!--   <build_depend>message_generation</build_depend> -->
  <!-- Use buildtool_depend for build tool packages: -->
  <!--   <buildtool_depend>catkin</buildtool_depend> -->
  <!-- Use run_depend for packages you need at runtime: -->
  <!--   <run_depend>message_runtime</run_depend> -->
  <!-- Use test_depend for packages you need only for testing: -->
  <!--   <test_depend>gtest</test_depend> -->
  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>std_msgs</build_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>std_msgs</run_depend>

  <!-- The export tag contains other, unspecified, tags -->
  <export>
    <!-- Other tools can request additional information be placed here -->
  </export>
</package>


================================================
FILE: camera_model/src/MeiCamera.cpp
================================================
/**   This File is part of Camera Model
 *  
 *    
 *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,
 *                                     lcw18@mails.tsinghua.edu.cn (valid until 2023))
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *    
 *    Since some functions are adapted from GVINS <https://github.com/HKUST-Aerial-Robotics/GVINS>
 *    GVINS is under GPLv3 License.
 */

#include "MeiCamera.h"
#include <iomanip>

namespace camera_model
{
    MeiCamera::Parameters::Parameters(): Camera::Parameters(MEI), m_xi(0.0), m_k1(0.0), m_k2(0.0), m_p1(0.0), m_p2(0.0), m_gamma1(0.0), m_gamma2(0.0), m_u0(0.0), m_v0(0.0)
    {}
    
    MeiCamera::Parameters::Parameters(const std::string& cameraName, int w, int h,  double xi, double k1, double k2, double p1, double p2, double gamma1, double gamma2, double u0, double v0) : Camera::Parameters(MEI, cameraName, w, h), m_xi(xi), m_k1(k1), m_k2(k2), m_p1(p1), m_p2(p2), m_gamma1(gamma1), m_gamma2(gamma2), m_u0(u0), m_v0(v0)
    {}
    
    double& MeiCamera::Parameters::xi() { return m_xi;}

    double& MeiCamera::Parameters::k1() { return m_k1;}

    double& MeiCamera::Parameters::k2() { return m_k2;}

    double& MeiCamera::Parameters::p1() { return m_p1;}

    double& MeiCamera::Parameters::p2() { return m_p2;}

    double& MeiCamera::Parameters::gamma1() { return m_gamma1;}

    double& MeiCamera::Parameters::gamma2() { return m_gamma2;}

    double& MeiCamera::Parameters::u0() { return m_u0;}

    double& MeiCamera::Parameters::v0() { return m_v0;}

    double MeiCamera::Parameters::xi() const { return m_xi;}

    double MeiCamera::Parameters::k1() const { return m_k1;}

    double MeiCamera::Parameters::k2() const { return m_k2;}

    double MeiCamera::Parameters::p1() const { return m_p1;}

    double MeiCamera::Parameters::p2() const { return m_p2;}

    double MeiCamera::Parameters::gamma1() const { return m_gamma1;}

    double MeiCamera::Parameters::gamma2() const { return m_gamma2;}

    double MeiCamera::Parameters::u0() const { return m_u0;}

    double MeiCamera::Parameters::v0() const { return m_v0;}

    bool MeiCamera::Parameters::readFromYamlFile(const std::string& filename)
    {
        cv::FileStorage fs(filename, cv::FileStorage::READ);
        
        if (!fs.isOpened()) return false;
        
        if (!fs["model_type"].isNone())
        {
            std::string sModelType;
            fs["model_type"] >> sModelType;
            
            if (sModelType.compare("MEI") != 0) return false;
        }
        
        m_modelType = MEI;
        fs["camera_name"] >> m_cameraName;
        m_imageWidth = static_cast<int>(fs["image_width"]);
        m_imageHeight = static_cast<int>(fs["image_height"]);

        cv::FileNode n = fs["mirror_parameters"];
        m_xi = static_cast<double>(n["xi"]);

        n = fs["distortion_parameters"];
        m_k1 = static_cast<double>(n["k1"]);
        m_k2 = static_cast<double>(n["k2"]);
        m_p1 = static_cast<double>(n["p1"]);
        m_p2 = static_cast<double>(n["p2"]);
        
        n = fs["projection_parameters"];
        m_gamma1 = static_cast<double>(n["gamma1"]);
        m_gamma2 = static_cast<double>(n["gamma2"]);
        m_u0 = static_cast<double>(n["u0"]);
        m_v0 = static_cast<double>(n["v0"]);
    
        return true;
    }
    
    void MeiCamera::Parameters::writeToYamlFile(const std::string& filename) const
    {
        cv::FileStorage fs(filename, cv::FileStorage::WRITE);

        fs << "model_type" << "MEI";
        fs << "camera_name" << m_cameraName;
        fs << "image_width" << m_imageWidth;
        fs << "image_height" << m_imageHeight;

        fs << "mirror_parameters";
        fs << "{" << "xi" << m_xi << "}";
    
        fs << "distortion_parameters";
        fs << "{" << "k1" << m_k1
                  << "k2" << m_k2
                  << "p1" << m_p1
                  << "p2" << m_p2 << "}";
        
        fs << "projection_parameters";
        fs << "{" << "gamma1" << m_gamma1
                  << "gamma2" << m_gamma2
                  << "u0" << m_u0
                  << "v0" << m_v0 << "}";

        fs.release();
    }
    
    MeiCamera::Parameters& MeiCamera::Parameters::operator=(const MeiCamera::Parameters& other)
    {
        if (this != &other)
        {
            m_modelType = other.m_modelType;
            m_cameraName = other.m_cameraName;
            m_imageWidth = other.m_imageWidth;
            m_imageHeight = other.m_imageHeight;
            m_xi = other.m_xi;
            m_k1 = other.m_k1;
            m_k2 = other.m_k2;
            m_p1 = other.m_p1;
            m_p2 = other.m_p2;
            m_gamma1 = other.m_gamma1;
            m_gamma2 = other.m_gamma2;
            m_u0 = other.m_u0;
            m_v0 = other.m_v0;
        }
    
        return *this;
    }
    
    std::ostream& operator<< (std::ostream& out, const MeiCamera::Parameters& params)
    {
        out << "Camera Parameters:" << std::endl;
        out << "    model_type " << "MEI" << std::endl;
        out << "   camera_name " << params.m_cameraName << std::endl;
        out << "   image_width " << params.m_imageWidth << std::endl;
        out << "  image_height " << params.m_imageHeight << std::endl;

        out << "Mirror Parameters" << std::endl;
        out << std::fixed << std::setprecision(10);
        out << "            xi " << params.m_xi << std::endl;

        out << "Distortion Parameters" << std::endl;
        out << "            k1 " << params.m_k1 << std::endl
            << "            k2 " << params.m_k2 << std::endl
            << "            p1 " << params.m_p1 << std::endl
            << "            p2 " << params.m_p2 << std::endl;

        out << "Projection Parameters" << std::endl;
        out << "        gamma1 " << params.m_gamma1 << std::endl
            << "        gamma2 " << params.m_gamma2 << std::endl
            << "            u0 " << params.m_u0 << std::endl
            << "            v0 " << params.m_v0 << std::endl;

        return out;
    }
    
    MeiCamera::MeiCamera(): m_inv_K11(1.0), m_inv_K13(0.0), m_inv_K22(1.0), m_inv_K23(0.0), m_noDistortion(true)
    {}
    
    MeiCamera::MeiCamera(const std::string& cameraName, int imageWidth, int imageHeight, double xi, double k1, double k2, double p1, double p2, double gamma1, double gamma2, double u0, double v0) : mParameters(cameraName, imageWidth, imageHeight, xi, k1, k2, p1, p2, gamma1, gamma2, u0, v0)
    {
        if ((mParameters.k1() == 0.0) && (mParameters.k2() == 0.0) && (mParameters.p1() == 0.0) && (mParameters.p2() == 0.0))
        {
            m_noDistortion = true;
        }
        else
        {
            m_noDistortion = false;
        }
        
        m_inv_K11 = 1.0 / mParameters.gamma1();
        m_inv_K13 = -mParameters.u0() / mParameters.gamma1();
        m_inv_K22 = 1.0 / mParameters.gamma2();
        m_inv_K23 = -mParameters.v0() / mParameters.gamma2();
    }
    
    MeiCamera::MeiCamera(const MeiCamera::Parameters& params) : mParameters(params)
    {
        if ((mParameters.k1() == 0.0) && (mParameters.k2() == 0.0) && (mParameters.p1() == 0.0) && (mParameters.p2() == 0.0))
        {
            m_noDistortion = true;
        }
        else
        {
            m_noDistortion = false;
        }
        
        m_inv_K11 = 1.0 / mParameters.gamma1();
        m_inv_K13 = -mParameters.u0() / mParameters.gamma1();
        m_inv_K22 = 1.0 / mParameters.gamma2();
        m_inv_K23 = -mParameters.v0() / mParameters.gamma2();
    }
    
    Camera::ModelType MeiCamera::modelType() const
    {
        return mParameters.modelType();
    }

    const std::string& MeiCamera::cameraName() const
    {
        return mParameters.cameraName();
    }

    int MeiCamera::imageWidth() const
    {
        return mParameters.imageWidth();
    }

    int MeiCamera::imageHeight() const
    {
        return mParameters.imageHeight();
    }
    
    double MeiCamera::getNormalPixel() const
    {
        return 2.0/(mParameters.gamma1() + mParameters.gamma2());
    }
    
    void MeiCamera::liftSphere(const Eigen::Vector2d& p, Eigen::Vector3d& P) const
    {
        double mx_d, my_d,mx2_d, mxy_d, my2_d, mx_u, my_u;
        double rho2_d, rho4_d, radDist_d, Dx_d, Dy_d, inv_denom_d;
        double lambda;
        
        mx_d = m_inv_K11 * p(0) + m_inv_K13;
        my_d = m_inv_K22 * p(1) + m_inv_K23;
        
        if (m_noDistortion)
        {
            mx_u = mx_d;
            my_u = my_d;
        }
        else
        {
            double k1 = mParameters.k1();
            double k2 = mParameters.k2();
            double p1 = mParameters.p1();
            double p2 = mParameters.p2();
            
            mx2_d = mx_d*mx_d;
            my2_d = my_d*my_d;
            mxy_d = mx_d*my_d;
            rho2_d = mx2_d+my2_d;
            rho4_d = rho2_d*rho2_d;
            radDist_d = k1*rho2_d+k2*rho4_d;
            Dx_d = mx_d*radDist_d + p2*(rho2_d+2*mx2_d) + 2*p1*mxy_d;
            Dy_d = my_d*radDist_d + p1*(rho2_d+2*my2_d) + 2*p2*mxy_d;
            inv_denom_d = 1/(1+4*k1*rho2_d+6*k2*rho4_d+8*p1*my_d+8*p2*mx_d);

            mx_u = mx_d - inv_denom_d*Dx_d;
            my_u = my_d - inv_denom_d*Dy_d;
        }
        
        double xi = mParameters.xi();
        if (xi == 1.0)
        {
            lambda = 2.0/(mx_u*mx_u + my_u*my_u + 1.0);
            P << lambda*mx_u, lambda*my_u, lambda - 1.0;
        }
        else
        {
            lambda = (xi + std::sqrt(1.0 + (1.0 - xi*xi)*(mx_u*mx_u + my_u*my_u))) / (1.0 + mx_u*mx_u + my_u*my_u);
            P << lambda*mx_u, lambda*my_u, lambda - xi;
        }
        
    }
    
    void MeiCamera::liftProjective(const Eigen::Vector2d& p, Eigen::Vector3d& P) const
    {
        double mx_d, my_d,mx2_d, mxy_d, my2_d, mx_u, my_u;
        double rho2_d, rho4_d, radDist_d, Dx_d, Dy_d, inv_denom_d;

        mx_d = m_inv_K11 * p(0) + m_inv_K13;
        my_d = m_inv_K22 * p(1) + m_inv_K23;

        if (m_noDistortion)
        {
            mx_u = mx_d;
            my_u = my_d;
        }
        else
        {
            double k1 = mParameters.k1();
            double k2 = mParameters.k2();
            double p1 = mParameters.p1();
            double p2 = mParameters.p2();

            mx2_d = mx_d*mx_d;
            my2_d = my_d*my_d;
            mxy_d = mx_d*my_d;
            rho2_d = mx2_d+my2_d;
            rho4_d = rho2_d*rho2_d;
            radDist_d = k1*rho2_d+k2*rho4_d;
            Dx_d = mx_d*radDist_d + p2*(rho2_d+2*mx2_d) + 2*p1*mxy_d;
            Dy_d = my_d*radDist_d + p1*(rho2_d+2*my2_d) + 2*p2*mxy_d;
            inv_denom_d = 1/(1+4*k1*rho2_d+6*k2*rho4_d+8*p1*my_d+8*p2*mx_d);

            mx_u = mx_d - inv_denom_d*Dx_d;
            my_u = my_d - inv_denom_d*Dy_d;
        }

        double xi = mParameters.xi();
        if (xi == 1.0)
        {
            P << mx_u, my_u, (1.0 - mx_u*mx_u - my_u*my_u)/2.0;
        }
        else
        {
            rho2_d = mx_u*mx_u + my_u*my_u;
            P << mx_u, my_u, 1.0 - xi*(rho2_d + 1.0)/(xi + std::sqrt(1.0 + (1.0 - xi*xi)*rho2_d));
        }
        
        P(0) = P(0)/P(2);
        P(1) = P(1)/P(2);
        P(2) = 1.0;
    }
    
    void MeiCamera::spaceToPlane(const Eigen::Vector3d& P, Eigen::Vector2d& p) const
    {
        Eigen::Vector2d p_u, p_d;

        double z = P(2) + mParameters.xi() * P.norm();
        p_u << P(0) / z, P(1) / z;

        if (m_noDistortion)
        {
            p_d = p_u;
        }
        else
        {
            Eigen::Vector2d d_u;
            distortion(p_u, d_u);
            p_d = p_u + d_u;
        }

        p << mParameters.gamma1()*p_d(0) + mParameters.u0(),
             mParameters.gamma2()*p_d(1) + mParameters.v0();
    }
    
    void MeiCamera::undistToPlane(const Eigen::Vector2d& p_u, Eigen::Vector2d& p) const
    {
        Eigen::Vector2d p_d;

        if (m_noDistortion)
        {
            p_d = p_u;
        }
        else
        {
            Eigen::Vector2d d_u;
            distortion(p_u, d_u);
            p_d = p_u + d_u;
        }

        p << mParameters.gamma1()*p_d(0) + mParameters.u0(),
             mParameters.gamma2()*p_d(1) + mParameters.v0();
    }
    
    void MeiCamera::distortion(const Eigen::Vector2d& p_u, Eigen::Vector2d& d_u) const
    {
        double k1 = mParameters.k1();
        double k2 = mParameters.k2();
        double p1 = mParameters.p1();
        double p2 = mParameters.p2();
        
        double mx2_u, my2_u, mxy_u, rho2_u, rad_dist_u;
        
        mx2_u = p_u(0)*p_u(0);
        my2_u = p_u(1)*p_u(1);
        mxy_u = p_u(0)*p_u(1);
        
        rho2_u = mx2_u + my2_u;
        rad_dist_u = k1*rho2_u + k2*rho2_u*rho2_u;
        
        d_u(0) = p_u(0)*rad_dist_u + 2.0*p1*mxy_u + p2*(rho2_u + 2.0*mx2_u);
        d_u(1) = p_u(1)*rad_dist_u + 2.0*p2*mxy_u + p1*(rho2_u + 2.0*my2_u);
    }
    
    void MeiCamera::distortion(const Eigen::Vector2d& p_u, Eigen::Vector2d& d_u, Eigen::Matrix2d& J) const
    {
        double k1 = mParameters.k1();
        double k2 = mParameters.k2();
        double p1 = mParameters.p1();
        double p2 = mParameters.p2();
        
        double mx2_u, my2_u, mxy_u, rho2_u, rad_dist_u;
        
        mx2_u = p_u(0)*p_u(0);
        my2_u = p_u(1)*p_u(1);
        mxy_u = p_u(0)*p_u(1);
        
        rho2_u = mx2_u + my2_u;
        rad_dist_u = k1*rho2_u + k2*rho2_u*rho2_u;
        
        d_u(0) = p_u(0)*rad_dist_u + 2.0*p1*mxy_u + p2*(rho2_u + 2.0*mx2_u);
        d_u(1) = p_u(1)*rad_dist_u + 2.0*p2*mxy_u + p1*(rho2_u + 2.0*my2_u);

        J(0, 0) = 1.0 + rad_dist_u + k1*2.0*mx2_u + k2*rho2_u*4.0*mx2_u + 2.0*p1*p_u(1) + 6.0*p2*p_u(0);
        J(0, 1) = k1*2.0*p_u(0)*p_u(1) + k2*4.0*rho2_u*p_u(0)*p_u(1) + p1*2.0*p_u(0) + 2.0*p2*p_u(1);       
        J(1, 0) = J(0, 1);
        J(1, 1) = 1.0 + rad_dist_u + k1*2.0*my2_u + k2*rho2_u*4.0*my2_u + 6.0*p1*p_u(1) + 2.0*p2*p_u(0);
    }
    
    int MeiCamera::parameterCount() const
    {
        return 9;
    }

    const MeiCamera::Parameters& MeiCamera::getParameters() const
    {
        return mParameters;
    }

    void MeiCamera::setParameters(const MeiCamera::Parameters& parameters)
    {
        mParameters = parameters;

        if ((mParameters.k1() == 0.0) && (mParameters.k2() == 0.0) && (mParameters.p1() == 0.0) && (mParameters.p2() == 0.0))
        {
            m_noDistortion = true;
        }
        else
        {
            m_noDistortion = false;
        }

        m_inv_K11 = 1.0 / mParameters.gamma1();
        m_inv_K13 = -mParameters.u0() / mParameters.gamma1();
        m_inv_K22 = 1.0 / mParameters.gamma2();
        m_inv_K23 = -mParameters.v0() / mParameters.gamma2();
    }
    
    void MeiCamera::readParameters(const std::vector<double>& parameterVec)
    {
        if ((int)parameterVec.size() != parameterCount())
            return;

        Parameters params = getParameters();

        params.xi() = parameterVec.at(0);
        params.k1() = parameterVec.at(1);
        params.k2() = parameterVec.at(2);
        params.p1() = parameterVec.at(3);
        params.p2() = parameterVec.at(4);
        params.gamma1() = parameterVec.at(5);
        params.gamma2() = parameterVec.at(6);
        params.u0() = parameterVec.at(7);
        params.v0() = parameterVec.at(8);

        setParameters(params);
    }
    
    void MeiCamera::writeParameters(std::vector<double>& parameterVec) const
    {
        parameterVec.resize(parameterCount());
        parameterVec.at(0) = mParameters.xi();
        parameterVec.at(1) = mParameters.k1();
        parameterVec.at(2) = mParameters.k2();
        parameterVec.at(3) = mParameters.p1();
        parameterVec.at(4) = mParameters.p2();
        parameterVec.at(5) = mParameters.gamma1();
        parameterVec.at(6) = mParameters.gamma2();
        parameterVec.at(7) = mParameters.u0();
        parameterVec.at(8) = mParameters.v0();
    }

    void MeiCamera::writeParametersToYamlFile(const std::string& filename) const
    {
        mParameters.writeToYamlFile(filename);
    }

    std::string MeiCamera::parametersToString() const
    {
        std::ostringstream oss;
        oss << mParameters;

        return oss.str();
    }

}


================================================
FILE: camera_model/src/PinholeCamera.cpp
================================================
/**   This File is part of Camera Model
 *  
 *    
 *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,
 *                                     lcw18@mails.tsinghua.edu.cn (valid until 2023))
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *    
 *    Since some functions are adapted from GVINS <https://github.com/HKUST-Aerial-Robotics/GVINS>
 *    GVINS is under GPLv3 License.
 */

#include "PinholeCamera.h"
#include <iomanip>

namespace camera_model
{
    PinholeCamera::Parameters::Parameters() : Camera::Parameters(PINHOLE), m_k1(0.0), m_k2(0.0), m_p1(0.0), m_p2(0.0), m_fx(0.0), m_fy(0.0), m_cx(0.0), m_cy(0.0)
    {}
    
    PinholeCamera::Parameters::Parameters(const std::string& cameraName, int w, int h, double k1, double k2, double p1, double p2, double fx, double fy, double cx, double cy) : Camera::Parameters(PINHOLE, cameraName, w, h), m_k1(k1), m_k2(k2), m_p1(p1), m_p2(p2), m_fx(fx), m_fy(fy), m_cx(cx), m_cy(cy)
    {}
    
    double& PinholeCamera::Parameters::k1(void) { return m_k1;}

    double& PinholeCamera::Parameters::k2(void) { return m_k2;}

    double& PinholeCamera::Parameters::p1(void) { return m_p1;}

    double& PinholeCamera::Parameters::p2(void) { return m_p2;}

    double& PinholeCamera::Parameters::fx(void) { return m_fx;}

    double& PinholeCamera::Parameters::fy(void) { return m_fy;}

    double& PinholeCamera::Parameters::cx(void) { return m_cx;}

    double& PinholeCamera::Parameters::cy(void) { return m_cy;}

    double PinholeCamera::Parameters::k1(void) const { return m_k1;}

    double PinholeCamera::Parameters::k2(void) const { return m_k2;}

    double PinholeCamera::Parameters::p1(void) const { return m_p1;}

    double PinholeCamera::Parameters::p2(void) const { return m_p2;}

    double PinholeCamera::Parameters::fx(void) const { return m_fx;}

    double PinholeCamera::Parameters::fy(void) const { return m_fy;}

    double PinholeCamera::Parameters::cx(void) const { return m_cx;}

    double PinholeCamera::Parameters::cy(void) const { return m_cy;}
    
    bool PinholeCamera::Parameters::readFromYamlFile(const std::string& filename)
    {
        cv::FileStorage fs(filename, cv::FileStorage::READ);

        if (!fs.isOpened())
        {
            return false;
        }

        if (!fs["model_type"].isNone())
        {
            std::string sModelType;
            fs["model_type"] >> sModelType;

            if (sModelType.compare("PINHOLE") != 0)
            {
                return false;
            }
        }

        m_modelType = PINHOLE;
        fs["camera_name"] >> m_cameraName;
        m_imageWidth = static_cast<int>(fs["image_width"]);
        m_imageHeight = static_cast<int>(fs["image_height"]);

        cv::FileNode n = fs["distortion_parameters"];
        m_k1 = static_cast<double>(n["k1"]);
        m_k2 = static_cast<double>(n["k2"]);
        m_p1 = static_cast<double>(n["p1"]);
        m_p2 = static_cast<double>(n["p2"]);

        n = fs["projection_parameters"];
        m_fx = static_cast<double>(n["fx"]);
        m_fy = static_cast<double>(n["fy"]);
        m_cx = static_cast<double>(n["cx"]);
        m_cy = static_cast<double>(n["cy"]);
    
        return true;
    }
    
    void PinholeCamera::Parameters::writeToYamlFile(const std::string& filename) const
    {
        cv::FileStorage fs(filename, cv::FileStorage::WRITE);

        fs << "model_type" << "PINHOLE";
        fs << "camera_name" << m_cameraName;
        fs << "image_width" << m_imageWidth;
        fs << "image_height" << m_imageHeight;

        // radial distortion: k1, k2
        // tangential distortion: p1, p2
        fs << "distortion_parameters";
        fs << "{" << "k1" << m_k1
                  << "k2" << m_k2
                  << "p1" << m_p1
                  << "p2" << m_p2 << "}";

        // projection: fx, fy, cx, cy
        fs << "projection_parameters";
        fs << "{" << "fx" << m_fx
                  << "fy" << m_fy
                  << "cx" << m_cx
                  << "cy" << m_cy << "}";

        fs.release();
    }
    
    PinholeCamera::Parameters& PinholeCamera::Parameters::operator=(const PinholeCamera::Parameters& other)
    {
        if (this != &other)
        {
            m_modelType = other.m_modelType;
            m_cameraName = other.m_cameraName;
            m_imageWidth = other.m_imageWidth;
            m_imageHeight = other.m_imageHeight;
            m_k1 = other.m_k1;
            m_k2 = other.m_k2;
            m_p1 = other.m_p1;
            m_p2 = other.m_p2;
            m_fx = other.m_fx;
            m_fy = other.m_fy;
            m_cx = other.m_cx;
            m_cy = other.m_cy;
        }
        return *this;
    }

    std::ostream& operator<< (std::ostream& out, const PinholeCamera::Parameters& params)
    {
        out << "Camera Parameters:" << std::endl;
        out << "    model_type " << "PINHOLE" << std::endl;
        out << "   camera_name " << params.m_cameraName << std::endl;
        out << "   image_width " << params.m_imageWidth << std::endl;
        out << "  image_height " << params.m_imageHeight << std::endl;

        // radial distortion: k1, k2
        // tangential distortion: p1, p2
        out << "Distortion Parameters" << std::endl;
        out << "            k1 " << params.m_k1 << std::endl
            << "            k2 " << params.m_k2 << std::endl
            << "            p1 " << params.m_p1 << std::endl
            << "            p2 " << params.m_p2 << std::endl;

        // projection: fx, fy, cx, cy
        out << "Projection Parameters" << std::endl;
        out << "            fx " << params.m_fx << std::endl
            << "            fy " << params.m_fy << std::endl
            << "            cx " << params.m_cx << std::endl
            << "            cy " << params.m_cy << std::endl;

        return out;
    }
    
    PinholeCamera::PinholeCamera() : m_inv_K11(1.0), m_inv_K13(0.0), m_inv_K22(1.0), m_inv_K23(0.0), m_noDistortion(true)
    {}

    PinholeCamera::PinholeCamera(const std::string& cameraName, int imageWidth, int imageHeight, double k1, double k2, double p1, double p2, double fx, double fy, double cx, double cy) : mParameters(cameraName, imageWidth, imageHeight, k1, k2, p1, p2, fx, fy, cx, cy)
    {
        if ((mParameters.k1() == 0.0) && (mParameters.k2() == 0.0) && (mParameters.p1() == 0.0) && (mParameters.p2() == 0.0))
        {
            m_noDistortion = true;
        }
        else
        {
            m_noDistortion = false;
        }

        m_inv_K11 = 1.0 / mParameters.fx();
        m_inv_K13 = -mParameters.cx() / mParameters.fx();
        m_inv_K22 = 1.0 / mParameters.fy();
        m_inv_K23 = -mParameters.cy() / mParameters.fy();
    }

    PinholeCamera::PinholeCamera(const PinholeCamera::Parameters& params) : mParameters(params)
    {
        if ((mParameters.k1() == 0.0) && (mParameters.k2() == 0.0) && (mParameters.p1() == 0.0) && (mParameters.p2() == 0.0))
        {
            m_noDistortion = true;
        }
        else
        {
            m_noDistortion = false;
        }

        m_inv_K11 = 1.0 / mParameters.fx();
        m_inv_K13 = -mParameters.cx() / mParameters.fx();
        m_inv_K22 = 1.0 / mParameters.fy();
        m_inv_K23 = -mParameters.cy() / mParameters.fy();
    }
    
    Camera::ModelType PinholeCamera::modelType(void) const
    {
        return mParameters.modelType();
    }

    const std::string& PinholeCamera::cameraName(void) const
    {
        return mParameters.cameraName();
    }

    int PinholeCamera::imageWidth(void) const
    {
        return mParameters.imageWidth();
    }

    int PinholeCamera::imageHeight(void) const
    {
        return mParameters.imageHeight();
    }
    
    double PinholeCamera::getNormalPixel() const
    {
        return 2.0/(mParameters.fx() + mParameters.fy());
    }
    
    void PinholeCamera::liftSphere(const Eigen::Vector2d& p, Eigen::Vector3d& P) const
    {
        liftProjective(p, P);

        P.normalize();
    }
    
    void PinholeCamera::liftProjective(const Eigen::Vector2d& p, Eigen::Vector3d& P) const
    {
        double mx_d, my_d,mx2_d, mxy_d, my2_d, mx_u, my_u;
        double rho2_d, rho4_d, radDist_d, Dx_d, Dy_d, inv_denom_d;

        mx_d = m_inv_K11 * p(0) + m_inv_K13;
        my_d = m_inv_K22 * p(1) + m_inv_K23;

        if (m_noDistortion)
        {
            mx_u = mx_d;
            my_u = my_d;
        }
        else
        {
            double k1 = mParameters.k1();
            double k2 = mParameters.k2();
            double p1 = mParameters.p1();
            double p2 = mParameters.p2();

            mx2_d = mx_d*mx_d;
            my2_d = my_d*my_d;
            mxy_d = mx_d*my_d;
            rho2_d = mx2_d+my2_d;
            rho4_d = rho2_d*rho2_d;
            radDist_d = k1*rho2_d+k2*rho4_d;
            Dx_d = mx_d*radDist_d + p2*(rho2_d+2*mx2_d) + 2*p1*mxy_d;
            Dy_d = my_d*radDist_d + p1*(rho2_d+2*my2_d) + 2*p2*mxy_d;
            inv_denom_d = 1/(1+4*k1*rho2_d+6*k2*rho4_d+8*p1*my_d+8*p2*mx_d);

            mx_u = mx_d - inv_denom_d*Dx_d;
            my_u = my_d - inv_denom_d*Dy_d;
        }

        P << mx_u, my_u, 1.0;
    }
    
    void PinholeCamera::spaceToPlane(const Eigen::Vector3d& P, Eigen::Vector2d& p) const
    {
        Eigen::Vector2d p_u, p_d;

        p_u << P(0) / P(2), P(1) / P(2);

        if (m_noDistortion)
        {
            p_d = p_u;
        }
        else
        {
            Eigen::Vector2d d_u;
            distortion(p_u, d_u);
            p_d = p_u + d_u;
        }

        p << mParameters.fx() * p_d(0) + mParameters.cx(),
             mParameters.fy() * p_d(1) + mParameters.cy();
    }
    
    void PinholeCamera::spaceToPlane(const Eigen::Vector3d& P, Eigen::Vector2d& p,  Eigen::Matrix<double,2,3>& J) const
    {
        Eigen::Vector2d p_u, p_d;
        double norm, inv_denom;
        double dxdmx, dydmx, dxdmy, dydmy;

        norm = P.norm();

        inv_denom = 1.0 / P(2);
        p_u << inv_denom * P(0), inv_denom * P(1);

        double dudx = inv_denom;
        double dvdx = 0.0;
        double dudy = 0.0;
        double dvdy = inv_denom;
        inv_denom = - inv_denom * inv_denom;
        double dudz = P(0) * inv_denom;
        double dvdz = P(1) * inv_denom;

        if (m_noDistortion)
        {
            p_d = p_u;
        }
        else
        {
            Eigen::Vector2d d_u;
            distortion(p_u, d_u);
            p_d = p_u + d_u;
        }

        double fx = mParameters.fx();
        double fy = mParameters.fy();

        // Make the product of the jacobians
        // and add projection matrix jacobian
        inv_denom = fx * (dudx * dxdmx + dvdx * dxdmy); // reuse
        dvdx = fy * (dudx * dydmx + dvdx * dydmy);
        dudx = inv_denom;

        inv_denom = fx * (dudy * dxdmx + dvdy * dxdmy); // reuse
        dvdy = fy * (dudy * dydmx + dvdy * dydmy);
        dudy = inv_denom;

        inv_denom = fx * (dudz * dxdmx + dvdz * dxdmy); // reuse
        dvdz = fy * (dudz * dydmx + dvdz * dydmy);
        dudz = inv_denom;

        // Apply generalised projection matrix
        p << fx * p_d(0) + mParameters.cx(),
             fy * p_d(1) + mParameters.cy();

        J << dudx, dudy, dudz,
             dvdx, dvdy, dvdz;
    }

    void PinholeCamera::undistToPlane(const Eigen::Vector2d& p_u, Eigen::Vector2d& p) const
    {
        Eigen::Vector2d p_d;

        if (m_noDistortion)
        {
            p_d = p_u;
        }
        else
        {
            // Apply distortion
            Eigen::Vector2d d_u;
            distortion(p_u, d_u);
            p_d = p_u + d_u;
        }

        // Apply generalised projection matrix
        p << mParameters.fx() * p_d(0) + mParameters.cx(),
             mParameters.fy() * p_d(1) + mParameters.cy();
    }
    
    void PinholeCamera::distortion(const Eigen::Vector2d& p_u, Eigen::Vector2d& d_u) const
    {
        double k1 = mParameters.k1();
        double k2 = mParameters.k2();
        double p1 = mParameters.p1();
        double p2 = mParameters.p2();

        double mx2_u, my2_u, mxy_u, rho2_u, rad_dist_u;

        mx2_u = p_u(0) * p_u(0);
        my2_u = p_u(1) * p_u(1);
        mxy_u = p_u(0) * p_u(1);
        rho2_u = mx2_u + my2_u;
        rad_dist_u = k1 * rho2_u + k2 * rho2_u * rho2_u;
        d_u << p_u(0) * rad_dist_u + 2.0 * p1 * mxy_u + p2 * (rho2_u + 2.0 * mx2_u),
               p_u(1) * rad_dist_u + 2.0 * p2 * mxy_u + p1 * (rho2_u + 2.0 * my2_u);
    }
    
    void PinholeCamera::distortion(const Eigen::Vector2d& p_u, Eigen::Vector2d& d_u,  Eigen::Matrix2d& J) const
    {
        double k1 = mParameters.k1();
        double k2 = mParameters.k2();
        double p1 = mParameters.p1();
        double p2 = mParameters.p2();

        double mx2_u, my2_u, mxy_u, rho2_u, rad_dist_u;

        mx2_u = p_u(0) * p_u(0);
        my2_u = p_u(1) * p_u(1);
        mxy_u = p_u(0) * p_u(1);
        rho2_u = mx2_u + my2_u;
        rad_dist_u = k1 * rho2_u + k2 * rho2_u * rho2_u;
        d_u << p_u(0) * rad_dist_u + 2.0 * p1 * mxy_u + p2 * (rho2_u + 2.0 * mx2_u),
               p_u(1) * rad_dist_u + 2.0 * p2 * mxy_u + p1 * (rho2_u + 2.0 * my2_u);

        double dxdmx = 1.0 + rad_dist_u + k1 * 2.0 * mx2_u + k2 * rho2_u * 4.0 * mx2_u + 2.0 * p1 * p_u(1) + 6.0 * p2 * p_u(0);
        double dydmx = k1 * 2.0 * p_u(0) * p_u(1) + k2 * 4.0 * rho2_u * p_u(0) * p_u(1) + p1 * 2.0 * p_u(0) + 2.0 * p2 * p_u(1);
        double dxdmy = dydmx;
        double dydmy = 1.0 + rad_dist_u + k1 * 2.0 * my2_u + k2 * rho2_u * 4.0 * my2_u + 6.0 * p1 * p_u(1) + 2.0 * p2 * p_u(0);

        J << dxdmx, dxdmy,
             dydmx, dydmy;
    }
    
    int PinholeCamera::parameterCount(void) const
    {
        return 8;
    }

    const PinholeCamera::Parameters& PinholeCamera::getParameters(void) const
    {
        return mParameters;
    }

    void PinholeCamera::setParameters(const PinholeCamera::Parameters& parameters)
    {
        mParameters = parameters;

        if ((mParameters.k1() == 0.0) && (mParameters.k2() == 0.0) && (mParameters.p1() == 0.0) && (mParameters.p2() == 0.0))
        {
            m_noDistortion = true;
        }
        else
        {
            m_noDistortion = false;
        }

        m_inv_K11 = 1.0 / mParameters.fx();
        m_inv_K13 = -mParameters.cx() / mParameters.fx();
        m_inv_K22 = 1.0 / mParameters.fy();
        m_inv_K23 = -mParameters.cy() / mParameters.fy();
    }

    void PinholeCamera::readParameters(const std::vector<double>& parameterVec)
    {
        if ((int)parameterVec.size() != parameterCount())
        {
            return;
        }

        Parameters params = getParameters();

        params.k1() = parameterVec.at(0);
        params.k2() = parameterVec.at(1);
        params.p1() = parameterVec.at(2);
        params.p2() = parameterVec.at(3);
        params.fx() = parameterVec.at(4);
        params.fy() = parameterVec.at(5);
        params.cx() = parameterVec.at(6);
        params.cy() = parameterVec.at(7);

        setParameters(params);
    }

    void PinholeCamera::writeParameters(std::vector<double>& parameterVec) const
    {
        parameterVec.resize(parameterCount());
        parameterVec.at(0) = mParameters.k1();
        parameterVec.at(1) = mParameters.k2();
        parameterVec.at(2) = mParameters.p1();
        parameterVec.at(3) = mParameters.p2();
        parameterVec.at(4) = mParameters.fx();
        parameterVec.at(5) = mParameters.fy();
        parameterVec.at(6) = mParameters.cx();
        parameterVec.at(7) = mParameters.cy();
    }

    void PinholeCamera::writeParametersToYamlFile(const std::string& filename) const
    {
        mParameters.writeToYamlFile(filename);
    }

    std::string PinholeCamera::parametersToString(void) const
    {
        std::ostringstream oss;
        oss << mParameters;

        return oss.str();
    }
    
}


================================================
FILE: camera_model/src/camera.cpp
================================================
/**   This File is part of Camera Model
 *  
 *    
 *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,
 *                                     lcw18@mails.tsinghua.edu.cn (valid until 2023))
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *    
 *    Since some functions are adapted from GVINS <https://github.com/HKUST-Aerial-Robotics/GVINS>
 *    GVINS is under GPLv3 License.
 */

#include "camera.h"

namespace camera_model
{
    Camera::Parameters::Parameters(ModelType modelType): m_modelType(modelType), m_imageWidth(0), m_imageHeight(0)
    {
        switch (modelType)
        {
            case PINHOLE:
                m_nIntrinsics = 8;
                break;
            case MEI:
            default:
                m_nIntrinsics = 9;
        }
    }
    
    Camera::Parameters::Parameters(ModelType modelType, const std::string& cameraName, int w, int h): m_modelType(modelType), m_cameraName(cameraName), m_imageWidth(w),  m_imageHeight(h)
    {
        switch (modelType)
        {
            case PINHOLE:
                m_nIntrinsics = 8;
                break;
            case MEI:
            default:
                m_nIntrinsics = 9;
        }
    }
    
    Camera::ModelType& Camera::Parameters::modelType()
    {
        return m_modelType;
    }
    
    std::string& Camera::Parameters::cameraName()
    {
        return m_cameraName;
    }
    
    int& Camera::Parameters::imageWidth()
    {
        return m_imageWidth;
    }

    int& Camera::Parameters::imageHeight()
    {
        return m_imageHeight;
    }

    Camera::ModelType Camera::Parameters::modelType() const 
    {
        return m_modelType;
    }

    const std::string& Camera::Parameters::cameraName() const
    {
        return m_cameraName;
    }

    int Camera::Parameters::imageWidth() const
    {
        return m_imageWidth;
    }

    int Camera::Parameters::imageHeight() const
    {
        return m_imageHeight;
    }

    int Camera::Parameters::nIntrinsics() const
    {
        return m_nIntrinsics;
    }

    cv::Mat& Camera::mask()
    {
        return m_mask;
    }

    const cv::Mat& Camera::mask() const
    {
        return m_mask;
    }    
    
    double Camera::reprojectionDist(const Eigen::Vector3d& P1, const Eigen::Vector3d& P2) const
    {
        Eigen::Vector2d p1, p2;
        
        spaceToPlane(P1, p1);
        spaceToPlane(P2, p2);
        
        return (p1-p2).norm();
    }
    
    double Camera::reprojectionError(const Eigen::Vector3d& P, 
                                     const Eigen::Quaterniond& camera_q, 
                                     const Eigen::Vector3d& camera_t, 
                                     const Eigen::Vector2d& observed_p) const
    {
        Eigen::Vector3d P_cam = camera_q.toRotationMatrix() * P + camera_t;

        Eigen::Vector2d p;
        spaceToPlane(P_cam, p);

        return (p - observed_p).norm();
    }
}


================================================
FILE: camera_model/src/camera_factory.cpp
================================================
/**   This File is part of Camera Model
 *  
 *    
 *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,
 *                                     lcw18@mails.tsinghua.edu.cn (valid until 2023))
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *    
 *    Since some functions are adapted from GVINS <https://github.com/HKUST-Aerial-Robotics/GVINS>
 *    GVINS is under GPLv3 License.
 */

#include "camera_factory.h"
#include "MeiCamera.h"
#include "PinholeCamera.h"

#include <boost/algorithm/string.hpp>

namespace camera_model
{
    boost::shared_ptr<CameraFactory> CameraFactory::m_instance;
    
    CameraFactory::CameraFactory() {}
    
    boost::shared_ptr<CameraFactory> CameraFactory::instance(void)
    {
        if (m_instance.get() == 0)
            m_instance.reset(new CameraFactory);
        
        return m_instance;
    }
    
    CameraPtr CameraFactory::generateCamera(Camera::ModelType modelType, const std::string& cameraName, cv::Size imageSize) const
    {
        switch (modelType)
        {
            case Camera::PINHOLE:
            {
                PinholeCameraPtr camera(new PinholeCamera);
                
                PinholeCamera::Parameters params = camera->getParameters();
                params.cameraName() = cameraName;
                params.imageWidth() = imageSize.width;
                params.imageHeight() = imageSize.height;
                
                camera->setParameters(params);
                return camera;
            }
            case Camera::MEI:
            default:
            {
                MeiCameraPtr camera(new MeiCamera);
                
                MeiCamera::Parameters params = camera->getParameters();
                params.cameraName() = cameraName;
                params.imageWidth() = imageSize.width;
                params.imageHeight() = imageSize.height;
                
                camera->setParameters(params);
                return camera;
            }
        }
    }
    
    CameraPtr CameraFactory::generateCameraFromYamlFile(const std::string& filename)
    {
        cv::FileStorage fs(filename, cv::FileStorage::READ);
        
        if (!fs.isOpened())
            return CameraPtr();
        
        Camera::ModelType modelType = Camera::MEI;
        if (!fs["model_type"].isNone())
        {
            std::string sModelType;
            fs["model_type"] >> sModelType;
            
            if (boost::iequals(sModelType, "MEI"))
            {
                modelType = Camera::MEI;
            }
            else if (boost::iequals(sModelType, "PINHOLE"))
            {
                modelType = Camera::PINHOLE;
            }
            else
            {
                std::cerr << "# ERROR: Unknown camera model type: " << sModelType << std::endl;
                return CameraPtr();
            }
        }
        
        switch (modelType)
        {
            case Camera::PINHOLE:
            {
                PinholeCameraPtr camera(new PinholeCamera);
                
                PinholeCamera::Parameters params = camera->getParameters();
                params.readFromYamlFile(filename);
                
                camera->setParameters(params);
                return camera;
            }
            case Camera::MEI:
            default:
            {
                MeiCameraPtr camera(new MeiCamera);
                
                MeiCamera::Parameters params = camera->getParameters();
                params.readFromYamlFile(filename);
                
                camera->setParameters(params);
                return camera;
            }
        }
        
        return CameraPtr();
    }
    
}


================================================
FILE: camera_model/test/CMakeLists.txt
================================================
# find_package(GTest REQUIRED)
# include_directories(${GTEST_INCLUDE_DIRS})

# add each test source file and executable items
# add_executable(test_common test_common.cpp)
# target_link_libraries(test_common ${GTEST_BOTH_LIBRARIES} pthread)
# gtest_discover_tests(test_common)


================================================
FILE: config/fw_zed2i_f9p/ingvio_mono.yaml
================================================
%YAML:1.0
# config for fw_zed2i_f9p

imu_topic: "/imu0"
feature_topic: "/mono_tracker/mono_feature"

cam_nums: 1
cam_left_file_path: "/home/lcw/VIO/ws_ingvio/src/config/fw_zed2i_f9p/mono_config.yaml"

max_sliding_window_poses: 25
is_key_frame: 1
max_landmark_features: 0

enable_gnss: 1

noise_gyro: 0.005
noise_accel: 0.09
noise_bias_gyro: 0.0005
noise_bias_accel: 0.009
noise_rcv_clockbias: 2.0
noise_rcv_clockbias_randomwalk: 0.2

init_cov_rot: 0.0
init_cov_pos: 0.0
init_cov_vel: 0.25
init_cov_bg: 0.01
init_cov_ba: 0.01
init_cov_ext_rot: 1.8e-02
init_cov_ext_pos: 2e-03
init_cov_rcv_clockbias: 2.0
init_cov_rcv_clockbias_randomwalk: 1.0
init_cov_yof: 0.015

gravity_norm: 9.8
max_imu_buffer_size: 10000
init_imu_buffer_sp: 100

trans_thres: 0.25
huber_epsilon: 0.01
conv_precision: 5e-08
init_damping: 1e-03
outer_loop_max_iter: 10
inner_loop_max_iter: 10
max_depth: 80.0
min_depth: 0.2
max_baseline_ratio: 80.0

chi2_max_dof: 150
chi2_thres: 0.95
visual_noise: 0.08
frame_select_interval: 23

gnss_ephem_topic: "/ublox_driver/ephem"
gnss_glo_ephem_topic: "/ublox_driver/glo_ephem"
gnss_meas_topic: "/ublox_driver/range_meas"
gnss_iono_params_topic: "/ublox_driver/iono_params"
rtk_gt_topic: "/ublox_driver/receiver_lla"

gnss_elevation_thres: 20.0
gnss_psr_std_thres: 8.0
gnss_dopp_std_thres: 8.0
gnss_track_num_thres: 20

use_fix_time_offset: 1
gnss_local_offset: -970047.18
gnss_chi2_test: 0
gnss_strong_reject: 0

gv_align_batch_size: 25
gv_align_max_iter: 10
gv_align_conv_epsilon: 1e-05       
gv_align_vel_thres: 0.4

psr_noise_amp: 1.0
dopp_noise_amp: 1.0
is_adjust_yof: 0


================================================
FILE: config/fw_zed2i_f9p/ingvio_stereo.yaml
================================================
%YAML:1.0
# config for fw_zed2i_f9p

imu_topic: "/imu0"
feature_topic: "/stereo_tracker/stereo_feature"

cam_nums: 2
cam_left_file_path: "/home/lcw/VIO/ws_ingvio/src/config/fw_zed2i_f9p/stereo_left_config.yaml"
cam_right_file_path: "/home/lcw/VIO/ws_ingvio/src/config/fw_zed2i_f9p/stereo_right_config.yaml"

max_sliding_window_poses: 21
is_key_frame: 1
max_landmark_features: 0

enable_gnss: 1

noise_gyro: 0.005
noise_accel: 0.09
noise_bias_gyro: 0.0005
noise_bias_accel: 0.009
noise_rcv_clockbias: 2.0
noise_rcv_clockbias_randomwalk: 0.2

init_cov_rot: 0.0
init_cov_pos: 0.0
init_cov_vel: 0.25
init_cov_bg: 0.01
init_cov_ba: 0.01
init_cov_ext_rot: 1.8e-02
init_cov_ext_pos: 2e-03
init_cov_rcv_clockbias: 2.0
init_cov_rcv_clockbias_randomwalk: 1.0
init_cov_yof: 0.015

gravity_norm: 9.8
max_imu_buffer_size: 10000
init_imu_buffer_sp: 100

trans_thres: 0.25
huber_epsilon: 0.01
conv_precision: 5e-08
init_damping: 1e-03
outer_loop_max_iter: 10
inner_loop_max_iter: 10
max_depth: 80.0
min_depth: 0.2
max_baseline_ratio: 80.0

chi2_max_dof: 150
chi2_thres: 0.95
visual_noise: 0.08
frame_select_interval: 18

gnss_ephem_topic: "/ublox_driver/ephem"
gnss_glo_ephem_topic: "/ublox_driver/glo_ephem"
gnss_meas_topic: "/ublox_driver/range_meas"
gnss_iono_params_topic: "/ublox_driver/iono_params"
rtk_gt_topic: "/ublox_driver/receiver_lla"

gnss_elevation_thres: 20.0
gnss_psr_std_thres: 8.0
gnss_dopp_std_thres: 8.0
gnss_track_num_thres: 20

use_fix_time_offset: 1
gnss_local_offset:  -970047.18
gnss_chi2_test: 0
gnss_strong_reject: 0

gv_align_batch_size: 25
gv_align_max_iter: 10
gv_align_conv_epsilon: 1e-05       
gv_align_vel_thres: 0.4

psr_noise_amp: 1.0
dopp_noise_amp: 1.0
is_adjust_yof: 0



================================================
FILE: config/fw_zed2i_f9p/mono_config.yaml
================================================
%YAML:1.0
# config for fw_zed2i_f9p

# common parameters
imu_topic: "/imu0"
image_topic: "/cam0/image_raw"

# intrinsic
model_type: PINHOLE
camera_name: cam0
image_width: 1280
image_height: 720
distortion_parameters:
   k1: -0.013323572637177162
   k2: 0.012297484726727028
   p1: -0.0008173313551158254
   p2: -0.0036129297585792528
projection_parameters:
   fx: 528.0821562999166
   fy: 528.1818555071027
   cx: 646.6309796410819
   cy: 351.87255392593374
   
# extrinsic
extrinsicRotation: !!opencv-matrix        # R^{imu}_{cam}
   rows: 3
   cols: 3
   dt: d
   data: [0.01301095634388352, -0.005070623738001712, 0.9999024971415602, 
          -0.9999097972900367, 0.003267771869320563, 0.01302762259241452, 
         -0.003333511424589375, -0.9999818050554322, -0.005027649516865795]
extrinsicTranslation: !!opencv-matrix     # t^{imu}_{cam}
   rows: 3
   cols: 1
   dt: d
   data: [0.03671615355111148, 0.02169026717979497, -0.0000578135929000942]
   

# feature tracker parameters
max_cnt: 100        # max feature number in feature tracking
min_dist: 35        # min distance between two features 
freq: 0             # freq (Hz) of publishing tracking result. At least 10Hz for good
                    # estimation. If set 0, the frequence will be the same as raw image 
F_threshold: 1.0    # ransac threshold (pixel)
show_track: 1       # publish tracking image as topic
show_timer: 0       # show time counting
timer_warning_thres: 50.0 # in (ms)
equalize: 1         # if image is too dark or light, 
                    # turn on equalize to find enough features


================================================
FILE: config/fw_zed2i_f9p/stereo_left_config.yaml
================================================
%YAML:1.0
# config for fw_zed2i_f9p

#topic parameters
imu_topic: "/imu0"
cam_left_topic: "/cam0/image_raw"
cam_right_topic: "/cam1/image_raw"

# intrinsic
model_type: PINHOLE
camera_name: cam0
image_width: 1280
image_height: 720
distortion_parameters:
   k1: -0.013323572637177162
   k2: 0.012297484726727028
   p1: -0.0008173313551158254
   p2: -0.0036129297585792528
projection_parameters:
   fx: 528.0821562999166
   fy: 528.1818555071027
   cx: 646.6309796410819
   cy: 351.87255392593374
   
# extrinsic
extrinsicRotation: !!opencv-matrix        # R^{imu}_{cam}
   rows: 3
   cols: 3
   dt: d
   data: [0.01301095634388352, -0.005070623738001712, 0.9999024971415602, 
          -0.9999097972900367, 0.003267771869320563, 0.01302762259241452, 
         -0.003333511424589375, -0.9999818050554322, -0.005027649516865795]
extrinsicTranslation: !!opencv-matrix     # t^{imu}_{cam}
   rows: 3
   cols: 1
   dt: d
   data: [0.03671615355111148, 0.02169026717979497, -0.0000578135929000942]

# tracker config
max_cnt: 60            # max feature number in feature tracking
min_dist: 45              # min distance between two features 
freq: 0                         # frequence (Hz) of publish tracking result. At least 10Hz for good estimation. If set 0, the frequence will be the same as raw image 
show_track: 1          # publish tracking image as topic
show_timer: 0       # show time counting
timer_warning_thres: 50.0 # in (ms)
equalize: 1                # if image is too dark or light, turn on equalize to find enough features
window_size: 20
epipolar_thres: 15.0
F_threshold: 1.0
print_track_info: 0


================================================
FILE: config/fw_zed2i_f9p/stereo_right_config.yaml
================================================
%YAML:1.0
# config for fw_zed2i_f9p

# intrinsic
model_type: PINHOLE
camera_name: cam1
image_width: 1280
image_height: 720
distortion_parameters:
   k1: -0.013705400292675644
   k2: 0.01351956571839721
   p1: -0.000806913038206586
   p2: -0.0028638404748635034
projection_parameters:
   fx: 527.4644311562542
   fy: 527.9383388808839
   cx: 647.6983568199339
   cy: 351.1977685749355

# extrinsic
extrinsicRotation: !!opencv-matrix        # R^{imu}_{cam}
   rows: 3
   cols: 3
   dt: d
   data: [ 0.01129080808837021, -0.004471320310557636, 0.9999262597548844,
          -0.9999301632412926,   0.00344058703135805, 0.01130623726631103,
          -0.003490887129951881,-0.9999840847011319, -0.004432161040157589]
extrinsicTranslation: !!opencv-matrix     # t^{imu}_{cam}
   rows: 3
   cols: 1
   dt: d
   data: [0.03767186874423049, -0.0980688527108189, -0.0002632245838794373]
   



================================================
FILE: config/sportsfield/ingvio_mono.yaml
================================================
%YAML:1.0
# config for sportsfield

imu_topic: "/imu0"
feature_topic: "/mono_tracker/mono_feature"

cam_nums: 1
cam_left_file_path: "/home/lcw/VIO/ws_ingvio/src/config/sportsfield/mono_config.yaml"

max_sliding_window_poses: 35
is_key_frame: 1
max_landmark_features: 0

enable_gnss: 1

noise_gyro: 0.004
noise_accel: 0.08
noise_bias_gyro: 0.0002
noise_bias_accel: 0.008
noise_rcv_clockbias: 2.0
noise_rcv_clockbias_randomwalk: 0.2

init_cov_rot: 0.0
init_cov_pos: 0.0
init_cov_vel: 0.25
init_cov_bg: 0.01
init_cov_ba: 0.01
init_cov_ext_rot: 1.8e-02
init_cov_ext_pos: 2e-03
init_cov_rcv_clockbias: 2.0
init_cov_rcv_clockbias_randomwalk: 1.0
init_cov_yof: 0.015

gravity_norm: 9.8
max_imu_buffer_size: 3000
init_imu_buffer_sp: 300

trans_thres: 0.25
huber_epsilon: 0.01
conv_precision: 5e-08
init_damping: 1e-03
outer_loop_max_iter: 10
inner_loop_max_iter: 10
max_depth: 60.0
min_depth: 0.2
max_baseline_ratio: 80.0

chi2_max_dof: 150
chi2_thres: 0.95
visual_noise: 0.18
frame_select_interval: 28

gnss_ephem_topic: "/ublox_driver/ephem"
gnss_glo_ephem_topic: "/ublox_driver/glo_ephem"
gnss_meas_topic: "/ublox_driver/range_meas"
gnss_iono_params_topic: "/ublox_driver/iono_params"
rtk_gt_topic: "/ublox_driver/receiver_lla"

gnss_elevation_thres: 20.0
gnss_psr_std_thres: 8.0
gnss_dopp_std_thres: 8.0
gnss_track_num_thres: 20

use_fix_time_offset: 1
gnss_local_offset: -18.0
gnss_chi2_test: 0
gnss_strong_reject: 1

gv_align_batch_size: 45
gv_align_max_iter: 25
gv_align_conv_epsilon: 1e-05       
gv_align_vel_thres: 0.4

psr_noise_amp: 1.0
dopp_noise_amp: 1.0
is_adjust_yof: 0


================================================
FILE: config/sportsfield/ingvio_stereo.yaml
================================================
%YAML:1.0
# config for sportsfield

imu_topic: "/imu0"
feature_topic: "/stereo_tracker/stereo_feature"

cam_nums: 2
cam_left_file_path: "/home/lcw/VIO/ws_ingvio/src/config/sportsfield/stereo_left_config.yaml"
cam_right_file_path: "/home/lcw/VIO/ws_ingvio/src/config/sportsfield/stereo_right_config.yaml"

max_sliding_window_poses: 27
is_key_frame: 1
max_landmark_features: 0

enable_gnss: 1

noise_gyro: 0.004
noise_accel: 0.08
noise_bias_gyro: 0.0002
noise_bias_accel: 0.008
noise_rcv_clockbias: 2.0
noise_rcv_clockbias_randomwalk: 0.2

init_cov_rot: 0.0
init_cov_pos: 0.0
init_cov_vel: 0.25
init_cov_bg: 0.01
init_cov_ba: 0.01
init_cov_ext_rot: 1.8e-02
init_cov_ext_pos: 2e-03
init_cov_rcv_clockbias: 2.0
init_cov_rcv_clockbias_randomwalk: 1.0
init_cov_yof: 0.015

gravity_norm: 9.8
max_imu_buffer_size: 3000
init_imu_buffer_sp: 300

trans_thres: 0.25
huber_epsilon: 0.01
conv_precision: 5e-07
init_damping: 1e-03
outer_loop_max_iter: 10
inner_loop_max_iter: 10
max_depth: 40.0
min_depth: 0.2
max_baseline_ratio: 80.0

chi2_max_dof: 150
chi2_thres: 0.95
visual_noise: 0.18
frame_select_interval: 18

gnss_ephem_topic: "/ublox_driver/ephem"
gnss_glo_ephem_topic: "/ublox_driver/glo_ephem"
gnss_meas_topic: "/ublox_driver/range_meas"
gnss_iono_params_topic: "/ublox_driver/iono_params"
rtk_gt_topic: "/ublox_driver/receiver_lla"

gnss_elevation_thres: 20.0
gnss_psr_std_thres: 8.0
gnss_dopp_std_thres: 8.0
gnss_track_num_thres: 20

use_fix_time_offset: 1
gnss_local_offset: -18.0
gnss_chi2_test: 0
gnss_strong_reject: 1

gv_align_batch_size: 25
gv_align_max_iter: 10
gv_align_conv_epsilon: 1e-05       
gv_align_vel_thres: 0.4

psr_noise_amp: 1.0
dopp_noise_amp: 1.0
is_adjust_yof: 0


================================================
FILE: config/sportsfield/mono_config.yaml
================================================
%YAML:1.0
# config for sportsfield

# common parameters
imu_topic: "/imu0"
image_topic: "/cam1/image_raw"

# camera calibration 
model_type: MEI
camera_name: camera
image_width: 752
image_height: 480
mirror_parameters:
   xi: 1.8476540167437447
distortion_parameters:
   k1: -0.06597811223735722
   k2: 0.8559479340704287
   p1: -0.0006445829733139821
   p2: 0.0015137487236065916
projection_parameters:
   gamma1: 1338.1845333957547
   gamma2: 1340.1190112672946
   u0: 378.7909740462579
   v0: 217.69105287172025

# extrinsic
extrinsicRotation: !!opencv-matrix        # R^{imu}_{cam}
   rows: 3
   cols: 3
   dt: d
   data: [ 0.9999014076382304, -0.0133731297219721, 0.0042818692791948,
           0.0133731003056063, 0.9999105754655292, 0.0000355022536769,
          -0.0042819611512717, 0.0000217631139403, 0.9999908321255077 ]
extrinsicTranslation: !!opencv-matrix     # t^{imu}_{cam}
   rows: 3
   cols: 1
   dt: d
   data: [0.0341738532732442, -0.0032623030537933, -0.0017782029037505]
   
# feature tracker parameters
max_cnt: 150        # max feature number in feature tracking
min_dist: 30        # min distance between two features 
freq: 0             # freq (Hz) of publishing tracking result. At least 10Hz for good
                    # estimation. If set 0, the frequence will be the same as raw image 
F_threshold: 1.0    # ransac threshold (pixel)
show_track: 1       # publish tracking image as topic
show_timer: 0       # show time counting
timer_warning_thres: 50.0 # in (ms)
equalize: 1         # if image is too dark or light, 
                    # turn on equalize to find enough features


================================================
FILE: config/sportsfield/stereo_left_config.yaml
================================================
%YAML:1.0
# config for sportsfield

#topic parameters
imu_topic: "/imu0"
cam_left_topic: "/cam1/image_raw"
cam_right_topic: "/cam0/image_raw"

# intrinsic
model_type: MEI
camera_name: cam1
image_width: 752
image_height: 480
mirror_parameters:
   xi: 1.8476540167437447
distortion_parameters:
   k1: -0.06597811223735722
   k2: 0.8559479340704287
   p1: -0.0006445829733139821
   p2: 0.0015137487236065916
projection_parameters:
   gamma1: 1338.1845333957547
   gamma2: 1340.1190112672946
   u0: 378.7909740462579
   v0: 217.69105287172025
   
# extrinsic
extrinsicRotation: !!opencv-matrix        # R^{imu}_{cam}
   rows: 3
   cols: 3
   dt: d
   data: [0.9999890386957373, -0.0043227774403168, 0.0017989117755288, 
          0.0043276579084841, 0.9999869417854389, -0.0027180205355500, 
         -0.0017871388870994, 0.0027257758172719, 0.9999946881262878]
extrinsicTranslation: !!opencv-matrix     # t^{imu}_{cam}
   rows: 3
   cols: 1
   dt: d
   data: [-0.0759472920952561, -0.0039320527565750, -0.0016395029500217]

# tracker config
max_cnt: 110            # max feature number in feature tracking
min_dist: 30              # min distance between two features 
freq: 0                         # frequence (Hz) of publish tracking result. At least 10Hz for good estimation. If set 0, the frequence will be the same as raw image 
show_track: 1          # publish tracking image as topic
show_timer: 0       # show time counting
timer_warning_thres: 50.0 # in (ms)
equalize: 1                # if image is too dark or light, turn on equalize to find enough features
window_size: 20
epipolar_thres: 25.0
F_threshold: 2.0
print_track_info: 0


================================================
FILE: config/sportsfield/stereo_right_config.yaml
================================================
%YAML:1.0
# config for sportsfield

# intrinsic
model_type: MEI
camera_name: cam0
image_width: 752
image_height: 480
mirror_parameters:
   xi: 1.8482000080983196
distortion_parameters:
   k1: -0.05322412328104923
   k2: 0.7676625579468673
   p1: -0.00019942420435829978
   p2: -0.0006936085281739436
projection_parameters:
   gamma1: 1330.3922281659666
   gamma2: 1332.49270401596
   u0: 377.39301029010045
   v0: 233.04955276185672

# extrinsic
extrinsicRotation: !!opencv-matrix        # R^{imu}_{cam}
   rows: 3
   cols: 3
   dt: d
   data: [ 0.9999014076382304, -0.0133731297219721, 0.0042818692791948,
           0.0133731003056063, 0.9999105754655292, 0.0000355022536769,
          -0.0042819611512717, 0.0000217631139403, 0.9999908321255077 ]
extrinsicTranslation: !!opencv-matrix     # t^{imu}_{cam}
   rows: 3
   cols: 1
   dt: d
   data: [0.0341738532732442, -0.0032623030537933, -0.0017782029037505]
   



================================================
FILE: feature_tracker/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 2.8.3)
project(feature_tracker)

set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS "-std=c++11")

find_package(catkin REQUIRED COMPONENTS
    roscpp
    std_msgs
    message_filters
    sensor_msgs
    cv_bridge
    camera_model
    message_generation
)

find_package(Boost REQUIRED COMPONENTS filesystem program_options system)
find_package(OpenCV REQUIRED)


add_message_files(
   FILES
   MonoMeas.msg
   MonoFrame.msg
   StereoMeas.msg
   StereoFrame.msg
)

generate_messages(
   DEPENDENCIES
   std_msgs
   geometry_msgs
)


catkin_package()

include_directories(
    ${PROJECT_SOURCE_DIR}/include
    "/usr/include/eigen3"
    ${catkin_INCLUDE_DIRS}
    ${OpenCV_INCLUDE_DIRS}
    ${Boost_INCLUDE_DIRS}
)

add_executable(mono_tracker
    src/mono_tracker.cpp
    src/mono_tracker_node.cpp
    src/mono_parameters.cpp
)

add_executable(stereo_tracker
    src/stereo_tracker.cpp
    src/stereo_tracker_node.cpp
    src/stereo_parameters.cpp
)

target_link_libraries(mono_tracker ${catkin_LIBRARIES} ${OpenCV_LIBS})
target_link_libraries(stereo_tracker ${catkin_LIBRARIES} ${OpenCV_LIBS})


================================================
FILE: feature_tracker/LICENSE
================================================
                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU General Public License is a free, copyleft license for
software and other kinds of works.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.  We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors.  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights.  Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received.  You must make sure that they, too, receive
or can get the source code.  And you must show them these terms so they
know their rights.

  Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

  For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software.  For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

  Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so.  This is fundamentally incompatible with the aim of
protecting users' freedom to change the software.  The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable.  Therefore, we
have designed this version of the GPL to prohibit the practice for those
products.  If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

  Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary.  To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Use with the GNU Affero General Public License.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

    <program>  Copyright (C) <year>  <name of author>
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.

  The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.


================================================
FILE: feature_tracker/include/Color.h
================================================
/**   This File is part of Feature Tracker
 *  
 *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,
 *                                     lcw18@mails.tsinghua.edu.cn (valid until 2023))
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#pragma once

#include <iostream>

namespace color
{
    inline std::ostream& setBlue(std::ostream& s)
    {
        s << "\033[0;1;34m";
        return s;
    }
    
    inline std::ostream& setRed(std::ostream& s)
    {
        s << "\033[0;1;31m";
        return s;
    }
    
    inline std::ostream& setGreen(std::ostream& s)
    {
        s << "\033[0;1;32m";
        return s;
    }
    
    inline std::ostream& setYellow(std::ostream& s)
    {
        s << "\033[0;1;33m";
        return s;
    }
    
    inline std::ostream& setWhite(std::ostream& s)
    {
        s << "\033[0;1;37m";
        return s;
    }
    
    inline std::ostream& resetColor(std::ostream& s)
    {
        s << "\033[0m";
        return s;
    }
}


================================================
FILE: feature_tracker/include/mono_parameters.h
================================================
/**   This File is part of Feature Tracker
 *  
 *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,
 *                                     lcw18@mails.tsinghua.edu.cn (valid until 2023))
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *    
 *    A few functions of the mono tracker mimic the realization from GVINS
 *    <https://github.com/HKUST-Aerial-Robotics/GVINS>
 *    GVINS is under GPLv3 License.
 */
 
#pragma once

#include <ros/ros.h>
#include <opencv2/highgui/highgui.hpp>

namespace feature_tracker
{
    class MonoParameters
    {
    public:
        MonoParameters();
        
        int row, col;
        int focal_length;
        
        std::string image_topic;
        std::string imu_topic;
        std::string cam_name;
        std::string cam_path;
        
        int max_cnt;
        int min_dist;
        
        int window_size;
        int freq;
        
        double f_threshold;
        
        int show_track;
        int equalize;
        double timer_warning_thres;
        int show_timer;
        
        void readParameters(ros::NodeHandle& n);
        
        template <typename T>
        static T readParam(ros::NodeHandle& n, std::string name);
    };
    
    template <typename T>
    T MonoParameters::readParam(ros::NodeHandle& n, std::string name)
    {
        T ans;
        if (n.getParam(name, ans))
        {
            ROS_INFO_STREAM("Loaded " << name << ": " << ans);    
        }
        else
        {
            ROS_ERROR_STREAM("Failed to load: " << name);
            n.shutdown();
        }
        
        return ans;
    }

}



================================================
FILE: feature_tracker/include/mono_tracker.h
================================================
/**   This File is part of Feature Tracker
 *  
 *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,
 *                                     lcw18@mails.tsinghua.edu.cn (valid until 2023))
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *    
 *    A few functions of the mono tracker mimic the realization from GVINS
 *    <https://github.com/HKUST-Aerial-Robotics/GVINS>
 *    GVINS is under GPLv3 License.
 */
 

#pragma once

#include <ros/ros.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/image_encodings.h>

#include <cv_bridge/cv_bridge.h>
#include <message_filters/subscriber.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>

#include <opencv2/opencv.hpp>

#include <Eigen/Core>
#include <Eigen/Geometry>

#include "tic_toc.hpp"

#include "camera_factory.h"
#include "MeiCamera.h"
#include "PinholeCamera.h"

#include "mono_parameters.h"

#include <feature_tracker/MonoMeas.h>
#include <feature_tracker/MonoFrame.h>

namespace feature_tracker
{
    class MonoTracker
    {
    public:
        EIGEN_MAKE_ALIGNED_OPERATOR_NEW
        
        MonoTracker(ros::NodeHandle& n) : nh(n) {}
        ~MonoTracker() {}
        MonoTracker(const MonoTracker&) = delete;
        MonoTracker operator=(const MonoTracker&) = delete;
        
        void init();
        
    private:
        ros::NodeHandle nh;
        ros::Publisher pub_mono_features, pub_match;
        ros::Subscriber sub_img;
        void img_callback(const sensor_msgs::ImageConstPtr& img_msg);
        
        MonoParameters param;
        camera_model::CameraPtr m_camera;        
        
        bool pub_this_frame;
        bool first_image_flag;
        double first_image_time, last_image_time;
        int pub_count;
        
        static int n_id;
        
        double cur_time, prev_time;
        cv::Mat mask;
        cv::Mat prev_img, cur_img, forw_img;
        
        std::vector<cv::Point2f> prev_pts, cur_pts, forw_pts;
        std::vector<cv::Point2f> prev_un_pts, cur_un_pts;
        std::vector<cv::Point2f> pts_velocity;
        std::vector<cv::Point2f> n_pts;
        
        std::vector<int> ids;
        std::vector<int> track_cnt;
        
        std::map<int, cv::Point2f> cur_un_pts_map;
        std::map<int, cv::Point2f> prev_un_pts_map;
        
        
        void readImage(const cv::Mat& _img, double _cur_time);
        
        void rejectWithF();
        
        void setMask();
        
        void addPoints();
        
        void undistortedPoints();
        
        void updateID();
        
        
        bool inBorder(const cv::Point2f& pt);
        
        template <typename T1, typename T2 = uchar>
        void reduceVector(std::vector<T1>& v, std::vector<T2> status);
        
        void readIntrinsicParameter(const std::string& calib_file);
    };
    
    typedef boost::shared_ptr<MonoTracker> MonoTrackerPtr; 
    
    template <typename T1, typename T2>
    void MonoTracker::reduceVector(std::vector<T1>& v, std::vector<T2> status)
    {
        int j = 0;
        for (int i = 0; i < int(v.size()); ++i)
            if (status[i])
                v[j++] = v[i];
            
        v.resize(j);
    }
}


================================================
FILE: feature_tracker/include/random_pair.hpp
================================================
/**   This File is part of Feature Tracker
 *  
 *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,
 *                                     lcw18@mails.tsinghua.edu.cn (valid until 2023))
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#pragma once

#include <vector>
#include <ctime>
#include <algorithm>
#include <cmath>

namespace feature_tracker
{
    class RandomPairGenerator
    {
    public:
        RandomPairGenerator(unsigned int n = 50) : xa(static_cast<int>(n*(n-1)/2)), count(0), N(n) 
        {
            for (int i = 0; i < static_cast<int>(n*(n-1)/2); ++i)
                xa[i] = i;
            std::random_shuffle(xa.begin(), xa.end());
        }
        RandomPairGenerator(RandomPairGenerator& obj) = delete;
        ~RandomPairGenerator(){}
        
        static void setRandomPairSeed()
        {
            srand((unsigned)time(NULL));
        }
        
        void generatePair(std::vector<unsigned int>& pair)
        {
            pair.clear();
            unsigned int i = xa[count];
            
            float k_max = (1.0+sqrt(i*8+9))/2.0;
            float k_min = (-1.0+sqrt(i*8+9))/2.0;
            
            float k_guess = floor(k_max);
            unsigned int k;
            
            if (k_guess < k_max && k_guess >= k_min)
                k = static_cast<unsigned int>(k_guess);
            else
                k = static_cast<unsigned int>(k_guess)-1;
            
            pair.push_back(N-k-1);
            pair.push_back(N-k+i-static_cast<unsigned int>(k*(k-1)/2));
            
            ++count;
            if (count >= static_cast<int>(N*(N-1)/2)) count = 0;
        }
    private:
        std::vector<unsigned int> xa;
        unsigned int count;
        unsigned int N;
    };
}



================================================
FILE: feature_tracker/include/stereo_parameters.h
================================================
/**   This File is part of Feature Tracker
 *  
 *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,
 *                                     lcw18@mails.tsinghua.edu.cn (valid until 2023))
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#pragma once

#include <ros/ros.h>
#include <opencv2/highgui/highgui.hpp>

#include <Eigen/Core>
#include <Eigen/Geometry>

namespace feature_tracker
{
    class StereoParameters
    {
    public:
        EIGEN_MAKE_ALIGNED_OPERATOR_NEW
        
        StereoParameters();
        
        int row, col;
        
        std::string image_left_topic;
        std::string image_right_topic;
        
        std::string cam_left_path;
        std::string cam_right_path;
        
        std::string cam_left_name;
        std::string cam_right_name;
        
        int max_cnt;
        int min_dist;
        
        int window_size;
        int freq;
        
        int show_track;
        
        int show_timer;
        double timer_warning_thres;
        
        int equalize;
        
        double epipolar_thres;
        double F_threshold;
        
        int print_track_info;
        
        Eigen::Isometry3d T_cl2i, T_cr2i;
        
        void readParameters(ros::NodeHandle& n);
        
        template <typename T>
        static T readParam(ros::NodeHandle& n, std::string name);
    };
    
    template <typename T>
    T StereoParameters::readParam(ros::NodeHandle& n, std::string name)
    {
        T ans;
        if (n.getParam(name, ans))
        {
            ROS_INFO_STREAM("Loaded " << name << ": " << ans);    
        }
        else
        {
            ROS_ERROR_STREAM("Failed to load: " << name);
            n.shutdown();
        }
        
        return ans;
    }
    
}


================================================
FILE: feature_tracker/include/stereo_tracker.h
================================================
/**   This File is part of Feature Tracker
 *  
 *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,
 *                                     lcw18@mails.tsinghua.edu.cn (valid until 2023))
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#pragma once

#include <ros/ros.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/image_encodings.h>

#include <cv_bridge/cv_bridge.h>

#include <message_filters/subscriber.h>
#include <message_filters/synchronizer.h>
#include <message_filters/sync_policies/approximate_time.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>

#include <opencv2/opencv.hpp>

#include <Eigen/Core>
#include <Eigen/Geometry>

#include "tic_toc.hpp"

#include "camera_factory.h"
#include "MeiCamera.h"
#include "PinholeCamera.h"

#include "random_pair.hpp"
#include "stereo_parameters.h"

#include "feature_tracker/StereoMeas.h"
#include "feature_tracker/StereoFrame.h"

namespace feature_tracker
{
    class StereoTracker
    {
    public:
        EIGEN_MAKE_ALIGNED_OPERATOR_NEW
        
        StereoTracker(ros::NodeHandle& n) : nh(n) {}
        ~StereoTracker() {}
        StereoTracker(const StereoTracker&) = delete;
        StereoTracker operator=(const StereoTracker&) = delete;
        
        void init();
        
    private:
        ros::NodeHandle nh;
        ros::Publisher pub_stereo_feature, pub_match;
        
        typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::Image, sensor_msgs::Image> stereoSyncPolicy;
        boost::shared_ptr<message_filters::Subscriber<sensor_msgs::Image>> cam_left_sub_;
        boost::shared_ptr<message_filters::Subscriber<sensor_msgs::Image>> cam_right_sub_;
        boost::shared_ptr<message_filters::Synchronizer<stereoSyncPolicy>> stereo_sub_;
        
        StereoParameters param;
        camera_model::CameraPtr m_camera_left, m_camera_right;
        
        cv::Mat mask;
        bool first_image_flag;
        double first_image_time, last_image_time;
        bool pub_this_frame;
        unsigned long long int pub_count;
        
        double cur_time, prev_time;
        cv::Mat prev_left_img, cur_left_img, forw_left_img;
        cv::Mat prev_right_img, cur_right_img, forw_right_img;
        
        std::vector<cv::Point2f> prev_left_pts, cur_left_pts, forw_left_pts;
        std::vector<cv::Point2f> prev_right_pts, cur_right_pts, forw_right_pts;
        
        std::vector<cv::Point2f> prev_left_un_pts, cur_left_un_pts;
        std::vector<cv::Point2f> prev_right_un_pts, cur_right_un_pts;
        
        std::vector<unsigned long long int> ids;
        std::vector<unsigned int> track_cnt;
        
        std::vector<cv::Point2f> n_left_pts, n_right_pts;
        
        static unsigned long long int n_id;
        
        
        void stereo_callback(const sensor_msgs::Image::ConstPtr& cam_left_msg, const sensor_msgs::Image::ConstPtr& cam_right_msg);
        
        void readIntrinsicParameters();
        
        void processStereoImage(const cv::Mat& _left_img, const cv::Mat& _right_img, double _cur_time);
        
        bool inBorder(const cv::Point2f& pt);
        
        void markStereoMatchOutlier(const std::vector<cv::Point2f>& left_pts, const std::vector<cv::Point2f>& right_pts, std::vector<uchar>& status);
        
        void rejectWithTwinRANSAC();
        
        void setMask();
        
        void addPoints();
        
        void undistortedPoints();
        
        void updateID();
        
        static void publishStereoImg(const cv::Mat& left_img, const cv::Mat& right_img, const std::vector<cv::Point2f>& left_pts, const std::vector<cv::Point2f>& right_pts, const int row, const int col, bool pair_line = true);
        
        void predictHomography(const std::vector<cv::Point2f>& left_pts, std::vector<cv::Point2f>& right_pts);
        
        template <typename T1, typename T2 = uchar>
        void reduceVector(std::vector<T1>& v, std::vector<T2> status);
        
        template <typename T1, typename T2 = uchar>
        void reduceTwinVector(std::vector<T1>& v1, std::vector<T1>& v2, std::vector<T2> status);
        
        template <typename T1, typename T2 = uchar>
        void reduceQuadVector(std::vector<T1>& v1, std::vector<T1>& v2, std::vector<T1>& v3, std::vector<T1>& v4, std::vector<T2> status);
    };
    
    typedef boost::shared_ptr<StereoTracker> StereoTrackerPtr;
    
    template <typename T1, typename T2>
    void StereoTracker::reduceVector(std::vector<T1>& v, std::vector<T2> status)
    {
        int j = 0;
        for (int i = 0; i < int(v.size()); ++i)
            if (status[i])
                v[j++] = v[i];
            
        v.resize(j);
    }    
    
    template <typename T1, typename T2>
    void StereoTracker::reduceTwinVector(std::vector<T1>& v1, std::vector<T1>& v2, std::vector<T2> status)
    {
        if (v1.size() != v2.size())
            ROS_WARN("[Stereo Tracker]: Reduce twin vectors, size: %i and %i are not equal!", int(v1.size()), int(v2.size()));
        
        int j = 0;
        for (int i = 0; i < int(v1.size()); ++i)
            if (status[i])
            {
                v1[j] = v1[i];
                v2[j] = v2[i];
                ++j;
            }
            
        v1.resize(j);
        v2.resize(j);        
    }
    
    template <typename T1, typename T2>
    void StereoTracker::reduceQuadVector(std::vector<T1>& v1, std::vector<T1>& v2, std::vector<T1>& v3, std::vector<T1>& v4, std::vector<T2> status)
    {
        if (!(v1.size() == v2.size() && v2.size() == v3.size() && v3.size() == v4.size()))
            ROS_WARN("[Stereo Tracker]: Reduce quad vectors, size: %i, %i, %i and %i  are not equal!", int(v1.size()), int(v2.size()), int(v3.size()), int(v4.size())); 
        
        int j = 0;
        for (int i = 0; i < int(v1.size()); ++i)
            if (status[i])
            {
                v1[j] = v1[i];
                v2[j] = v2[i];
                v3[j] = v3[i];
                v4[j] = v4[i];
                ++j;
            }
            
        v1.resize(j);
        v2.resize(j);         
        v3.resize(j);
        v4.resize(j);
    }
}


================================================
FILE: feature_tracker/include/tic_toc.hpp
================================================
/**   This File is part of Feature Tracker
 *  
 *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,
 *                                     lcw18@mails.tsinghua.edu.cn (valid until 2023))
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *    
 *    A few functions of the mono tracker mimic the realization from GVINS
 *    <https://github.com/HKUST-Aerial-Robotics/GVINS>
 *    GVINS is under GPLv3 License.
 */

#pragma once

#include <ctime>
#include <cstdlib>
#include <chrono>

namespace feature_tracker
{
    class TicToc
    {
    public:
        TicToc()
        {
            tic();
        }
        
        void tic()
        {
            start = std::chrono::system_clock::now();
        }
        
        double toc()
        {
            end = std::chrono::system_clock::now();
            std::chrono::duration<double> elapsed_seconds = end - start;
            return elapsed_seconds.count() * 1000.0;
        }
        
    private:
        std::chrono::time_point<std::chrono::system_clock> start, end;
    };
}



================================================
FILE: feature_tracker/launch/sportsfield/mono_tracker_sf.launch
================================================
<launch>
    <arg name="config_path" default = "$(find feature_tracker)/../config/sportsfield/mono_config.yaml" />
    
    <node name="mono_tracker" pkg="feature_tracker" type="mono_tracker" output="screen">
        <param name="config_file" type="string" value="$(arg config_path)" />
    </node>



</launch>


================================================
FILE: feature_tracker/launch/sportsfield/stereo_tracker_sf.launch
================================================
<launch>
    <arg name="config_path_left" default = "$(find feature_tracker)/../config/sportsfield/stereo_left_config.yaml" />
    <arg name="config_path_right" default = "$(find feature_tracker)/../config/sportsfield/stereo_right_config.yaml" />
    
    <node name="stereo_tracker" pkg="feature_tracker" type="stereo_tracker" output="screen">
        <param name="config_file_left" type="string" value="$(arg config_path_left)" />
        <param name="config_file_right" type="string" value="$(arg config_path_right)" />
    </node>


</launch>


================================================
FILE: feature_tracker/msg/MonoFrame.msg
================================================
std_msgs/Header header
MonoMeas[] mono_features


================================================
FILE: feature_tracker/msg/MonoMeas.msg
================================================
uint64 id
float64 u0
float64 v0


================================================
FILE: feature_tracker/msg/StereoFrame.msg
================================================
std_msgs/Header header
StereoMeas[] stereo_features


================================================
FILE: feature_tracker/msg/StereoMeas.msg
================================================
uint64 id
float64 u0
float64 v0
float64 u1
float64 v1


================================================
FILE: feature_tracker/package.xml
================================================
<?xml version="1.0"?>
<package format="2">
  <name>feature_tracker</name>
  <version>0.0.0</version>
  <description>The mono and stereo feature_tracker package</description>

  <maintainer email="lcw18@mails.tsinghua.edu.cn">lcw18</maintainer>


  <!-- One license tag required, multiple allowed, one license per tag -->
  <!-- Commonly used license strings: -->
  <!--   BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
  <license>GPLv3</license>

  <buildtool_depend>catkin</buildtool_depend>


  <build_depend>roscpp</build_depend>
  <build_depend>std_msgs</build_depend>

  <build_export_depend>roscpp</build_export_depend>
  <build_export_depend>std_msgs</build_export_depend>
 
  <exec_depend>nodelet</exec_depend>
  <exec_depend>pluginlib</exec_depend>
  <exec_depend>roscpp</exec_depend>
  <exec_depend>std_msgs</exec_depend>
  <depend>roslib</depend>
  <depend>rosbag</depend>
  <depend>message_filters</depend>
  <depend>sensor_msgs</depend>
  <depend>eigen_conversions</depend>
  <depend>cv_bridge</depend>
  <depend>image_transport</depend>
  <build_depend>message_generation</build_depend>
  <exec_depend>message_runtime</exec_depend>


  <!-- The export tag contains other, unspecified, tags -->
  <export>
    <!-- You can specify that this package is a metapackage here: -->
    <!-- <metapackage/> -->

    <!-- Other tools can request additional information be placed here -->

  </export>
</package>


================================================
FILE: feature_tracker/src/mono_parameters.cpp
================================================
/**   This File is part of Feature Tracker
 *  
 *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,
 *                                     lcw18@mails.tsinghua.edu.cn (valid until 2023))
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *    
 *    A few functions of the mono tracker mimic the realization from GVINS
 *    <https://github.com/HKUST-Aerial-Robotics/GVINS>
 *    GVINS is under GPLv3 License.
 */
 
#include "mono_parameters.h"

namespace feature_tracker
{
    MonoParameters::MonoParameters() : row(480), col(752), focal_length(460), image_topic("/cam1/image_raw"), imu_topic("/imu0"), cam_name("camera"), cam_path("~"), max_cnt(150), min_dist(30), window_size(20), freq(0), f_threshold(1.0), show_track(1), equalize(1)
    {}
    
    void MonoParameters::readParameters(ros::NodeHandle& n)
    {
        std::string config_file;
        config_file = readParam<std::string>(n, "config_file");
        
        cv::FileStorage fs(config_file, cv::FileStorage::READ);
        if (!fs.isOpened())
        {
            ROS_ERROR("ERROR: Wrong path to mono config yaml files!");
            n.shutdown();
        }
        
        cam_path = config_file;
        
        row = fs["image_height"];
        col = fs["image_width"];
        focal_length = 460;
        fs["image_topic"] >> image_topic;
        fs["imu_topic"] >> imu_topic;
        fs["camera_name"] >> cam_name;
        max_cnt = fs["max_cnt"];
        min_dist = fs["min_dist"];
        
        window_size = 20;
        
        freq = fs["freq"];
        if (freq == 0) freq = 100;
        
        f_threshold = fs["F_threshold"];
        show_track = fs["show_track"];
        show_timer = fs["show_timer"];
        timer_warning_thres = fs["timer_warning_thres"];
        equalize = fs["equalize"];
        
        fs.release();
    }
}


================================================
FILE: feature_tracker/src/mono_tracker.cpp
================================================
/**   This File is part of Feature Tracker
 *  
 *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,
 *                                     lcw18@mails.tsinghua.edu.cn (valid until 2023))
 *    
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *    
 *    A few functions of the mono tracker mimic the realization from GVINS
 *    <https://github.com/HKUST-Aerial-Robotics/GVINS>
 *    GVINS is under GPLv3 License.
 */

#include "mono_tracker.h"

#include "Color.h"

namespace feature_tracker
{
    int MonoTracker::n_id = 0;
    
    void MonoTracker::init()
    {
        param.readParameters(nh);
        
        readIntrinsicParameter(param.cam_path);
        
        sub_img = nh.subscribe(param.image_topic, 100, &MonoTracker::img_callback, this);
        pub_mono_features = nh.advertise<feature_tracker::MonoFrame>("mono_feature", 100);
        pub_match = nh.advertise<sensor_msgs::Image>("mono_track", 100);
        
        first_image_flag = true;
        first_image_time = 0.0;
        last_image_time = 0.0;
        
        pub_this_frame = false;
        
        pub_count = 1;
    }
    
    void MonoTracker::img_callback(const sensor_msgs::ImageConstPtr& img_msg)
    {
        TicToc mono_timer;
        
        if (first_image_flag)
        {
            first_image_flag = false;
            first_image_time = img_msg->header.stamp.toSec();
            last_image_time = img_msg->header.stamp.toSec();
            return;
        }
        
        if (img_msg->header.stamp.toSec() - last_image_time > 1.0 || img_msg->header.stamp.toSec() < last_image_time)
        {
            ROS_WARN("[Mono Tracker]: Image discontinue! Mono tracker reset!");
            first_image_flag = true;
            first_image_time = 0.0;
            last_image_time = 0.0;
            pub_count = 1;
            pub_this_frame = false;
            return;
        }
        
        last_image_time = img_msg->header.stamp.toSec();
        
        if (std::round(1.0*pub_count/(last_image_time-first_image_time)) <= param.freq)
        {
            pub_this_frame = true;
            
            if (std::fabs(1.0*pub_count/(last_image_time-first_image_time)-param.freq) < 0.01*param.freq)
            {
                first_image_time = last_image_time;
                pub_count = 0;
            }
        }
        else
        {
            pub_this_frame = false;
        }
        
        
        cv_bridge::CvImageConstPtr ptr;
        if (img_msg->encoding == "8UC1")
        {
            sensor_msgs::Image img;
            img.header = img_msg->header;
            img.height = img_msg->height;
            img.width = img_msg->width;
            img.is_bigendian = img_msg->is_bigendian;
            img.step = img_msg->step;
            img.data = img_msg->data;
            img.encoding = "mono8";
            ptr = cv_bridge::toCvCopy(img, sensor_msgs::image_encodings::MONO8);
        }
        else
            ptr = cv_bridge::toCvCopy(img_msg, sensor_msgs::image_encodings::MONO8);
        
        
        readImage(ptr->image, img_msg->header.stamp.toSec());
        
        updateID();
        
        if (pub_this_frame)
        {
            ++pub_count;
            
            feature_tracker::MonoFrame::Ptr mono_frame_ptr(new feature_tracker::MonoFrame);
            mono_frame_ptr->header = img_msg->header;
            
            for (int i = 0; i < ids.size(); ++i)
            {
                if (track_cnt[i] > 1)
                {
                    feature_tracker::MonoMeas::Ptr mono_feature_ptr(new feature_tracker::MonoMeas);
                    
                    mono_feature_ptr->id = ids[i];
                    mono_feature_ptr->u0 = cur_un_pts[i].x;
                    mono_feature_ptr->v0 = cur_un_pts[i].y;
                    
                    mono_frame_ptr->mono_features.push_back(*mono_feature_ptr);
                }
            }
            
            if (mono_frame_ptr->mono_features.size() > 0)
                pub_mono_features.publish(mono_frame_ptr);
            
            if (param.show_track)
            {
                ptr = cv_bridge::cvtColor(ptr, sensor_msgs::image_encodings::BGR8);
                
                cv::Mat tmp_img = ptr->image;
                
                for (unsigned int j = 0; j < cur_pts.size(); ++j)
                {
                    double len = std::min(1.0, 1.0*track_cnt[j]/param.window_size);
                    cv::circle(tmp_img, cur_pts[j], 2, cv::Scalar(255*(1-len), 0, 255*len), 2);
                }
                pub_match.publish(ptr->toImageMsg());
            }
        }
        
        if (param.show_timer)
        {
            double mono_time = mono_timer.toc();
            
            if (mono_time <= param.timer_warning_thres)
                std::cout << color::setBlue << "[MonoTracker]: Mono tracking processing time = " << mono_time << " (ms) " << color::resetColor << std::endl;
            else
                std::cout << color::setRed << "[MonoTracker]: Mono tracking processing time = " << mono_time << " (ms) " << color::resetColor << std::endl;
        }
        
    }
    
    void MonoTracker::updateID()
    {
        for (unsigned int i = 0; i < ids.size(); ++i)
            if (ids[i] == -1)
                ids[i] = n_id++;
    }
    
    
    void MonoTracker::readImage(const cv::Mat& _img, double _cur_time)
    {
        cv::Mat img;
        cur_time = _cur_time;
        
        if (param.equalize)
        {
            cv::Ptr<cv::CLAHE> clahe = cv::createCLAHE(3.0, cv::Size(8, 8));
            clahe->apply(_img, img);
        }
        else
            img = _img;
            
        if (forw_img.empty())
            prev_img = cur_img = forw_img = img;
        else
            forw_img = img;
            
        forw_pts.clear();
        
        if (cur_pts.size() > 0)
        {
            std::vector<uchar> status;
            std::vector<float> err;
            
            cv::calcOpticalFlowPyrLK(cur_img, forw_img, cur_pts, forw_pts, status, err, cv::Size(21, 21), 3);
            
            for (int i = 0; i < int(forw_pts.size()); ++i)
                if (status[i] && !inBorder(forw_pts[i]))
                    status[i] = 0;
                
            reduceVector<cv::Point2f>(prev_pts, status);
            reduceVector<cv::Point2f>(cur_pts, status);
            reduceVector<cv::Point2f>(forw_pts, status);
            reduceVector<int>(ids, status);
            reduceVector<cv::Point2f>(cur_un_pts, status);
            reduceVector<int>(track_cnt, status);
        }
        
        for (auto& n: track_cnt)
            ++n;
        
        if (pub_this_frame)
        {
            rejectWithF();
            
            setMask();
            
            int n_max_cnt = param.max_cnt - static_cast<int>(forw_pts.size());
            
            if (n_max_cnt > 0)
            {
                if (mask.empty())
                    ROS_WARN("[Mono Tracker]: Mask is empty!");
                if (mask.type() != CV_8UC1)
                    ROS_WARN("[Mono Tracker]: Mask type wrong!");
                if (mask.size() != forw_img.size())
                    ROS_WARN("[Mono Tracker]: Mask size wrong!");
                
                cv::goodFeaturesToTrack(forw_img, n_pts, n_max_cnt, 0.01, param.min_dist, mask);
                
            }
            else
                n_pts.clear();
            
            addPoints();
        }
        
        prev_img = cur_img;
        prev_pts = cur_pts;
        prev_un_pts = cur_un_pts;
        
        cur_img = forw_img;
        cur_pts = forw_pts;
        
        undistortedPoints();
        
        prev_time = cur_time;
    }
    
    void MonoTracker::addPoints()
    {
        for (auto& p: n_pts)
        {
            forw_pts.push_back(p);
            ids.push_back(-1);
            track_cnt.push_back(1);
        }
    }   
    
    void MonoTracker::undistortedPoints()
    {
        cur_un_pts.clear();
        cur_un_pts_map.clear();
        
        for (unsigned int i = 0; i < cur_pts.size(); ++i)
        {
            Eigen::Vector2d a(cur_pts[i].x, cur_pts[i].y);
            Eigen::Vector3d b;
            m_camera->liftProjective(a, b);
            cur_un_pts.push_back(cv::Point2f(b.x()/b.z(), b.y()/b.z()));
            cur_un_pts_map.insert(std::make_pair(ids[i], cv::Point2f(b.x()/b.z(), b.y()/b.z())));
        }
        
        if (!prev_un_pts_map.empty())
        {
            double dt = cur_time - prev_time;
            pts_velocity.clear();
            
            for (unsigned int i = 0; i < cur_un_pts.size(); ++i)
            {
                if (ids[i] != -1)
                {
                    auto it = prev_un_pts_map.find(ids[i]);
                    if (it != prev_un_pts_map.end())
                    {
                        double v_x = (cur_un_pts[i].x - it->second.x) / dt;
                        double v_y = (cur_un_pts[i].y - it->second.y) / dt;
                        pts_velocity.push_back(cv::Point2f(v_x, v_y));
                    }
                    else
                        pts_velocity.push_back(cv::Point2f(0.0, 0.0));
                }
                else
                    pts_velocity.push_back(cv::Point2f(0.0, 0.0));
            }
        }
        else
        {
            for (unsigned int i = 0; i < cur_pts.size(); ++i)
                pts_velocity.push_back(cv::Point2f(0.0, 0.0));
        }
        
        prev_un_pts_map = cur_un_pts_map;
    }
    
    void MonoTracker::setMask()
    {
        mask = cv::Mat(param.row, param.col, CV_8UC1, cv::Scalar(255));
        
        std::vector<std::pair<int, std::pair<cv::Point2f, int>>> cnt_pts_id;
        
        for (unsigned int i = 0; i < forw_pts.size(); ++i)
            cnt_pts_id.push_back(std::make_pair(track_cnt[i], std::make_pair(forw_pts[i], ids[i])));
        
        std::sort(cnt_pts_id.begin(), cnt_pts_id.end(), [](const std::pair<int, std::pair<cv::Point2f, int>>& a, const std::pair<int, std::pair<cv::Point2f, int>>& b){ return a.first > b.first; });
        
        forw_pts.clear();
        ids.clear();
        track_cnt.clear();
        
        for (auto& it: cnt_pts_id)
        {
            if (mask.at<uchar>(it.second.first) == 255)
            {
                forw_pts.push_back(it.second.first);
                ids.push_back(it.second.second);
                track_cnt.push_back(it.first);
                
                cv::circle(mask, it.second.first, param.min_dist, 0, -1);
            }
        }

    }
    
    
    void MonoTracker::rejectWithF()
    {
        if (forw_pts.size() >= 8)
        {
            std::vector<cv::Point2f> un_cur_pts(cur_pts.size()), un_forw_pts(forw_pts.size());
            
            for (unsigned int i = 0; i < cur_pts.size(); ++i)
            {
                Eigen::Vector3d tmp_p;
                m_camera->liftProjective(Eigen::Vector2d(cur_pts[i].x, cur_pts[i].y), tmp_p);
                
                tmp_p.x() = param.focal_length*tmp_p.x()/tmp_p.z() + param.col/2.0;
                tmp_p.y() = param.focal_length*tmp_p.y()/tmp_p.z() + param.row/2.0;
                un_cur_pts[i] = cv::Point2f(tmp_p.x(), tmp_p.y());
                
                m_camera->liftProjective(Eigen::Vector2d(forw_pts[i].x, forw_pts[i].y), tmp_p);
                tmp_p.x() = param.focal_length*tmp_p.x()/tmp_p.z() + param.col/2.0;
                tmp_p.y() = param.focal_length*tmp_p.y()/tmp_p.z() + param.row/2.0;
                un_forw_pts[i] = cv::Point2f(tmp_p.x(), tmp_p.y());
            }
            
            std::vector<uchar> status;
            cv::findFundamentalMat(un_cur_pts, un_forw_pts, cv::FM_RANSAC, param.f_threshold, 0.99, status);
            
            // int size_a = cur_pts.size();
            reduceVector<cv::Point2f>(prev_pts, status);
            reduceVector<cv::Point2f>(cur_pts, status);
            reduceVector<cv::Point2f>(forw_pts, status);
            reduceVector<cv::Point2f>(cur_un_pts, status);
            reduceVector<int>(ids, status);
            reduceVector<int>(track_cnt, status);
            
            // ROS_INFO("FM RANSAC: %d points reduced to -> %lu: %f", size_a, forw_pts.size(), 1.0*forw_pts.size()/size_a);
        }
    }
    
    
    bool Mon
Download .txt
gitextract_o7z2p0ui/

├── .gitignore
├── README.md
├── camera_model/
│   ├── CMakeLists.txt
│   ├── LICENSE
│   ├── include/
│   │   ├── MeiCamera.h
│   │   ├── PinholeCamera.h
│   │   ├── camera.h
│   │   └── camera_factory.h
│   ├── package.xml
│   ├── src/
│   │   ├── MeiCamera.cpp
│   │   ├── PinholeCamera.cpp
│   │   ├── camera.cpp
│   │   └── camera_factory.cpp
│   └── test/
│       └── CMakeLists.txt
├── config/
│   ├── fw_zed2i_f9p/
│   │   ├── ingvio_mono.yaml
│   │   ├── ingvio_stereo.yaml
│   │   ├── mono_config.yaml
│   │   ├── stereo_left_config.yaml
│   │   └── stereo_right_config.yaml
│   └── sportsfield/
│       ├── ingvio_mono.yaml
│       ├── ingvio_stereo.yaml
│       ├── mono_config.yaml
│       ├── stereo_left_config.yaml
│       └── stereo_right_config.yaml
├── feature_tracker/
│   ├── CMakeLists.txt
│   ├── LICENSE
│   ├── include/
│   │   ├── Color.h
│   │   ├── mono_parameters.h
│   │   ├── mono_tracker.h
│   │   ├── random_pair.hpp
│   │   ├── stereo_parameters.h
│   │   ├── stereo_tracker.h
│   │   └── tic_toc.hpp
│   ├── launch/
│   │   └── sportsfield/
│   │       ├── mono_tracker_sf.launch
│   │       └── stereo_tracker_sf.launch
│   ├── msg/
│   │   ├── MonoFrame.msg
│   │   ├── MonoMeas.msg
│   │   ├── StereoFrame.msg
│   │   └── StereoMeas.msg
│   ├── package.xml
│   └── src/
│       ├── mono_parameters.cpp
│       ├── mono_tracker.cpp
│       ├── mono_tracker_node.cpp
│       ├── stereo_parameters.cpp
│       ├── stereo_tracker.cpp
│       └── stereo_tracker_node.cpp
├── gnss_comm/
│   ├── .gitignore
│   ├── CMakeLists.txt
│   ├── LICENSE
│   ├── README.md
│   ├── cmake/
│   │   ├── FindEigen.cmake
│   │   └── FindGlog.cmake
│   ├── docker/
│   │   ├── Dockerfile
│   │   └── Makefile
│   ├── include/
│   │   └── gnss_comm/
│   │       ├── gnss_constant.hpp
│   │       ├── gnss_ros.hpp
│   │       ├── gnss_spp.hpp
│   │       ├── gnss_utility.hpp
│   │       └── rinex_helper.hpp
│   ├── msg/
│   │   ├── GnssBestXYZMsg.msg
│   │   ├── GnssEphemMsg.msg
│   │   ├── GnssGloEphemMsg.msg
│   │   ├── GnssMeasMsg.msg
│   │   ├── GnssObsMsg.msg
│   │   ├── GnssPVTSolnMsg.msg
│   │   ├── GnssSvsMsg.msg
│   │   ├── GnssTimeMsg.msg
│   │   ├── GnssTimePulseInfoMsg.msg
│   │   └── StampedFloat64Array.msg
│   ├── package.xml
│   └── src/
│       ├── gnss_ros.cpp
│       ├── gnss_spp.cpp
│       ├── gnss_utility.cpp
│       └── rinex_helper.cpp
└── ingvio_estimator/
    ├── CMakeLists.txt
    ├── LICENSE
    ├── README.md
    ├── cmake/
    │   ├── FindSuiteSparse.cmake
    │   └── ROS1.cmake
    ├── launch/
    │   ├── ingvio_mono_fw.launch
    │   ├── ingvio_mono_fw_record.launch
    │   ├── ingvio_mono_sf.launch
    │   ├── ingvio_mono_sf_record.launch
    │   ├── ingvio_stereo_fw.launch
    │   ├── ingvio_stereo_fw_record.launch
    │   ├── ingvio_stereo_sf.launch
    │   └── ingvio_stereo_sf_record.launch
    ├── package.xml
    ├── rviz/
    │   ├── ingvio_mono.rviz
    │   └── ingvio_stereo.rviz
    ├── src/
    │   ├── AnchoredLandmark.cpp
    │   ├── AnchoredLandmark.h
    │   ├── AuxGammaFunc.cpp
    │   ├── AuxGammaFunc.h
    │   ├── Color.h
    │   ├── GnssData.cpp
    │   ├── GnssData.h
    │   ├── GnssManager.cpp
    │   ├── GnssManager.h
    │   ├── GnssProcessor.cpp
    │   ├── GnssSync.cpp
    │   ├── GnssSync.h
    │   ├── GnssUpdate.cpp
    │   ├── GnssUpdate.h
    │   ├── GvioAligner.cpp
    │   ├── GvioAligner.h
    │   ├── ImuPropagator.cpp
    │   ├── ImuPropagator.h
    │   ├── IngvioFilter.cpp
    │   ├── IngvioFilter.h
    │   ├── IngvioNode.cpp
    │   ├── IngvioParams.cpp
    │   ├── IngvioParams.h
    │   ├── KeyframeUpdate.cpp
    │   ├── KeyframeUpdate.h
    │   ├── LandmarkUpdate.cpp
    │   ├── LandmarkUpdate.h
    │   ├── MapServer.cpp
    │   ├── MapServer.h
    │   ├── MapServerManager.cpp
    │   ├── MapServerManager.h
    │   ├── PoseState.cpp
    │   ├── PoseState.h
    │   ├── RemoveLostUpdate.cpp
    │   ├── RemoveLostUpdate.h
    │   ├── State.cpp
    │   ├── State.h
    │   ├── StateManager.cpp
    │   ├── StateManager.h
    │   ├── SwMargUpdate.cpp
    │   ├── SwMargUpdate.h
    │   ├── TicToc.h
    │   ├── Triangulator.cpp
    │   ├── Triangulator.h
    │   ├── Update.cpp
    │   ├── Update.h
    │   ├── VecState.cpp
    │   └── VecState.h
    └── test/
        ├── GenerateNoise.cpp
        ├── GenerateNoise.h
        ├── TestMapServer.cpp
        ├── TestPropagator.cpp
        ├── TestStateManager.cpp
        └── TestTriangulator.cpp
Download .txt
SYMBOL INDEX (240 symbols across 83 files)

FILE: camera_model/include/MeiCamera.h
  function xi (line 49) | double xi() const;

FILE: camera_model/include/PinholeCamera.h
  function namespace (line 28) | namespace camera_model

FILE: camera_model/include/camera_factory.h
  function namespace (line 27) | namespace camera_model

FILE: camera_model/src/MeiCamera.cpp
  type camera_model (line 27) | namespace camera_model

FILE: camera_model/src/PinholeCamera.cpp
  type camera_model (line 27) | namespace camera_model

FILE: camera_model/src/camera.cpp
  type camera_model (line 26) | namespace camera_model

FILE: camera_model/src/camera_factory.cpp
  type camera_model (line 30) | namespace camera_model
    function CameraPtr (line 44) | CameraPtr CameraFactory::generateCamera(Camera::ModelType modelType, c...
    function CameraPtr (line 76) | CameraPtr CameraFactory::generateCameraFromYamlFile(const std::string&...

FILE: feature_tracker/include/Color.h
  function namespace (line 24) | namespace color

FILE: feature_tracker/include/mono_parameters.h
  function namespace (line 29) | namespace feature_tracker

FILE: feature_tracker/include/mono_tracker.h
  function namespace (line 55) | namespace feature_tracker

FILE: feature_tracker/include/random_pair.hpp
  type feature_tracker (line 27) | namespace feature_tracker
    class RandomPairGenerator (line 29) | class RandomPairGenerator
      method RandomPairGenerator (line 32) | RandomPairGenerator(unsigned int n = 50) : xa(static_cast<int>(n*(n-...
      method RandomPairGenerator (line 38) | RandomPairGenerator(RandomPairGenerator& obj) = delete;
      method setRandomPairSeed (line 41) | static void setRandomPairSeed()
      method generatePair (line 46) | void generatePair(std::vector<unsigned int>& pair)

FILE: feature_tracker/include/stereo_parameters.h
  function namespace (line 28) | namespace feature_tracker

FILE: feature_tracker/include/stereo_tracker.h
  function namespace (line 54) | namespace feature_tracker

FILE: feature_tracker/include/tic_toc.hpp
  type feature_tracker (line 30) | namespace feature_tracker
    class TicToc (line 32) | class TicToc
      method TicToc (line 35) | TicToc()
      method tic (line 40) | void tic()
      method toc (line 45) | double toc()

FILE: feature_tracker/src/mono_parameters.cpp
  type feature_tracker (line 26) | namespace feature_tracker

FILE: feature_tracker/src/mono_tracker.cpp
  type feature_tracker (line 28) | namespace feature_tracker

FILE: feature_tracker/src/mono_tracker_node.cpp
  function main (line 26) | int main(int argc, char** argv)

FILE: feature_tracker/src/stereo_parameters.cpp
  type feature_tracker (line 23) | namespace feature_tracker

FILE: feature_tracker/src/stereo_tracker.cpp
  type feature_tracker (line 24) | namespace feature_tracker

FILE: feature_tracker/src/stereo_tracker_node.cpp
  function main (line 22) | int main(int argc, char** argv)

FILE: gnss_comm/include/gnss_comm/gnss_constant.hpp
  type gnss_comm (line 44) | namespace gnss_comm
    type gtime_t (line 296) | struct gtime_t
    type EphemBase (line 302) | struct EphemBase
    type GloEphem (line 314) | struct GloEphem : EphemBase
    type Ephem (line 326) | struct Ephem : EphemBase
    type Obs (line 344) | struct Obs                                           /* observation da...
    type TimePulseInfo (line 362) | struct TimePulseInfo                /* time pulse(PPS) information */
    type BestSat (line 370) | struct BestSat
    type BestPos (line 379) | struct BestPos
    type BestVel (line 396) | struct BestVel
    type BestXYZ (line 408) | struct BestXYZ
    type PVTSolution (line 427) | struct PVTSolution
    type PsrPos (line 444) | struct PsrPos
    type PsrVel (line 461) | struct PsrVel
    type SvInfo (line 474) | struct SvInfo
    type TECEpoch (line 486) | struct TECEpoch
    type EphemerideEpoch (line 498) | struct EphemerideEpoch
    type SatState (line 506) | struct SatState

FILE: gnss_comm/include/gnss_comm/gnss_ros.hpp
  type gnss_comm (line 39) | namespace gnss_comm

FILE: gnss_comm/include/gnss_comm/gnss_spp.hpp
  type gnss_comm (line 27) | namespace gnss_comm

FILE: gnss_comm/include/gnss_comm/gnss_utility.hpp
  type gnss_comm (line 49) | namespace gnss_comm

FILE: gnss_comm/include/gnss_comm/rinex_helper.hpp
  type gnss_comm (line 35) | namespace gnss_comm

FILE: gnss_comm/src/gnss_ros.cpp
  type gnss_comm (line 23) | namespace gnss_comm
    function GnssEphemMsg (line 25) | GnssEphemMsg ephem2msg(const EphemPtr &ephem_ptr)
    function EphemPtr (line 72) | EphemPtr msg2ephem(const GnssEphemMsgConstPtr &gnss_ephem_msg)
    function GnssGloEphemMsg (line 111) | GnssGloEphemMsg glo_ephem2msg(const GloEphemPtr &glo_ephem_ptr)
    function GloEphemPtr (line 143) | GloEphemPtr msg2glo_ephem(const GnssGloEphemMsgConstPtr &gnss_glo_ephe...
    function GnssMeasMsg (line 169) | GnssMeasMsg meas2msg(const std::vector<ObsPtr> &meas)
    function msg2meas (line 197) | std::vector<ObsPtr> msg2meas(const GnssMeasMsgConstPtr &gnss_meas_msg)
    function GnssTimePulseInfoMsg (line 223) | GnssTimePulseInfoMsg tp_info2msg(const TimePulseInfoPtr &tp_info)
    function TimePulseInfoPtr (line 232) | TimePulseInfoPtr msg2tp_info(const GnssTimePulseInfoMsgConstPtr &gnss_...
    function GnssBestXYZMsg (line 241) | GnssBestXYZMsg best_xyz2msg(const BestXYZPtr &best_xyz)
    function GnssPVTSolnMsg (line 258) | GnssPVTSolnMsg pvt2msg(const PVTSolutionPtr &pvt_soln)
    function PVTSolutionPtr (line 281) | PVTSolutionPtr msg2pvt(const GnssPVTSolnMsgConstPtr &pvt_msg)
    function GnssSvsMsg (line 304) | GnssSvsMsg svs2msg(const std::vector<SvInfo> &svs)

FILE: gnss_comm/src/gnss_spp.cpp
  type gnss_comm (line 27) | namespace gnss_comm
    function filter_L1 (line 29) | void filter_L1(const std::vector<ObsPtr> &obs, const std::vector<Ephem...
    function sat_states (line 50) | std::vector<SatStatePtr> sat_states(const std::vector<ObsPtr> &obs,
    function psr_res (line 99) | void psr_res(const Eigen::Matrix<double, 7, 1> &rcv_state, const std::...
    function psr_pos (line 148) | Eigen::Matrix<double, 7, 1> psr_pos(const std::vector<ObsPtr> &obs,
    function dopp_res (line 256) | void dopp_res(const Eigen::Matrix<double, 4, 1> &rcv_state, const Eige...
    function dopp_vel (line 284) | Eigen::Matrix<double, 4, 1> dopp_vel(const std::vector<ObsPtr> &obs,

FILE: gnss_comm/src/gnss_utility.cpp
  type gnss_comm (line 34) | namespace gnss_comm
    function sat_no (line 48) | uint32_t sat_no(uint32_t sys, uint32_t prn)
    function satsys (line 74) | uint32_t satsys(uint32_t sat, uint32_t *prn)
    function gtime_t (line 101) | gtime_t epoch2time(const double *ep)
    function time2epoch (line 123) | void time2epoch(gtime_t t, double *ep)
    function gtime_t (line 151) | gtime_t gpst2time(uint32_t week, double tow)
    function time2gpst (line 165) | double time2gpst(gtime_t t, uint32_t *week)
    function gtime_t (line 180) | gtime_t gst2time(int week, double tow)
    function time2gst (line 195) | double time2gst(gtime_t t, int *week)
    function gtime_t (line 210) | gtime_t bdt2time(int week, double tow)
    function time2bdt (line 225) | double time2bdt(gtime_t t, int *week)
    function gtime_t (line 241) | gtime_t gpst2utc(gtime_t t)
    function gtime_t (line 260) | gtime_t utc2gpst(gtime_t t)
    function julian_day (line 271) | double julian_day(std::vector<double> datetime)
    function leap_seconds_from_GPS_epoch (line 287) | uint32_t leap_seconds_from_GPS_epoch(std::vector<double> datetime)
    function time2doy (line 299) | double time2doy(gtime_t time)
    function time_diff (line 308) | double time_diff(gtime_t t1, gtime_t t2)
    function gtime_t (line 313) | gtime_t time_add(gtime_t t, double sec)
    function time2sec (line 322) | double time2sec(gtime_t time)
    function gtime_t (line 327) | gtime_t sec2time(const double sec)
    function geo2ecef (line 335) | Eigen::Vector3d geo2ecef(const Eigen::Vector3d &lla)
    function ecef2geo (line 347) | Eigen::Vector3d ecef2geo(const Eigen::Vector3d &xyz)
    function Kepler (line 390) | double Kepler(const double mk, const double es)
    function eph2svdt (line 437) | double eph2svdt(const gtime_t &curr_time, const EphemPtr ephem_ptr)
    function eph2pos (line 448) | Eigen::Vector3d eph2pos(const gtime_t &curr_time, const EphemPtr ephem...
    function eph2vel (line 533) | Eigen::Vector3d eph2vel(const gtime_t &curr_time, const EphemPtr ephem...
    function deq (line 642) | void deq(const Eigen::Vector3d &pos, const Eigen::Vector3d &vel, const...
    function glo_orbit (line 664) | void glo_orbit(double dt, Eigen::Vector3d &pos, Eigen::Vector3d &vel, ...
    function geph2svdt (line 684) | double geph2svdt(const gtime_t &curr_time, const GloEphemPtr geph_ptr)
    function geph2pos (line 698) | Eigen::Vector3d geph2pos(const gtime_t &curr_time, const GloEphemPtr g...
    function geph2vel (line 716) | Eigen::Vector3d geph2vel(const gtime_t &curr_time, const GloEphemPtr g...
    function ecef2enu (line 733) | Eigen::Vector3d ecef2enu(const Eigen::Vector3d &ref_lla, const Eigen::...
    function geo2rotation (line 745) | Eigen::Matrix3d geo2rotation(const Eigen::Vector3d &ref_geo)
    function ecef2rotation (line 757) | Eigen::Matrix3d ecef2rotation(const Eigen::Vector3d &ref_ecef)
    function sat_azel (line 762) | void sat_azel(const Eigen::Vector3d &rev_pos, const Eigen::Vector3d &s...
    function interpc (line 774) | static double interpc(const double coef[], double lat)
    function mapf (line 782) | static double mapf(double el, double a, double b, double c)
    function nmf (line 797) | static void nmf(gtime_t time, const Eigen::Vector3d rev_lla, const dou...
    function calculate_trop_delay (line 841) | double calculate_trop_delay(gtime_t time, const Eigen::Vector3d &rev_l...
    function calculate_ion_delay (line 865) | double calculate_ion_delay(gtime_t t, const std::vector<double> &ion_p...
    function sat2str (line 901) | std::string sat2str(uint32_t sat_no)
    function L1_freq (line 933) | double L1_freq(const ObsPtr &obs, int *l1_idx)
    function str2sat (line 964) | uint32_t str2sat(const std::string &sat_str)
    function exec (line 990) | std::string exec(const std::string &cmd)

FILE: gnss_comm/src/rinex_helper.cpp
  type gnss_comm (line 23) | namespace gnss_comm
    function str2double (line 29) | static double str2double(const std::string &num_str)
    function GloEphemPtr (line 39) | static GloEphemPtr rinex_line2glo_ephem(const std::vector<std::string>...
    function EphemPtr (line 80) | static EphemPtr rinex_line2ephem(const std::vector<std::string> &ephem...
    function rinex2ephems (line 172) | void rinex2ephems(const std::string &rinex_filepath, std::map<uint32_t...
    function ObsPtr (line 225) | static ObsPtr rinex_line2obs(const std::string rinex_str,
    function rinex2obs (line 297) | void rinex2obs(const std::string &rinex_filepath, std::vector<std::vec...
    function rinex2iono_params (line 352) | void rinex2iono_params(const std::string &rinex_filepath, std::vector<...
    function obs_index (line 397) | int obs_index(const uint32_t sys, const double freq)
    function index_freq (line 422) | double index_freq(const ObsPtr &obs, const int band_idx, int &freq_idx)
    function get_glo_freqo (line 478) | std::map<uint32_t, int> get_glo_freqo(const std::vector<std::vector<Ob...
    function obs2rinex (line 506) | void obs2rinex(const std::string &rinex_filepath,

FILE: ingvio_estimator/src/AnchoredLandmark.cpp
  type ingvio (line 23) | namespace ingvio

FILE: ingvio_estimator/src/AnchoredLandmark.h
  function namespace (line 26) | namespace ingvio

FILE: ingvio_estimator/src/AuxGammaFunc.cpp
  type ingvio (line 26) | namespace ingvio
    function skew (line 28) | Eigen::Matrix3d skew(const Eigen::Vector3d& vec)
    function vee (line 37) | Eigen::Vector3d vee(const Eigen::Matrix3d& mat)
    function GammaFunc (line 46) | Eigen::Matrix3d GammaFunc(const Eigen::Vector3d& vec, int m)
    function Psi1Func (line 115) | Eigen::Matrix3d Psi1Func(const Eigen::Vector3d& tilde_omega,
    function Psi2Func (line 168) | Eigen::Matrix3d Psi2Func(const Eigen::Vector3d& tilde_omega,

FILE: ingvio_estimator/src/AuxGammaFunc.h
  function namespace (line 25) | namespace ingvio

FILE: ingvio_estimator/src/Color.h
  function namespace (line 25) | namespace color

FILE: ingvio_estimator/src/GnssData.cpp
  type ingvio (line 23) | namespace ingvio

FILE: ingvio_estimator/src/GnssData.h
  function namespace (line 25) | namespace ingvio

FILE: ingvio_estimator/src/GnssManager.cpp
  type ingvio (line 23) | namespace ingvio

FILE: ingvio_estimator/src/GnssManager.h
  function namespace (line 29) | namespace ingvio

FILE: ingvio_estimator/src/GnssProcessor.cpp
  type ingvio (line 32) | namespace ingvio

FILE: ingvio_estimator/src/GnssSync.cpp
  type ingvio (line 25) | namespace ingvio

FILE: ingvio_estimator/src/GnssSync.h
  function namespace (line 29) | namespace ingvio
  function class (line 57) | class GnssSync

FILE: ingvio_estimator/src/GnssUpdate.cpp
  type ingvio (line 31) | namespace ingvio

FILE: ingvio_estimator/src/GnssUpdate.h
  function namespace (line 33) | namespace ingvio

FILE: ingvio_estimator/src/GvioAligner.cpp
  type ingvio (line 29) | namespace ingvio

FILE: ingvio_estimator/src/GvioAligner.h
  function namespace (line 33) | namespace ingvio

FILE: ingvio_estimator/src/ImuPropagator.cpp
  type ingvio (line 27) | namespace ingvio

FILE: ingvio_estimator/src/ImuPropagator.h
  function namespace (line 38) | namespace ingvio
  function storeImu (line 127) | void storeImu(const sensor_msgs::Imu::ConstPtr& imu_msg)
  function getInitQuat (line 133) | bool getInitQuat(Eigen::Quaterniond& quat_init) const

FILE: ingvio_estimator/src/IngvioFilter.cpp
  type ingvio (line 48) | namespace ingvio

FILE: ingvio_estimator/src/IngvioFilter.h
  function namespace (line 42) | namespace ingvio

FILE: ingvio_estimator/src/IngvioNode.cpp
  function main (line 25) | int main(int argc, char** argv)

FILE: ingvio_estimator/src/IngvioParams.cpp
  type ingvio (line 25) | namespace ingvio

FILE: ingvio_estimator/src/IngvioParams.h
  function namespace (line 30) | namespace ingvio

FILE: ingvio_estimator/src/KeyframeUpdate.cpp
  type ingvio (line 39) | namespace ingvio

FILE: ingvio_estimator/src/KeyframeUpdate.h
  function namespace (line 28) | namespace ingvio

FILE: ingvio_estimator/src/LandmarkUpdate.cpp
  type ingvio (line 30) | namespace ingvio

FILE: ingvio_estimator/src/LandmarkUpdate.h
  function namespace (line 29) | namespace ingvio

FILE: ingvio_estimator/src/MapServer.cpp
  type ingvio (line 23) | namespace ingvio

FILE: ingvio_estimator/src/MapServer.h
  function namespace (line 31) | namespace ingvio
  function asRightVec (line 47) | struct StereoMeas
  function class (line 69) | class FeatureInfo
  type std (line 134) | typedef std::map<int, std::shared_ptr<FeatureInfo>> MapServer;

FILE: ingvio_estimator/src/MapServerManager.cpp
  type ingvio (line 35) | namespace ingvio

FILE: ingvio_estimator/src/MapServerManager.h
  function namespace (line 31) | namespace ingvio

FILE: ingvio_estimator/src/PoseState.cpp
  type ingvio (line 23) | namespace ingvio

FILE: ingvio_estimator/src/PoseState.h
  function namespace (line 28) | namespace ingvio

FILE: ingvio_estimator/src/RemoveLostUpdate.cpp
  type ingvio (line 38) | namespace ingvio

FILE: ingvio_estimator/src/RemoveLostUpdate.h
  function namespace (line 27) | namespace ingvio

FILE: ingvio_estimator/src/State.cpp
  type ingvio (line 23) | namespace ingvio
    function distance (line 182) | double distance(std::shared_ptr<State> state1, std::shared_ptr<State> ...

FILE: ingvio_estimator/src/State.h
  function class (line 37) | class StateParams
  type GNSSType (line 75) | enum GNSSType {GPS = 0, GLO, GAL, BDS, FS, YOF}
  function nextMargTime (line 83) | double nextMargTime()

FILE: ingvio_estimator/src/StateManager.cpp
  type ingvio (line 25) | namespace ingvio

FILE: ingvio_estimator/src/StateManager.h
  function namespace (line 29) | namespace ingvio

FILE: ingvio_estimator/src/SwMargUpdate.cpp
  type ingvio (line 40) | namespace ingvio

FILE: ingvio_estimator/src/SwMargUpdate.h
  function namespace (line 27) | namespace ingvio

FILE: ingvio_estimator/src/TicToc.h
  function namespace (line 30) | namespace ingvio

FILE: ingvio_estimator/src/Triangulator.cpp
  type ingvio (line 28) | namespace ingvio

FILE: ingvio_estimator/src/Triangulator.h
  function namespace (line 28) | namespace ingvio

FILE: ingvio_estimator/src/Update.cpp
  type ingvio (line 25) | namespace ingvio

FILE: ingvio_estimator/src/Update.h
  function namespace (line 31) | namespace ingvio

FILE: ingvio_estimator/src/VecState.cpp
  type ingvio (line 23) | namespace ingvio

FILE: ingvio_estimator/src/VecState.h
  function namespace (line 26) | namespace ingvio
  function class (line 56) | class Vec3 : public Type
  function class (line 97) | class Scalar : public Type

FILE: ingvio_estimator/test/GenerateNoise.cpp
  type ingvio_test (line 25) | namespace ingvio_test
    function generateGaussRandom (line 27) | double generateGaussRandom(const double& mean, const double& std)
    function isSPD (line 43) | bool isSPD(const Eigen::MatrixXd& cov)

FILE: ingvio_estimator/test/GenerateNoise.h
  function namespace (line 25) | namespace ingvio_test

FILE: ingvio_estimator/test/TestMapServer.cpp
  type ingvio_test (line 42) | namespace ingvio_test
    class TestMapServer (line 44) | class TestMapServer : public virtual ::testing::Test
      method TestMapServer (line 47) | TestMapServer ()
      method generateRandomMonoFrame (line 78) | feature_tracker::MonoFrameConstPtr generateRandomMonoFrame(const std...
      method calcMonoMeas (line 100) | feature_tracker::MonoMeas::Ptr calcMonoMeas(int id, const Eigen::Vec...
      method generateMonoFrame (line 113) | feature_tracker::MonoFrameConstPtr generateMonoFrame(double timestam...
      method generateRandomStereoFrame (line 127) | feature_tracker::StereoFrameConstPtr generateRandomStereoFrame(const...
      method calcStereoMeas (line 151) | feature_tracker::StereoMeas::Ptr calcStereoMeas(int id, const Eigen:...
      method generateStereoFrame (line 169) | feature_tracker::StereoFrameConstPtr generateStereoFrame(double time...
    function TEST_F (line 184) | TEST_F(TestMapServer, collectFeatureAndMarg)
    function TEST_F (line 310) | TEST_F(TestMapServer, featureInfoTriMono)
    function TEST_F (line 397) | TEST_F(TestMapServer, featureInfoTriStereo)
    function TEST_F (line 484) | TEST_F(TestMapServer, changeAnchor)
  function main (line 555) | int main(int argc, char** argv)

FILE: ingvio_estimator/test/TestPropagator.cpp
  type ingvio_test (line 33) | namespace ingvio_test
    class TestPropagator (line 35) | class TestPropagator : public virtual ::testing::Test
      method TestPropagator (line 38) | TestPropagator() : _N(300)
    function TEST_F (line 54) | TEST_F(TestPropagator, initGravity)
    function TEST_F (line 114) | TEST_F(TestPropagator, oneStepProp)
    function TEST_F (line 191) | TEST_F(TestPropagator, propaUntil)
    function TEST_F (line 232) | TEST_F(TestPropagator, propagateAugment)
  function main (line 262) | int main(int argc, char** argv)

FILE: ingvio_estimator/test/TestStateManager.cpp
  type ingvio_test (line 29) | namespace ingvio_test
    function TEST (line 31) | TEST(testState, BasicFuncs)
    function TEST (line 53) | TEST(testState, StateAddMargProp)
    class StateUpdateTest (line 158) | class StateUpdateTest : public virtual ::testing::Test
      method StateUpdateTest (line 161) | StateUpdateTest()
    function TEST_F (line 195) | TEST_F(StateUpdateTest, augmentPose)
    function TEST_F (line 257) | TEST_F(StateUpdateTest, stateBoxPlus)
    function TEST_F (line 478) | TEST_F(StateUpdateTest, stateCovUpdate)
    class AddDelayedTest (line 559) | class AddDelayedTest : public virtual ::testing::Test
      method AddDelayedTest (line 562) | AddDelayedTest()
    function TEST_F (line 594) | TEST_F(AddDelayedTest, addVarInv)
    function TEST_F (line 644) | TEST_F(AddDelayedTest, addVar)
  function main (line 729) | int main(int argc, char** argv)

FILE: ingvio_estimator/test/TestTriangulator.cpp
  type ingvio_test (line 30) | namespace ingvio_test
    class TestTriangulator (line 32) | class TestTriangulator : public virtual ::testing::Test
      method TestTriangulator (line 35) | TestTriangulator() : pf(Eigen::Vector3d(1.0, 2.0, 3.0))
      method calcMonoMeas (line 102) | std::shared_ptr<MonoMeas> calcMonoMeas(const Eigen::Vector3d& pf, co...
      method calcStereoMeas (line 114) | std::shared_ptr<StereoMeas> calcStereoMeas(const Eigen::Vector3d& pf...
    function TEST_F (line 133) | TEST_F(TestTriangulator, monoTriangulate)
    function TEST_F (line 156) | TEST_F(TestTriangulator, stereoTriangulate)
  function main (line 181) | int main(int argc, char** argv)
Condensed preview — 144 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,083K chars).
[
  {
    "path": ".gitignore",
    "chars": 8,
    "preview": "*.kdev4\n"
  },
  {
    "path": "README.md",
    "chars": 6504,
    "preview": "# InGVIO\n\nAn invariant filter for visual-inertial-raw GNSS fusion.\n\n**Paper:** InGVIO: A Consistent Invariant Filter For"
  },
  {
    "path": "camera_model/CMakeLists.txt",
    "chars": 1060,
    "preview": "cmake_minimum_required(VERSION 2.8.3)\nproject(camera_model)\n\nset(CMAKE_BUILD_TYPE \"Release\")\nset(CMAKE_CXX_FLAGS \"${CMAK"
  },
  {
    "path": "camera_model/LICENSE",
    "chars": 35149,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
  },
  {
    "path": "camera_model/include/MeiCamera.h",
    "chars": 6425,
    "preview": "/**   This File is part of Camera Model\r\n *  \r\n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\r\n *             "
  },
  {
    "path": "camera_model/include/PinholeCamera.h",
    "chars": 6062,
    "preview": "/**   This File is part of Camera Model\n *  \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *                "
  },
  {
    "path": "camera_model/include/camera.h",
    "chars": 4295,
    "preview": "/**   This File is part Camera Model\n *  \n *    \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *            "
  },
  {
    "path": "camera_model/include/camera_factory.h",
    "chars": 1586,
    "preview": "/**   This File is part of Camera Model\n *  \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *                "
  },
  {
    "path": "camera_model/package.xml",
    "chars": 1419,
    "preview": "<?xml version=\"1.0\"?>\n<package>\n  <name>camera_model</name>\n  <version>0.0.0</version>\n  <description>The camera_model p"
  },
  {
    "path": "camera_model/src/MeiCamera.cpp",
    "chars": 16852,
    "preview": "/**   This File is part of Camera Model\n *  \n *    \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *         "
  },
  {
    "path": "camera_model/src/PinholeCamera.cpp",
    "chars": 16511,
    "preview": "/**   This File is part of Camera Model\n *  \n *    \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *         "
  },
  {
    "path": "camera_model/src/camera.cpp",
    "chars": 3558,
    "preview": "/**   This File is part of Camera Model\n *  \n *    \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *         "
  },
  {
    "path": "camera_model/src/camera_factory.cpp",
    "chars": 4334,
    "preview": "/**   This File is part of Camera Model\n *  \n *    \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *         "
  },
  {
    "path": "camera_model/test/CMakeLists.txt",
    "chars": 277,
    "preview": "# find_package(GTest REQUIRED)\n# include_directories(${GTEST_INCLUDE_DIRS})\n\n# add each test source file and executable "
  },
  {
    "path": "config/fw_zed2i_f9p/ingvio_mono.yaml",
    "chars": 1586,
    "preview": "%YAML:1.0\n# config for fw_zed2i_f9p\n\nimu_topic: \"/imu0\"\nfeature_topic: \"/mono_tracker/mono_feature\"\n\ncam_nums: 1\ncam_lef"
  },
  {
    "path": "config/fw_zed2i_f9p/ingvio_stereo.yaml",
    "chars": 1695,
    "preview": "%YAML:1.0\n# config for fw_zed2i_f9p\n\nimu_topic: \"/imu0\"\nfeature_topic: \"/stereo_tracker/stereo_feature\"\n\ncam_nums: 2\ncam"
  },
  {
    "path": "config/fw_zed2i_f9p/mono_config.yaml",
    "chars": 1576,
    "preview": "%YAML:1.0\n# config for fw_zed2i_f9p\n\n# common parameters\nimu_topic: \"/imu0\"\nimage_topic: \"/cam0/image_raw\"\n\n# intrinsic\n"
  },
  {
    "path": "config/fw_zed2i_f9p/stereo_left_config.yaml",
    "chars": 1611,
    "preview": "%YAML:1.0\n# config for fw_zed2i_f9p\n\n#topic parameters\nimu_topic: \"/imu0\"\ncam_left_topic: \"/cam0/image_raw\"\ncam_right_to"
  },
  {
    "path": "config/fw_zed2i_f9p/stereo_right_config.yaml",
    "chars": 882,
    "preview": "%YAML:1.0\n# config for fw_zed2i_f9p\n\n# intrinsic\nmodel_type: PINHOLE\ncamera_name: cam1\nimage_width: 1280\nimage_height: 7"
  },
  {
    "path": "config/sportsfield/ingvio_mono.yaml",
    "chars": 1578,
    "preview": "%YAML:1.0\n# config for sportsfield\n\nimu_topic: \"/imu0\"\nfeature_topic: \"/mono_tracker/mono_feature\"\n\ncam_nums: 1\ncam_left"
  },
  {
    "path": "config/sportsfield/ingvio_stereo.yaml",
    "chars": 1684,
    "preview": "%YAML:1.0\n# config for sportsfield\n\nimu_topic: \"/imu0\"\nfeature_topic: \"/stereo_tracker/stereo_feature\"\n\ncam_nums: 2\ncam_"
  },
  {
    "path": "config/sportsfield/mono_config.yaml",
    "chars": 1614,
    "preview": "%YAML:1.0\n# config for sportsfield\n\n# common parameters\nimu_topic: \"/imu0\"\nimage_topic: \"/cam1/image_raw\"\n\n# camera cali"
  },
  {
    "path": "config/sportsfield/stereo_left_config.yaml",
    "chars": 1642,
    "preview": "%YAML:1.0\n# config for sportsfield\n\n#topic parameters\nimu_topic: \"/imu0\"\ncam_left_topic: \"/cam1/image_raw\"\ncam_right_top"
  },
  {
    "path": "config/sportsfield/stereo_right_config.yaml",
    "chars": 916,
    "preview": "%YAML:1.0\n# config for sportsfield\n\n# intrinsic\nmodel_type: MEI\ncamera_name: cam0\nimage_width: 752\nimage_height: 480\nmir"
  },
  {
    "path": "feature_tracker/CMakeLists.txt",
    "chars": 1125,
    "preview": "cmake_minimum_required(VERSION 2.8.3)\nproject(feature_tracker)\n\nset(CMAKE_BUILD_TYPE \"Release\")\nset(CMAKE_CXX_FLAGS \"-st"
  },
  {
    "path": "feature_tracker/LICENSE",
    "chars": 35149,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
  },
  {
    "path": "feature_tracker/include/Color.h",
    "chars": 1624,
    "preview": "/**   This File is part of Feature Tracker\n *  \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *             "
  },
  {
    "path": "feature_tracker/include/mono_parameters.h",
    "chars": 2251,
    "preview": "/**   This File is part of Feature Tracker\n *  \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *             "
  },
  {
    "path": "feature_tracker/include/mono_tracker.h",
    "chars": 3834,
    "preview": "/**   This File is part of Feature Tracker\n *  \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *             "
  },
  {
    "path": "feature_tracker/include/random_pair.hpp",
    "chars": 2406,
    "preview": "/**   This File is part of Feature Tracker\n *  \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *             "
  },
  {
    "path": "feature_tracker/include/stereo_parameters.h",
    "chars": 2410,
    "preview": "/**   This File is part of Feature Tracker\n *  \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *             "
  },
  {
    "path": "feature_tracker/include/stereo_tracker.h",
    "chars": 6813,
    "preview": "/**   This File is part of Feature Tracker\n *  \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *             "
  },
  {
    "path": "feature_tracker/include/tic_toc.hpp",
    "chars": 1683,
    "preview": "/**   This File is part of Feature Tracker\n *  \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *             "
  },
  {
    "path": "feature_tracker/launch/sportsfield/mono_tracker_sf.launch",
    "chars": 312,
    "preview": "<launch>\n    <arg name=\"config_path\" default = \"$(find feature_tracker)/../config/sportsfield/mono_config.yaml\" />\n    \n"
  },
  {
    "path": "feature_tracker/launch/sportsfield/stereo_tracker_sf.launch",
    "chars": 547,
    "preview": "<launch>\n    <arg name=\"config_path_left\" default = \"$(find feature_tracker)/../config/sportsfield/stereo_left_config.ya"
  },
  {
    "path": "feature_tracker/msg/MonoFrame.msg",
    "chars": 48,
    "preview": "std_msgs/Header header\nMonoMeas[] mono_features\n"
  },
  {
    "path": "feature_tracker/msg/MonoMeas.msg",
    "chars": 32,
    "preview": "uint64 id\nfloat64 u0\nfloat64 v0\n"
  },
  {
    "path": "feature_tracker/msg/StereoFrame.msg",
    "chars": 52,
    "preview": "std_msgs/Header header\nStereoMeas[] stereo_features\n"
  },
  {
    "path": "feature_tracker/msg/StereoMeas.msg",
    "chars": 54,
    "preview": "uint64 id\nfloat64 u0\nfloat64 v0\nfloat64 u1\nfloat64 v1\n"
  },
  {
    "path": "feature_tracker/package.xml",
    "chars": 1439,
    "preview": "<?xml version=\"1.0\"?>\n<package format=\"2\">\n  <name>feature_tracker</name>\n  <version>0.0.0</version>\n  <description>The "
  },
  {
    "path": "feature_tracker/src/mono_parameters.cpp",
    "chars": 2475,
    "preview": "/**   This File is part of Feature Tracker\n *  \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *             "
  },
  {
    "path": "feature_tracker/src/mono_tracker.cpp",
    "chars": 13585,
    "preview": "/**   This File is part of Feature Tracker\n *  \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *             "
  },
  {
    "path": "feature_tracker/src/mono_tracker_node.cpp",
    "chars": 1465,
    "preview": "/**   This File is part of Feature Tracker\n *  \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *             "
  },
  {
    "path": "feature_tracker/src/stereo_parameters.cpp",
    "chars": 4006,
    "preview": "/**   This File is part of Feature Tracker\n *  \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *             "
  },
  {
    "path": "feature_tracker/src/stereo_tracker.cpp",
    "chars": 24846,
    "preview": "/**   This File is part of Feature Tracker\n *  \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *             "
  },
  {
    "path": "feature_tracker/src/stereo_tracker_node.cpp",
    "chars": 1291,
    "preview": "/**   This File is part of Feature Tracker\n *  \n *    Copyright (C) 2022  Changwu Liu (cwliu529@163.com,\n *             "
  },
  {
    "path": "gnss_comm/.gitignore",
    "chars": 8,
    "preview": ".vscode/"
  },
  {
    "path": "gnss_comm/CMakeLists.txt",
    "chars": 1467,
    "preview": "cmake_minimum_required(VERSION 2.8.3)\nproject(gnss_comm)\n\nset(CMAKE_BUILD_TYPE \"release\")\nset(CMAKE_CXX_FLAGS \"-std=c++1"
  },
  {
    "path": "gnss_comm/LICENSE",
    "chars": 35149,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
  },
  {
    "path": "gnss_comm/README.md",
    "chars": 2443,
    "preview": "# gnss_comm\n\n**Authors/Maintainers:** CAO Shaozu (shaozu.cao AT gmail.com)\n\nThe *gnss_comm* package contains basic defin"
  },
  {
    "path": "gnss_comm/cmake/FindEigen.cmake",
    "chars": 7887,
    "preview": "# Ceres Solver - A fast non-linear least squares minimizer\n# Copyright 2015 Google Inc. All rights reserved.\n# http://ce"
  },
  {
    "path": "gnss_comm/cmake/FindGlog.cmake",
    "chars": 17466,
    "preview": "# Ceres Solver - A fast non-linear least squares minimizer\n# Copyright 2015 Google Inc. All rights reserved.\n# http://ce"
  },
  {
    "path": "gnss_comm/docker/Dockerfile",
    "chars": 1150,
    "preview": "FROM ros:kinetic-perception\n\nENV EIGEN_VERSION=\"3.3.3\"\nENV CATKIN_WS=/root/catkin_ws\n\n      # set up thread number for b"
  },
  {
    "path": "gnss_comm/docker/Makefile",
    "chars": 277,
    "preview": "all: help\n\nhelp:\n\t@echo \"\"\n\t@echo \"-- Help Menu\"\n\t@echo \"\"\n\t@echo \"   1. make build              - build all images\"\n\t@e"
  },
  {
    "path": "gnss_comm/include/gnss_comm/gnss_constant.hpp",
    "chars": 23331,
    "preview": "/**\n* This file is part of gnss_comm.\n*\n* Copyright (C) 2021 Aerial Robotics Group, Hong Kong University of Science and "
  },
  {
    "path": "gnss_comm/include/gnss_comm/gnss_ros.hpp",
    "chars": 5782,
    "preview": "/**\n* This file is part of gnss_comm.\n*\n* Copyright (C) 2021 Aerial Robotics Group, Hong Kong University of Science and "
  },
  {
    "path": "gnss_comm/include/gnss_comm/gnss_spp.hpp",
    "chars": 5778,
    "preview": "/**\n* This file is part of gnss_comm.\n*\n* Copyright (C) 2021 Aerial Robotics Group, Hong Kong University of Science and "
  },
  {
    "path": "gnss_comm/include/gnss_comm/gnss_utility.hpp",
    "chars": 19488,
    "preview": "/**\n* This file is part of gnss_comm.\n*\n* Copyright (C) 2021 Aerial Robotics Group, Hong Kong University of Science and "
  },
  {
    "path": "gnss_comm/include/gnss_comm/rinex_helper.hpp",
    "chars": 3356,
    "preview": "/**\n* This file is part of gnss_comm.\n*\n* Copyright (C) 2021 Aerial Robotics Group, Hong Kong University of Science and "
  },
  {
    "path": "gnss_comm/msg/GnssBestXYZMsg.msg",
    "chars": 99,
    "preview": "Header header\nfloat64[] pos\nfloat64[] pos_sigma\nfloat64[] vel\nfloat64[] vel_sigma\nuint32    num_svs"
  },
  {
    "path": "gnss_comm/msg/GnssEphemMsg.msg",
    "chars": 487,
    "preview": "# This message contains GPS, Galileo and BeiDou ephemeris data\n\nuint32 sat\nGnssTimeMsg ttr\nGnssTimeMsg toe\nGnssTimeMsg t"
  },
  {
    "path": "gnss_comm/msg/GnssGloEphemMsg.msg",
    "chars": 326,
    "preview": "# This message contains GLONASS ephemeris data\n\nuint32 sat\nGnssTimeMsg ttr\nGnssTimeMsg toe\nint32  freqo\nuint32 iode\nuint"
  },
  {
    "path": "gnss_comm/msg/GnssMeasMsg.msg",
    "chars": 90,
    "preview": "# This message contains one-epoch measurements from multiple satellites\n\nGnssObsMsg[] meas"
  },
  {
    "path": "gnss_comm/msg/GnssObsMsg.msg",
    "chars": 861,
    "preview": "# This message contains one-epoch measurements from one single satellite\n\nGnssTimeMsg time    # measurement time\nuint32 "
  },
  {
    "path": "gnss_comm/msg/GnssPVTSolnMsg.msg",
    "chars": 1102,
    "preview": "# This message contains information of UBX-NAV-PVT message. \n# reference: [1]. UBX-18010854-R08, page 132\n\nGnssTimeMsg t"
  },
  {
    "path": "gnss_comm/msg/GnssSvsMsg.msg",
    "chars": 133,
    "preview": "Header header\nuint32[]    sat\nuint32[]    freqo\nbool[]      health\nfloat64[]   elev_degree\nfloat64[]   az_degree\nuint32["
  },
  {
    "path": "gnss_comm/msg/GnssTimeMsg.msg",
    "chars": 132,
    "preview": "# This message contains GNSS time expressed in the form of \n# GNSS week number and time of week(in seconds)\n\nuint32 week"
  },
  {
    "path": "gnss_comm/msg/GnssTimePulseInfoMsg.msg",
    "chars": 305,
    "preview": "# This message contains information of UBX-TIM-TP message. \n# reference: [1]. UBX-18010854-R08, page 156\n\nGnssTimeMsg ti"
  },
  {
    "path": "gnss_comm/msg/StampedFloat64Array.msg",
    "chars": 69,
    "preview": "# A list of float values with timestamp\n\nHeader header\nfloat64[] data"
  },
  {
    "path": "gnss_comm/package.xml",
    "chars": 752,
    "preview": "<?xml version=\"1.0\"?>\n<package>\n  <name>gnss_comm</name>\n  <version>1.0.0</version>\n  <description>Definitions and utili"
  },
  {
    "path": "gnss_comm/src/gnss_ros.cpp",
    "chars": 12846,
    "preview": "/**\n* This file is part of gnss_comm.\n*\n* Copyright (C) 2021 Aerial Robotics Group, Hong Kong University of Science and "
  },
  {
    "path": "gnss_comm/src/gnss_spp.cpp",
    "chars": 16178,
    "preview": "/**\n* This file is part of gnss_comm.\n*\n* Copyright (C) 2021 Aerial Robotics Group, Hong Kong University of Science and "
  },
  {
    "path": "gnss_comm/src/gnss_utility.cpp",
    "chars": 42122,
    "preview": "/**\n* This file is part of gnss_comm.\n*\n* Copyright (C) 2021 Aerial Robotics Group, Hong Kong University of Science and "
  },
  {
    "path": "gnss_comm/src/rinex_helper.cpp",
    "chars": 28313,
    "preview": "/**\n* This file is part of gnss_comm.\n*\n* Copyright (C) 2021 Aerial Robotics Group, Hong Kong University of Science and "
  },
  {
    "path": "ingvio_estimator/CMakeLists.txt",
    "chars": 1173,
    "preview": "cmake_minimum_required(VERSION 3.16)\nproject(ingvio_estimator)\n\nset(CMAKE_CXX_STANDARD 14)\nset(CMAKE_CXX_STANDARD_REQUIR"
  },
  {
    "path": "ingvio_estimator/LICENSE",
    "chars": 35149,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
  },
  {
    "path": "ingvio_estimator/README.md",
    "chars": 6371,
    "preview": "# InGVIO\n\nAn invariant filter for visual-inertial-raw GNSS fusion.\n\n**Paper:** InGVIO: A Consistent Invariant Filter For"
  },
  {
    "path": "ingvio_estimator/cmake/FindSuiteSparse.cmake",
    "chars": 21946,
    "preview": "# Ceres Solver - A fast non-linear least squares minimizer\n# Copyright 2015 Google Inc. All rights reserved.\n# http://ce"
  },
  {
    "path": "ingvio_estimator/cmake/ROS1.cmake",
    "chars": 4548,
    "preview": "cmake_minimum_required(VERSION 3.16)\n\nfind_package(catkin QUIET COMPONENTS\n    roscpp\n    roslib\n    std_msgs\n    messag"
  },
  {
    "path": "ingvio_estimator/launch/ingvio_mono_fw.launch",
    "chars": 747,
    "preview": "<launch>\n    <arg name=\"cam_config_path\" default = \"$(find feature_tracker)/../config/fw_zed2i_f9p/mono_config.yaml\" />\n"
  },
  {
    "path": "ingvio_estimator/launch/ingvio_mono_fw_record.launch",
    "chars": 656,
    "preview": "<launch>\n    <include file = \"$(find ingvio_estimator)/launch/ingvio_mono_fw.launch\" />\n    \n    <arg name = \"is_record_"
  },
  {
    "path": "ingvio_estimator/launch/ingvio_mono_sf.launch",
    "chars": 745,
    "preview": "<launch>\n    <arg name=\"cam_config_path\" default = \"$(find feature_tracker)/../config/sportsfield/mono_config.yaml\" />\n "
  },
  {
    "path": "ingvio_estimator/launch/ingvio_mono_sf_record.launch",
    "chars": 653,
    "preview": "<launch>\n    <include file = \"$(find ingvio_estimator)/launch/ingvio_mono_sf.launch\" />\n    \n    <arg name = \"is_record_"
  },
  {
    "path": "ingvio_estimator/launch/ingvio_stereo_fw.launch",
    "chars": 996,
    "preview": "<launch>\n    <arg name=\"cam_config_path_left\" default = \"$(find feature_tracker)/../config/fw_zed2i_f9p/stereo_left_conf"
  },
  {
    "path": "ingvio_estimator/launch/ingvio_stereo_fw_record.launch",
    "chars": 659,
    "preview": "<launch>\n    <include file = \"$(find ingvio_estimator)/launch/ingvio_stereo_fw.launch\" />\n    \n    <arg name = \"is_recor"
  },
  {
    "path": "ingvio_estimator/launch/ingvio_stereo_sf.launch",
    "chars": 993,
    "preview": "<launch>\n    <arg name=\"cam_config_path_left\" default = \"$(find feature_tracker)/../config/sportsfield/stereo_left_confi"
  },
  {
    "path": "ingvio_estimator/launch/ingvio_stereo_sf_record.launch",
    "chars": 656,
    "preview": "<launch>\n    <include file = \"$(find ingvio_estimator)/launch/ingvio_stereo_sf.launch\" />\n    \n    <arg name = \"is_recor"
  },
  {
    "path": "ingvio_estimator/package.xml",
    "chars": 1407,
    "preview": "<?xml version=\"1.0\"?>\n<package format=\"3\">\n    \n    <name>ingvio_estimator</name>\n    <version>1.0.0</version>\n    <desc"
  },
  {
    "path": "ingvio_estimator/rviz/ingvio_mono.rviz",
    "chars": 7335,
    "preview": "Panels:\n  - Class: rviz/Displays\n    Help Height: 0\n    Name: Displays\n    Property Tree Widget:\n      Expanded:\n       "
  },
  {
    "path": "ingvio_estimator/rviz/ingvio_stereo.rviz",
    "chars": 7349,
    "preview": "Panels:\n  - Class: rviz/Displays\n    Help Height: 78\n    Name: Displays\n    Property Tree Widget:\n      Expanded:\n      "
  },
  {
    "path": "ingvio_estimator/src/AnchoredLandmark.cpp",
    "chars": 8629,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n*    inertial-raw GNSS navigation. \n*    \n"
  },
  {
    "path": "ingvio_estimator/src/AnchoredLandmark.h",
    "chars": 3565,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/AuxGammaFunc.cpp",
    "chars": 7126,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/AuxGammaFunc.h",
    "chars": 1619,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/Color.h",
    "chars": 1698,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/GnssData.cpp",
    "chars": 1475,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/GnssData.h",
    "chars": 1693,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/GnssManager.cpp",
    "chars": 5258,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/GnssManager.h",
    "chars": 2319,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/GnssProcessor.cpp",
    "chars": 8161,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/GnssSync.cpp",
    "chars": 7944,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/GnssSync.h",
    "chars": 3956,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/GnssUpdate.cpp",
    "chars": 21433,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/GnssUpdate.h",
    "chars": 3943,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/GvioAligner.cpp",
    "chars": 13621,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/GvioAligner.h",
    "chars": 3656,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/ImuPropagator.cpp",
    "chars": 13741,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/ImuPropagator.h",
    "chars": 5930,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/IngvioFilter.cpp",
    "chars": 18977,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/IngvioFilter.h",
    "chars": 4306,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/IngvioNode.cpp",
    "chars": 1379,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/IngvioParams.cpp",
    "chars": 12408,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/IngvioParams.h",
    "chars": 4338,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/KeyframeUpdate.cpp",
    "chars": 29024,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/KeyframeUpdate.h",
    "chars": 4404,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/LandmarkUpdate.cpp",
    "chars": 41164,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/LandmarkUpdate.h",
    "chars": 6028,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/MapServer.cpp",
    "chars": 2645,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/MapServer.h",
    "chars": 4039,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/MapServerManager.cpp",
    "chars": 18767,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/MapServerManager.h",
    "chars": 5671,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/PoseState.cpp",
    "chars": 7422,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/PoseState.h",
    "chars": 6914,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/RemoveLostUpdate.cpp",
    "chars": 21535,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/RemoveLostUpdate.h",
    "chars": 2963,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/State.cpp",
    "chars": 9224,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/State.h",
    "chars": 4410,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/StateManager.cpp",
    "chars": 29542,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/StateManager.h",
    "chars": 5355,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/SwMargUpdate.cpp",
    "chars": 28840,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/SwMargUpdate.h",
    "chars": 4707,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/TicToc.h",
    "chars": 1715,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/Triangulator.cpp",
    "chars": 13360,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/Triangulator.h",
    "chars": 4921,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/Update.cpp",
    "chars": 6039,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/Update.h",
    "chars": 3700,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/VecState.cpp",
    "chars": 1911,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/src/VecState.h",
    "chars": 3546,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/test/GenerateNoise.cpp",
    "chars": 1842,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/test/GenerateNoise.h",
    "chars": 1160,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/test/TestMapServer.cpp",
    "chars": 23428,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/test/TestPropagator.cpp",
    "chars": 8621,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/test/TestStateManager.cpp",
    "chars": 30456,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  },
  {
    "path": "ingvio_estimator/test/TestTriangulator.cpp",
    "chars": 8217,
    "preview": "/**  This File is part of InGVIO, an invariant filter for mono/stereo visual-\n *    inertial-raw GNSS navigation. \n *   "
  }
]

About this extraction

This page contains the full source code of the ChangwuLiu/InGVIO GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 144 files (1019.3 KB), approximately 271.3k tokens, and a symbol index with 240 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!