Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .github/scripts/python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ function build()
{
export CMAKE_GENERATOR=Ninja
BUILD_PYBIND="ON"

# Add Boost hints on Windows
BOOST_CMAKE_ARGS=""
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" || "$OSTYPE" == "cygwin" ]]; then
if [ -n "${BOOST_ROOT}" ]; then
BOOST_ROOT_UNIX=$(echo "$BOOST_ROOT" | sed 's/\\/\//g')
BOOST_CMAKE_ARGS="-DBOOST_ROOT=${BOOST_ROOT_UNIX} -DBOOST_INCLUDEDIR=${BOOST_ROOT_UNIX}/include -DBOOST_LIBRARYDIR=${BOOST_ROOT_UNIX}/lib"
fi
fi

cmake $GITHUB_WORKSPACE \
-B build \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
Expand All @@ -58,9 +68,11 @@ function build()
-DGTSAM_UNSTABLE_BUILD_PYTHON=${GTSAM_BUILD_UNSTABLE:-ON} \
-DGTSAM_PYTHON_VERSION=$PYTHON_VERSION \
-DPYTHON_EXECUTABLE:FILEPATH=$(which $PYTHON) \
-DGTSAM_USE_BOOST_FEATURES=ON \
-DGTSAM_ENABLE_BOOST_SERIALIZATION=ON \
-DGTSAM_ALLOW_DEPRECATED_SINCE_V43=OFF \
-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/gtsam_install

-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/gtsam_install \
$BOOST_CMAKE_ARGS

# Set to 2 cores so that Actions does not error out during resource provisioning.
cmake --build build -j2
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/build-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ name: Python CI
# Since this is a required check, specify paths-ignore in the check-paths job
# instead of under 'pull_request:'. Otherwise, the check is still required but
# never runs, and a maintainer must bypass the check in order to merge the PR.
on: [pull_request]
on:
push:
branches:
- develop
paths-ignore:
- '**.md'
- '**.ipynb'
- 'myst.yml'
pull_request:
paths-ignore:
- '**.md'
- '**.ipynb'
- 'myst.yml'

# Every time you make a push to your PR, it cancel immediately the previous checks,
# and start a new one. The other runner will be available more quickly to your PR.
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,20 @@ jobs:
- name: Configuration
shell: bash
run: |
export CMAKE_GENERATOR=Ninja
export CMAKE_GENERATOR=Ninja
# Convert Windows backslashes to forward slashes for CMake
BOOST_ROOT_UNIX=$(echo "$BOOST_ROOT" | sed 's/\\/\//g')
cmake -E remove_directory build
if [ "${{ matrix.build_type }}" = "Release" ]; then
cmake -B build \
-S . \
-DGTSAM_BUILD_EXAMPLES_ALWAYS=OFF \
-DGTSAM_ALLOW_DEPRECATED_SINCE_V43=OFF \
-DBOOST_ROOT="${BOOST_ROOT}" \
-DGTSAM_USE_BOOST_FEATURES=ON \
-DGTSAM_ENABLE_BOOST_SERIALIZATION=ON \
-DBOOST_INCLUDEDIR="${BOOST_ROOT}\\boost\\include" \
-DBOOST_LIBRARYDIR="${BOOST_ROOT}\\lib"
-DBOOST_ROOT="${BOOST_ROOT_UNIX}" \
-DBOOST_INCLUDEDIR="${BOOST_ROOT_UNIX}/include" \
-DBOOST_LIBRARYDIR="${BOOST_ROOT_UNIX}/lib"
else
cmake -B build \
-S . \
Expand Down
35 changes: 24 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ mapping (SAM) in robotics and vision, using Factor Graphs and Bayes
Networks as the underlying computing paradigm rather than sparse
matrices.

The current support matrix is:

| Platform | Compiler | Build Status |
| :----------------: | :-------: | :------------------------------------------------------------------------------: |
| Ubuntu 22.04/24.04 | gcc/clang | ![Linux CI](https://github.com/borglab/gtsam/workflows/Linux%20CI/badge.svg) |
| macOS | clang | ![macOS CI](https://github.com/borglab/gtsam/workflows/macOS%20CI/badge.svg) |
| Windows | MSVC | ![Windows CI](https://github.com/borglab/gtsam/workflows/Windows%20CI/badge.svg) |

<!-- Main CI Badges (develop branch) -->
| CI Status | Platform | Compiler |
|:----------|:---------|:---------|
| [![Python CI](https://github.com/borglab/gtsam/actions/workflows/build-python.yml/badge.svg?branch=develop)](https://github.com/borglab/gtsam/actions/workflows/build-python.yml?query=branch%3Adevelop) | Ubuntu 22.04, MacOS 13-14, Windows | gcc/clang,MSVC |
| [![vcpkg](https://github.com/borglab/gtsam/actions/workflows/vcpkg.yml/badge.svg?branch=develop)](https://github.com/borglab/gtsam/actions/workflows/vcpkg.yml?query=branch%3Adevelop) | Latest Windows/Ubuntu/Mac | - |
| [![Build Wheels for Develop](https://github.com/borglab/gtsam/actions/workflows/build-cibw.yml/badge.svg?branch=develop)](https://github.com/borglab/gtsam/actions/workflows/build-cibw.yml?query=branch%3Adevelop) | See [pypi files](https://pypi.org/project/gtsam-develop/#files); no Windows| - |

On top of the C++ library, GTSAM includes [wrappers for MATLAB & Python](#wrappers).

Expand All @@ -34,15 +33,29 @@ In the root library folder execute:
mkdir build
cd build
cmake ..
make check (optional, runs unit tests)
make check # optional, runs all unit tests
make install
```

Prerequisites:

- [Boost](http://www.boost.org/users/download/) >= 1.65 (Ubuntu: `sudo apt-get install libboost-all-dev`)
- [CMake](http://www.cmake.org/cmake/resources/software.html) >= 3.0 (Ubuntu: `sudo apt-get install cmake`)
- A modern compiler, i.e., at least gcc 4.7.3 on Linux.
- A modern compiler:
- Mac: at least xcode-14.2
- Linux: at least clang-11 or gcc-9
- Windows: at least msvc-14.2
- [CMake](http://www.cmake.org/cmake/resources/software.html) >= 3.0
- Ubuntu: `sudo apt-get install cmake`

Optional Boost prerequisite:

Boost is now *optional*. Two cmake flags govern its behavior:
- `GTSAM_USE_BOOST_FEATURES` = `ON|OFF`: some of our timers and concept checking in the tests still depend on boost.
- `GTSAM_ENABLE_BOOST_SERIALIZATION` = `ON|OFF`: serialization of factor graphs, factors, etc still is done using boost

If one or both of these flags are `ON`, you need to install [Boost](http://www.boost.org/users/download/) >= 1.70
- Mac: `brew install boost`
- Ubuntu: `sudo apt-get install libboost-all-dev`
- Windows: We highly recommend using the [vcpkg](https://github.com/microsoft/vcpkg) package manager. For other installation methods or troubleshooting, please see the guidance in the [cmake/HandleBoost.cmake](cmake/HandleBoost.cmake) script.

Optional prerequisites - used automatically if findable by CMake:

Expand Down
94 changes: 63 additions & 31 deletions cmake/HandleBoost.cmake
Original file line number Diff line number Diff line change
@@ -1,56 +1,88 @@
###############################################################################
# Find boost

# To change the path for boost, you will need to set:
# BOOST_ROOT: path to install prefix for boost
# Boost_NO_SYSTEM_PATHS: set to true to keep the find script from ignoring BOOST_ROOT
################################################################################
# Find and configure the Boost libraries.
#
# To customize the Boost installation path, you can set the following variables
# when running CMake:
# - BOOST_ROOT: Path to the Boost installation prefix.
# - BOOST_INCLUDEDIR: Path to the Boost include directory.
# - BOOST_LIBRARYDIR: Path to the Boost library directory.
#
# These hints are particularly important for manual installations on Windows.
################################################################################

if(MSVC)
# By default, boost only builds static libraries on windows
set(Boost_USE_STATIC_LIBS ON) # only find static libs
# If we ever reset above on windows and, ...
# If we use Boost shared libs, disable auto linking.
# Some libraries, at least Boost Program Options, rely on this to export DLL symbols.
# By default, Boost pre-compiled binaries for Windows are static libraries.
set(Boost_USE_STATIC_LIBS ON)
if(NOT Boost_USE_STATIC_LIBS)
list_append_cache(GTSAM_COMPILE_DEFINITIONS_PUBLIC BOOST_ALL_NO_LIB BOOST_ALL_DYN_LINK)
endif()
# Virtual memory range for PCH exceeded on VS2015
if(MSVC_VERSION LESS 1910) # older than VS2017
list_append_cache(GTSAM_COMPILE_OPTIONS_PRIVATE -Zm295)
endif()
endif()

# --- GUIDANCE FOR LOCAL WINDOWS DEVELOPMENT ---
#
# If you enable Boost features on Windows, there are two primary ways to provide
# the Boost libraries:
#
# 1. RECOMMENDED: Use a package manager like vcpkg.
# - Vcpkg (https://github.com/microsoft/vcpkg) handles the download, build,
# and integration of Boost. It provides modern CMake config files and works
# seamlessly with this script without any special configuration.
#
# 2. ALTERNATIVE: Manual Installation (e.g., pre-compiled binaries).
# - If you download pre-compiled binaries, you MUST provide hints to CMake so
# it can find your installation. At a minimum, set BOOST_ROOT, e.g.:
# cmake .. -DBOOST_ROOT=C:/local/boost_1_87_0
#
################################################################################

# Store these in variables so they are automatically replicated in GTSAMConfig.cmake and such.
set(BOOST_FIND_MINIMUM_VERSION 1.65)
set(BOOST_FIND_MINIMUM_COMPONENTS serialization system filesystem thread program_options date_time timer chrono regex)
# Set minimum required Boost version and components.
# NOTE: "system" is intentionally omitted. It is a transitive dependency of other
# components (like filesystem) and will be found automatically. Explicitly
# requesting it can cause issues with modern header-only versions of Boost.
set(BOOST_FIND_MINIMUM_VERSION 1.70)
set(BOOST_FIND_MINIMUM_COMPONENTS serialization filesystem thread program_options date_time timer chrono regex)

find_package(Boost ${BOOST_FIND_MINIMUM_VERSION} COMPONENTS ${BOOST_FIND_MINIMUM_COMPONENTS} REQUIRED)
# Find the Boost package. On systems with modern installations (vcpkg, Homebrew),
# this will use CMake's "Config mode". With manual installations (especially on
# Windows), providing the hints above will trigger the legacy "Module mode".
find_package(Boost ${BOOST_FIND_MINIMUM_VERSION} REQUIRED
COMPONENTS ${BOOST_FIND_MINIMUM_COMPONENTS}
)

# Required components
if(NOT Boost_SERIALIZATION_LIBRARY OR NOT Boost_SYSTEM_LIBRARY OR NOT Boost_FILESYSTEM_LIBRARY OR
NOT Boost_THREAD_LIBRARY OR NOT Boost_DATE_TIME_LIBRARY)
message(FATAL_ERROR "Missing required Boost components >= v1.65, please install/upgrade Boost or configure your search paths.")
endif()
# Verify that the required Boost component targets were successfully found and imported.
foreach(_t IN ITEMS Boost::serialization Boost::filesystem Boost::thread Boost::date_time)
if(NOT TARGET ${_t})
message(FATAL_ERROR "Missing required Boost component target: ${_t}. Please install/upgrade Boost or set BOOST_ROOT/Boost_DIR correctly.")
endif()
endforeach()

option(GTSAM_DISABLE_NEW_TIMERS "Disables using Boost.chrono for timing" OFF)
# Allow for not using the timer libraries on boost < 1.48 (GTSAM timing code falls back to old timer library)

set(GTSAM_BOOST_LIBRARIES
Boost::serialization
Boost::system
Boost::filesystem
Boost::thread
Boost::date_time
Boost::regex
)
if (GTSAM_DISABLE_NEW_TIMERS)
message("WARNING: GTSAM timing instrumentation manually disabled")
list_append_cache(GTSAM_COMPILE_DEFINITIONS_PUBLIC DGTSAM_DISABLE_NEW_TIMERS)

if(GTSAM_DISABLE_NEW_TIMERS)
message("WARNING: GTSAM timing instrumentation manually disabled")
list_append_cache(GTSAM_COMPILE_DEFINITIONS_PUBLIC DGTSAM_DISABLE_NEW_TIMERS)
else()
if(Boost_TIMER_LIBRARY)
list(APPEND GTSAM_BOOST_LIBRARIES Boost::timer Boost::chrono)
# Link against compiled timer libraries if they exist.
if(TARGET Boost::timer AND TARGET Boost::chrono)
list(APPEND GTSAM_BOOST_LIBRARIES Boost::timer Boost::chrono)
else()
# Fallback for header-only timer: link librt on Linux.
if(UNIX AND NOT APPLE)
list(APPEND GTSAM_BOOST_LIBRARIES rt)
message("WARNING: Using header-only Boost timer; adding -lrt on Linux.")
else()
list(APPEND GTSAM_BOOST_LIBRARIES rt) # When using the header-only boost timer library, need -lrt
message("WARNING: GTSAM timing instrumentation will use the older, less accurate, Boost timer library because boost older than 1.48 was found.")
message("WARNING: Using header-only Boost timer; no extra libs required on this platform.")
endif()
endif()
endif()
endif()
2 changes: 1 addition & 1 deletion gtsam/3rdparty/GeographicLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ set (LIBVERSION_BUILD 17.1.2)
string (TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
string (TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER)

cmake_minimum_required (VERSION 3.5) # This version was released 2011-02-16
cmake_minimum_required (VERSION 3.10)

# User-settable variables

Expand Down
2 changes: 1 addition & 1 deletion gtsam/3rdparty/metis/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10)
project(METIS)

# Add flags for currect directory and below
Expand Down
91 changes: 91 additions & 0 deletions gtsam/navigation/GalileanImuFactor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/* ----------------------------------------------------------------------------

* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)

* See LICENSE for the license information

* -------------------------------------------------------------------------- */

/**
* @file GalileanImuFactor.cpp
* @brief Implementation of Delama et al. IMU Factor
* @author Frank Dellaert
* @author Giulio Delama
*/

#include <gtsam/navigation/GalileanImuFactor.h>

namespace gtsam {

// -- Constructors ------------------------------------------------------------
PreintegratedImuMeasurementsG::PreintegratedImuMeasurementsG(
const std::shared_ptr<Params>& p, const imuBias::ConstantBias& biasHat)
: Base(p, biasHat), p_(p) {}

// -- Integration API ---------------------------------------------------------
void PreintegratedImuMeasurementsG::resetIntegration() {
preintMatrix_ = Gal3().Identity();
preintMeasCov_.setZero();
preintBiasJacobian_.setZero();
}

void PreintegratedImuMeasurementsG::integrateMeasurement(
const Vector3& measuredAcc, const Vector3& measuredOmega, double dt) {
// Correct measurements for bias and construct input
Vector3 acc = biasHat_.correctAccelerometer(measuredAcc);
Vector3 omega = biasHat_.correctGyroscope(measuredOmega);
if (p_->body_P_sensor) {
const auto& bRs = p_->body_P_sensor->rotation();
acc = bRs * acc;
omega = bRs * omega;
}
Vector10 wInput = Vector10::Zero();
wInput.head<3>() = omega;
wInput.segment<3>(3) = acc;
wInput(9) = 1.0; // time scale
Matrix10 Jl;
Gal3 wExp = Gal3::Expmap(-wInput * dt, Jl).inverse();
Matrix10 preintMatrixAdjoint = preintMatrix_.AdjointMap();

// Propagate mean - from eq. (22) in the paper
preintMatrix_ = preintMatrix_.compose(wExp);

// Propagate covariance - from eq. (35) in the paper
// IMPORTANT: the covariance propagation is based on the Right-Invariant (RI)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these outdated now? I think you switched to LI?

// error since the equivariant error (34) is by definition RI. If we want to
// use the Left-Invariant (LI) error to use NavState in the error formulation
// for the factor, we need to change the covariance propagation accordingly
// with the Adjoint. For RI error, the A_ matrix is identity.
Matrix10 B_ = preintMatrixAdjoint * Jl * dt;
Matrix10 Qd = Matrix10::Zero();
Qd.block<3, 3>(0, 0) = p_->gyroscopeCovariance / dt;
Qd.block<3, 3>(3, 3) = p_->accelerometerCovariance / dt;
preintMeasCov_.noalias() += B_ * Qd * B_.transpose();

// Propagate bias Jacobian - from eq. (38) in the paper
Matrix20 phiBiasJacobian = Matrix20::Identity();
phiBiasJacobian.block<10, 10>(9, 9) = -preintMatrixAdjoint * Jl * dt;
preintBiasJacobian_ = phiBiasJacobian * preintBiasJacobian_;
}

// -- print / equals ----------------------------------------------------------
void PreintegratedImuMeasurementsG::print(const std::string& s) const {
std::cout << (s.empty() ? s : s + "\n")
<< "PreintegratedImuMeasurementsG:" << std::endl;
std::cout << " preintMatrix_: " << preintMatrix_ << std::endl;
std::cout << " preintMeasCov_: \n" << preintMeasCov_ << std::endl;
std::cout << " preintBiasJacobian_: \n" << preintBiasJacobian_ << std::endl;
std::cout << " biasHat_: " << biasHat_.vector().transpose() << std::endl;
}
bool PreintegratedImuMeasurementsG::equals(
const PreintegratedImuMeasurementsG& o, double tol) const {
return p_->equals(*o.p_, tol) && biasHat_.equals(o.biasHat_, tol) &&
preintMatrix_.equals(o.preintMatrix_, tol) &&
equal_with_abs_tol(preintMeasCov_, o.preintMeasCov_, tol) &&
equal_with_abs_tol(preintBiasJacobian_, o.preintBiasJacobian_, tol);
}

} // namespace gtsam
Loading
Loading