Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imu_tk application #151

Merged
merged 3 commits into from
Feb 11, 2022
Merged
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
1 change: 0 additions & 1 deletion src/applications/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ option(ENABLE_view "Build basic viewer" ON)
option(ENABLE_soundDetectionDemo "Build sound source detection demo" OFF)
option(ENABLE_corner "Build corner detector" OFF)
option(ENABLE_dualCamTransform "Build event to frame transform" OFF)
option(ENABLE_IMUcalibapp "Install IMU calibration dumper app" OFF)

if(ENABLE_autosaccade)
add_subdirectory(autosaccade)
Expand Down
8 changes: 0 additions & 8 deletions src/applications/IMUCalibDumper/CMakeLists.txt

This file was deleted.

61 changes: 61 additions & 0 deletions src/applications/imuCalibration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
project(EDPR_imutk_app)

cmake_minimum_required (VERSION 2.8)
cmake_policy(SET CMP0015 NEW)

if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE "Release")
endif()

find_package(Boost REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(Ceres REQUIRED)

include_directories(./include
/usr/include
${Boost_INCLUDE_DIRS}
${EIGEN_INCLUDE_DIR}
${CERES_INCLUDE_DIRS})

#Vis3D
find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED )
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)

include_directories( ${OPENGL_INCLUDE_DIRS}
${GLUT_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR} )

set(IMU_TK_VIS_EXTRA_SOURCES
/usr/local/src/imu_tk/src/vis_extra/gl_camera.cpp
/usr/local/src/imu_tk/src/vis_extra/opengl_3d_scene.cpp )
set(IMU_TK_VIS_EXTRA_HEADERS
/usr/local/src/imu_tk/include/imu_tk/vis_extra/opengl_3d_scene.h )

qt4_wrap_cpp(IMU_TK_VIS_EXTRA_HEADERS_MOC ${IMU_TK_VIS_EXTRA_HEADERS})

include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})

aux_source_directory( /usr/local/src/imu_tk/src IMU_TK_CORE_SRC )
set( IMU_TK_SRC ${IMU_TK_CORE_SRC} ${IMU_TK_VIS_EXTRA_HEADERS_MOC} ${IMU_TK_VIS_EXTRA_SOURCES} )

set (IMU_TK_INCLUDE_DIR /usr/local/src/imu_tk/include CACHE STRING "imu_tk include directories")
set (IMU_TK_LIB_DIR /usr/local/src/imu_tk/lib CACHE STRING "imu_tk libraries directories")
set (IMU_TK_LIBS imu_tk ${CERES_LIBRARIES} ${QT_LIBRARIES} ${OPENGL_LIBRARIES} ${GLUT_LIBRARY}
CACHE STRING "imu_tk libraries")

#add_library( imu_tk UNKNOWN IMPORTED)
#set_property(TARGET imu_tk PROPERTY IMPORTED_LOCATION "/usr/local/src/imu_tk/lib/libimu_tk.a")

add_library(imu_tk ${IMU_TK_SRC})
set_target_properties(imu_tk PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${IMU_TK_LIB_DIR})
target_include_directories(imu_tk PRIVATE ${IMU_TK_INCLUDE_DIR})

message( "${IMU_TK_LIBS}" )

add_executable(EDPR_imu_calib EDPR_imu_calib.cpp)
target_include_directories(EDPR_imu_calib PRIVATE ${IMU_TK_INCLUDE_DIR})
target_link_libraries( EDPR_imu_calib ${IMU_TK_LIBS})
#set_target_properties( EDPR_imu_calib PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)

36 changes: 36 additions & 0 deletions src/applications/imuCalibration/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ubuntu:20.04
LABEL maintainer="arren.glover@iit.it"
LABEL version="0.1"
LABEL description="Docker to install IMU calibration software"

# required libs
RUN apt update
RUN DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends build-essential cmake libeigen3-dev freeglut3-dev gnuplot vim
RUN apt install -y git libboost-dev software-properties-common libqt5core5a
RUN apt install -y libgoogle-glog-dev libgflags-dev libatlas-base-dev libsuitesparse-dev
RUN add-apt-repository ppa:rock-core/qt4 && apt update && apt install -y libqt4-dev libqt4-opengl-dev
RUN cd /usr/include && ln -sf eigen3/Eigen Eigen && ln -sf eigen3/unsupported unsupported

# ceres-solver
RUN cd /usr/local/src && \
git clone --depth 1 --branch 2.0.0 https://ceres-solver.googlesource.com/ceres-solver && \
mkdir ceres-solver/build && cd ceres-solver/build && \
cmake .. && make install -j12

# imu_tk
RUN cd /usr/local/src && \
git clone https://bitbucket.org/alberto_pretto/imu_tk.git
#&& \
#mkdir imu_tk/build && cd imu_tk/build && \
#cmake .. && make -j12

# edpr imu_tk application
RUN cd /usr/local/src && \
git clone https://github.com/robotology/event-driven.git && \
cd event-driven/src/applications/imuCalibration && \
mkdir build && cd build && \
cmake .. && make -j12

WORKDIR /usr/local/src


77 changes: 77 additions & 0 deletions src/applications/imuCalibration/EDPR_imu_calib.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include <iostream>
#include <fstream>
#include <iomanip>

#include "imu_tk/io_utils.h"
#include "imu_tk/calibration.h"
#include "imu_tk/filters.h"
#include "imu_tk/integration.h"
#include "imu_tk/visualization.h"

using namespace std;
using namespace imu_tk;
using namespace Eigen;

int main(int argc, char** argv)
{
if( argc < 4 ) {
std::cout << "Calibrate IMU in the EDPR environment" << std::endl;
std::cout << "Usage: EDPR_imu_calib <acc file> <gyro file> <output file>" << std::endl;
return -1;
}

vector< TriadData > acc_data, gyro_data;

cout<<"Importing IMU data from the Matlab matrix file : "<< argv[1]<<endl;
importAsciiData( argv[1], acc_data, imu_tk::TIMESTAMP_UNIT_SEC );
cout<<"Importing IMU data from the Matlab matrix file : "<< argv[2]<<endl;
importAsciiData( argv[2], gyro_data, imu_tk::TIMESTAMP_UNIT_SEC );
ofstream cw(argv[3], ios_base::out|ios_base::trunc);
if(!cw.is_open()) {
std::cout << "Error: could not open output .ini file for writing" << std::endl;
return -1;
}
cout<<"Saving Calibration to the file : "<< argv[3] << endl;


CalibratedTriad init_acc_calib, init_gyro_calib;
init_acc_calib.setBias( Vector3d(0.0, 0.0, 0.0) );
init_acc_calib.setScale( Vector3d(0.00059855, 0.00059855, 0.00059855) );
init_gyro_calib.setBias( Vector3d(0.0, 0.0, 0.0) );
init_gyro_calib.setScale( Vector3d(0.000010653,0.000010653,0.000010653) );

MultiPosCalibration mp_calib;

//mp_calib.setInitStaticIntervalDuration(50.0);
mp_calib.setInitAccCalibration( init_acc_calib );
mp_calib.setInitGyroCalibration( init_gyro_calib );
mp_calib.setGravityMagnitude(9.80665);
mp_calib.enableVerboseOutput(true);
mp_calib.enableAccUseMeans(false);
//mp_calib.setGyroDataPeriod(0.01);
mp_calib.calibrateAccGyro(acc_data, gyro_data );
//mp_calib.getAccCalib().save("test_imu_acc.calib");
//mp_calib.getGyroCalib().save("test_imu_gyro.calib");

cw << std::fixed << std::setprecision(8);
const Vector3d &abv = mp_calib.getAccCalib().getBiasVector();
cw << "ACC_BIAS (" << abv[0] << " " << abv[1] << " " << abv[2] << ")" << std::endl;
const Matrix3d &abg = mp_calib.getAccCalib().getScaleMatrix();
cw << "ACC_GAIN (" << abg(0, 0) << " " << abg(1, 1) << " " << abg(2, 2) << ")" << std::endl;
const Matrix3d &abs = mp_calib.getAccCalib().getMisalignmentMatrix();
cw << "ACC_SKEW (" << abs(0, 0) << " " << abs(0, 1) << " " << abs(0, 2) << " "
<< abs(1, 0) << " " << abs(1, 1) << " " << abs(1, 2) << " "
<< abs(2, 0) << " " << abs(2, 1) << " " << abs(2, 2) << ")"
<< std::endl;
const Vector3d &gbv = mp_calib.getGyroCalib().getBiasVector();
cw << "GYR_BIAS (" << gbv[0] << " " << gbv[1] << " " << gbv[2] << ")" << std::endl;
const Matrix3d &gbg = mp_calib.getGyroCalib().getScaleMatrix();
cw << "GYR_GAIN (" << gbg(0, 0) << " " << gbg(1, 1) << " " << gbg(2, 2) << ")" << std::endl;
const Matrix3d &gbs = mp_calib.getGyroCalib().getMisalignmentMatrix();
cw << "GYR_SKEW (" << gbs(0, 0) << " " << gbs(0, 1) << " " << gbs(0, 2) << " "
<< gbs(1, 0) << " " << gbs(1, 1) << " " << gbs(1, 2) << " "
<< gbs(2, 0) << " " << gbs(2, 1) << " " << gbs(2, 2) << ")"
<< std::endl;

return 0;
}