Skip to content

Commit

Permalink
Merge pull request #24 from tmcg0/dev
Browse files Browse the repository at this point in the history
Target bioslam 1.0.1
  • Loading branch information
tmcg0 authored Dec 2, 2023
2 parents 70eae20 + 64173d4 commit 816c449
Show file tree
Hide file tree
Showing 21 changed files with 1,450 additions and 92 deletions.
167 changes: 167 additions & 0 deletions .github/workflows/build-test-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
name: Linux CI

on: [push, pull_request, workflow_dispatch]

jobs:
build:
name: ${{ matrix.name }} ${{ matrix.build_type }}
runs-on: ${{ matrix.os }}

env:
CTEST_OUTPUT_ON_FAILURE: ON
CTEST_PARALLEL_LEVEL: 2
CMAKE_BUILD_TYPE: ${{ matrix.build_type }}
BOOST_VERSION: 1.67.0

strategy:
fail-fast: false
matrix:
name: [
ubuntu-20.04-gcc-7,
ubuntu-20.04-gcc-9,
ubuntu-20.04-clang-9,
]

build_type: [Debug, Release]
include:
- name: ubuntu-20.04-gcc-7
os: ubuntu-20.04
compiler: gcc
version: "7"

- name: ubuntu-20.04-gcc-9
os: ubuntu-20.04
compiler: gcc
version: "9"

- name: ubuntu-20.04-clang-9
os: ubuntu-20.04
compiler: clang
version: "9"

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Print job details
run: |
echo "Job ${{ env.GITHUB_JOB }}"
echo "compiler: '${{matrix.compiler}}'"
echo "matrix name: '${{matrix.name}}"
echo "build type: '${{ matrix.build_type }}'"
- name: Install Eigen 3.3.9
run: |
cd ${{runner.workspace}} # cd to runner home
git clone --depth 1 --branch 3.3.9 https://gitlab.com/libeigen/eigen eigen3 # clone Eigen
cd eigen3 && mkdir build && cd build # move into build dir for eigen3
cmake ..
sudo make -j$(nproc) install
- name: Install Python 3.9
run: |
if ["${{matrix.os}}"="ubuntu-18.04"]; then
sudo apt-get -y install libpython-dev python-numpy
else # Ubuntu 20.04
sudo apt-get -y install libpython3-dev python-numpy
fi
- name: Install build tools
run: |
# LLVM (clang) 9 is not in Bionic's repositories so we add the official LLVM repository.
if [ "${{ matrix.compiler }}" = "clang" ] && [ "${{ matrix.version }}" = "9" ] && [ "${{matrix.os}}"="ubuntu-18.04" ]; then
# (ipv4|ha).pool.sks-keyservers.net is the SKS GPG global keyserver pool
# ipv4 avoids potential timeouts because of crappy IPv6 infrastructure
# 15CF4D18AF4F7421 is the GPG key for the LLVM apt repository
# This key is not in the keystore by default for Ubuntu so we need to add it.
LLVM_KEY=15CF4D18AF4F7421
gpg --keyserver keyserver.ubuntu.com --recv-key $LLVM_KEY || gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-key $LLVM_KEY
gpg -a --export $LLVM_KEY | sudo apt-key add -
sudo add-apt-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main"
fi
sudo apt-get -y update
sudo apt-get -y install cmake build-essential pkg-config libicu-dev
if [ "${{ matrix.compiler }}" = "gcc" ]; then
sudo apt-get install -y g++-${{ matrix.version }} g++-${{ matrix.version }}-multilib
echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV
echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV
else
sudo apt-get install -y clang-${{ matrix.version }} g++-multilib
echo "CC=clang-${{ matrix.version }}" >> $GITHUB_ENV
echo "CXX=clang++-${{ matrix.version }}" >> $GITHUB_ENV
fi
- name: Install Boost
run: |
BOOST_FOLDER=boost_${BOOST_VERSION//./_}
wget https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/${BOOST_FOLDER}.tar.gz
tar -zxf ${BOOST_FOLDER}.tar.gz
cd ${BOOST_FOLDER}/
./bootstrap.sh --with-libraries=serialization,filesystem,thread,system,atomic,date_time,timer,chrono,program_options,regex
sudo ./b2 -j$(nproc) install
- name: Install GTSAM 4.0.3
run: |
cd ${{runner.workspace}} # cd to runner home
git clone --depth 1 --branch 4.0.3 https://github.com/borglab/gtsam.git gtsam # clone latest from dev branch. switch to GTSAM 4.1 once it's tagged.
cd gtsam && mkdir build && cd build # move into build dir for gtsam
cmake -DCMAKE_BUILD_TYPE=Release -DGTSAM_WITH_EIGEN_MKL=OFF -DGTSAM_BUILD_EXAMPLES_ALWAYS=OFF -DGTSAM_BUILD_TIMING_ALWAYS=OFF -DGTSAM_BUILD_TESTS=OFF -DGTSAM_BUILD_UNSTABLE=ON ..
sudo make -j$(nproc) install
- name: Install hdf5
run: sudo apt-get -y install libhdf5-serial-dev

- name: Install HighFive v2.3.1
run: |
cd ${{runner.workspace}} # cd to runner home
git clone https://github.com/BlueBrain/HighFive HighFive && cd HighFive # clone HighFive
git checkout a01ee6be4d4a75aeeb9fd962c3b415ea8cd395f6 # checkout v2.3.1 release
mkdir build && cd build # move into build dir for HighFive
cmake -DHIGHFIVE_USE_BOOST=OFF ..
sudo make -j$(nproc) install
- name: Install imuDataUtils
run: |
cd ${{runner.workspace}} # cd to runner home
git clone --depth 1 --branch master https://github.com/tmcg0/imuDataUtils imuDataUtils # clone imuDataUtils
cd imuDataUtils && mkdir build && cd build # move into build dir for imuDataUtils
cmake ..
sudo make -j$(nproc) install
- name: Install LCov
if: matrix.name == 'ubuntu-20.04-gcc-9' && matrix.build_type == 'Debug'
run: sudo apt-get update -q && sudo apt-get install lcov -q -y

- name: Build bioslam
run: |
cd ${{github.workspace}} # cd to repo root
mkdir build && cd build # move into bioslam build dir
cmake -DBIOSLAM_BUILD_MATLAB_WRAPPER=OFF ..
sudo make -j$(nproc) install
- name: Test bioslam
run: make -j$(nproc) test

- name: Run LCov
if: matrix.name == 'ubuntu-20.04-gcc-9' && matrix.build_type == 'Debug'
run: |
cd ${{github.workspace}}/build # cd to build folder
lcov -c -d . --include '*bioslam*' -o main_coverage.info
- name: Submit to codecov.io
if: matrix.name == 'ubuntu-20.04-gcc-9' && matrix.build_type == 'Debug'
uses: codecov/codecov-action@v3
with:
files: ${{github.workspace}}/build/main_coverage.info
token: ${{ secrets.CODECOV_TOKEN }} # supposedly not required for public repos, but codecov fails otherwise
name: bioslam-codecov # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)

- name: Archive code coverage results
if: matrix.name == 'ubuntu-20.04-gcc-9' && matrix.build_type == 'Debug'
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: ${{github.workspace}}/build/main_coverage.info
retention-days: 30
20 changes: 20 additions & 0 deletions .github/workflows/cpp-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: cpp-linter

on: [push, pull_request, workflow_dispatch]

jobs:
cpp-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cpp-linter/cpp-linter-action@v2
id: linter
with:
style: 'llvm'
files-changed-only: false

- name: Fail fast
if: steps.linter.outputs.checks-failed > 0
run: |
echo "Some files failed the linting checks!"
exit 1
20 changes: 20 additions & 0 deletions .github/workflows/dockerfile-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Dockerfile

on: [push, pull_request, workflow_dispatch]

jobs:
test:
name: Build, test Dockerfile
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Build and run docker image
run: |
docker build -t bioslam -f ./docker/ubu-20.Dockerfile ./docker
docker run -id --name bioslam bioslam
- name: Run tests
run: docker exec -i bioslam make test
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ cmake-build-minsizerel/
wrap/build/
build*/


# ide files
# IDEs and editors
*.idea
.idea/
.idea/*
.idea/
.vscode/

# ignore Latex stuff
*.aux
Expand Down
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ set (BIOSLAM_VERSION_STRING "${BIOSLAM_VERSION_MAJOR}.${BIOSLAM_VERSION_MINOR}.$

project(bioslam VERSION ${BIOSLAM_VERSION_STRING} LANGUAGES CXX C) # added C because some HDF5 tests were .c

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Introduce variables:
# * CMAKE_INSTALL_LIBDIR
# * CMAKE_INSTALL_BINDIR
Expand All @@ -22,13 +26,12 @@ endif()
# -------------------------------------- #

set(PROJECT_DESCRIPTION "IMU + biomechanics estimation toolbox") # for compatibility with CMake 3.8.2
set(CMAKE_CXX_STANDARD 14) # C++ version

### ----- User options ----- ###
option(BIOSLAM_BUILD_WITH_MARCH_NATIVE "Build with -march=native (this should match the gtsam build option GTSAM_BUILD_WITH_MARCH_NATIVE)" ON)
option(BIOSLAM_BUILD_TESTS "Should I build these tests?" ON)
option(GTSAM_USE_MKL "Does GTSAM require MKL?" OFF)
option(BIOSLAM_BUILD_MATLAB_WRAPPER "Build the MATLAB interface for bioslam?" ON)
option(BIOSLAM_BUILD_MATLAB_WRAPPER "Build the MATLAB interface for bioslam?" OFF)
option(BIOSLAM_BUILD_EXAMPLES "Build examples?" ON)
option(BIOSLAM_USE_TBB "Include Intel's TBB library?" ON) # if GTSAM uses TBB, you need to set this to 'ON'
### ------------------------ ###
Expand Down Expand Up @@ -56,6 +59,9 @@ endif()

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules/") # include the modules subfolder

include(CodeCoverage)
append_coverage_compiler_flags()

# Offer the user the choice of overriding the installation directories
set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
Expand Down Expand Up @@ -90,7 +96,7 @@ if(GTSAM_USE_MKL)
message(STATUS "including MKL from ${MKL_INCLUDE_DIRS}")
endif()
# --- Require Boost ---
find_package(Boost 1.58 COMPONENTS filesystem REQUIRED)
find_package(Boost 1.65 COMPONENTS filesystem REQUIRED)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
list(APPEND BIOSLAMLIBS ${Boost_LIBRARIES})
Expand Down Expand Up @@ -152,6 +158,11 @@ list(APPEND SOURCES_BIOSLAM ${PROJECT_SOURCE_DIR}/src/factors/MagPose3Factor.cpp
message(STATUS "Libs that we have for bioslam are ${BIOSLAMLIBS} ")
message("bioslam sources are ${SOURCES_BIOSLAM}")
add_library(bioslam SHARED ${SOURCES_BIOSLAM})
set_target_properties(bioslam PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
target_link_libraries(bioslam ${BIOSLAMLIBS})
target_link_libraries(bioslam gtsam)
target_link_libraries(bioslam HighFive)
Expand Down
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Bioslam: IMU-Based Human Skeletal Pose Estimation

**Author:** [Tim McGrath](https://www.researchgate.net/profile/Tim_Mcgrath9)
<h1 align="center">
Bioslam: IMU-Based Human Skeletal Pose Estimation<br>
<a href="https://github.com/tmcg0/bioslam/actions/workflows/build-test-linux.yml/badge.svg"><img src="https://github.com/tmcg0/bioslam/actions/workflows/build-test-linux.yml/badge.svg"/></a> <a href="https://github.com/tmcg0/bioslam/actions/workflows/dockerfile-build.yml/badge.svg"><img src="https://github.com/tmcg0/bioslam/actions/workflows/dockerfile-build.yml/badge.svg"/></a> <a href="https://github.com/tmcg0/bioslam/actions/workflows/cpp-linter.yml/badge.svg"><img src="https://github.com/tmcg0/bioslam/actions/workflows/cpp-linter.yml/badge.svg"/></a> <a href="https://codecov.io/gh/tmcg0/bioslam" ><img src="https://codecov.io/gh/tmcg0/bioslam/branch/dev/graph/badge.svg?token=7YN205FLRJ"/></a> <a href="https://github.com/tmcg0/bioslam/blob/dev/LICENSE.txt"><img src="https://img.shields.io/badge/License-MIT-maroon.svg"/></a>

</h1>

## What is Bioslam?

Bioslam is a C++/MATLAB toolbox for estimation of human skeletal pose from IMU data, using robust factor-graph based global optimization techniques.

<p align="center">
<img width="400" height="400" src="https://github.com/tmcg0/bioslam/blob/dev/doc/media/bioslam-gait.gif">
<img width="430" height="430" src="https://github.com/tmcg0/bioslam/blob/dev/doc/media/subj_cal_partial.gif">
<img width="380" height="380" src="https://github.com/tmcg0/bioslam/blob/dev/doc/media/bioslam-gait.gif">
<img width="410" height="410" src="https://github.com/tmcg0/bioslam/blob/dev/doc/media/subj_cal_partial.gif">
</p>

## Citing Bioslam
Expand All @@ -20,7 +22,9 @@ If using this software repository, please cite bioslam through the following Zen
<!-- For now I'm putting all of these in IEEE style without ref numbers and without DOI numbers since I'll provide direct links -->
If using bioslam, also please cite the following publication:

- T. McGrath and L. Stirling, “Body-Worn IMU Human Skeletal Pose Estimation Using a Factor Graph-Based Optimization Framework,” *Sensors*, vol. 20, no. 23, p. 6887, Dec. 2020. [[link]](https://www.mdpi.com/1424-8220/20/23/6887)
- T. McGrath and L. Stirling, “Body-Worn IMU Human Skeletal Pose Estimation Using a Factor Graph-Based Optimization Framework,” *Sensors*, vol. 20, no. 23, p. 6887, Dec. 2020. [[link]](https://doi.org/10.3390/s20236887)

- T. McGrath and L. Stirling, “Body-Worn IMU-Based Human Hip and Knee Kinematics Estimation during Treadmill Walking,” *Sensors*, vol. 22, no. 7, p. 2544, Mar. 2022. [[link]](https://doi.org/10.3390/s22072544)

### Related publications
The novel hinge joint kinematic model is based on:
Expand All @@ -35,10 +39,19 @@ The optimization backend ([GTSAM 4.0+](https://github.com/borglab/gtsam)) and IM

# Installation

### Supported systems
Bioslam is tested on the following systems:

- Ubuntu 20.04 with GCC 7, GCC 9, and Clang 9

using Boost 1.67, GTSAM 4.0.3, and Eigen 3.3.9.

On other systems, a bioslam-installed Ubuntu image can be spun up in a Docker container using the provided [Dockerfile](docker/Dockerfile).

## Required Dependencies

* CMake (>= 3.17, _working through older versions now. Can confirm 3.10.2 doesn't work_)
* boost (>= 1.58)
* boost (>= 1.65)
* Ubuntu: `sudo apt-get install libboost-all-dev`
* [Eigen](http://eigen.tuxfamily.org/index.php?title=Main_Page)
* `git clone https://github.com/eigenteam/eigen-git-mirror`
Expand Down
Loading

0 comments on commit 816c449

Please sign in to comment.