IMU Errors and Rectification

[TOC]

Overview

  • 确定性误差(六面法 标定)
    • 开机后恒定的零偏误差(bias)
    • 比例因子误差(scale factor)
    • 轴偏及非正交误差(misalignment errors and non-orthogonality)
    • 非线性误差(non-linearity)
    • 温度误差(thermal noise)
    • 陀螺仪还包含加速度的变化引起的误差(g-dependent noise)
  • 随机性误差(Allan方差 标定)
    • 高斯白噪声(Noise Density)
    • 零偏不稳定性(Bias Instability or Random Walk)


IMU Stochastic Errors

  • a high frequency additive White Noise
  • a slower varying sensor Bias

continuous-time model:

Ref:

How To Get

the Datasheet of the IMU

  • White Noise Terms
    • Rate Noise Density (Angular Random Walk - ARW)
    • Acceleration Noise Density (Velocity Random Walk - VRW)
  • Bias Terms
    • In-Run Bias (Bias Stability)

the Allan standard deviation (AD)

  • “white noise” is at tau=1 (slope -1/2 in a log-log AD plot)
  • “random walk” is at tau=3 (slope +1/2 in a log-log AD plot)

Noise Samples (Continuous-time)

  • MPU6000 / MPU6050

    core_noise_acc: 0.003924    # [m/s^2/sqrt(Hz)] mpu6000 datasheet
    core_noise_gyr: 0.00008726  # [rad/s/sqrt(Hz)] mpu6000 datasheet
    
  • ADIS 16448

    # avg-axis
    gyr_n: 1.8582082627718251e-04
    gyr_w: 7.2451532648461174e-05
    acc_n: 1.9862287242243099e-03
    acc_w: 1.2148497781522122e-03
    
  • MYNT-EYE-S1030 IMU

    gyr_n: 0.00888232829671
    gyr_w: 0.000379565782927
    acc_n: 0.0268014618074
    acc_w: 0.00262960861593
    

Performance Analysis Software

  • IMU-TK: Inertial Measurement Unit ToolKit
  • gaowenliang/imu_utils: A ROS package tool to analyze the IMU performance
    <?xml version="1.0"?>
    <launch>
        <node pkg="imu_utils" type="imu_an" name="imu_an" output="screen">
            <param name="imu_topic" type="string" value= "/camera/imu/data_raw"/>
            <param name="imu_name" type="string" value= "ZR300"/>
            <param name="data_save_path" type="string" value= "$(find imu_utils)/data/"/>
            <param name="max_time_min" type="int" value= "80"/>
            <param name="max_cluster" type="int" value= "100"/>
        </node>
    </launch>
    
  • rpng/kalibr_allan: IMU Allan standard deviation charts for use with Kalibr and inertial kalman filters
  • XinLiGH/GyroAllan: 陀螺仪随机误差的 Allan 方差分析
  • AllanTools: A python library for calculating Allan deviation and related time & frequency statistics.

Reference

Read More

Ubuntu16.04 下 构建 Android(NDK) 应用

[TOC]

NDK Build

Generate .so or .a files using NDK tools:

  1. Edit .java file

  2. Generate header file for the java file using JDK tools javac and javah
    # 在 `src` 目录下
    javac com/ndk/test/OpenCVTest.java
    javah -classpath ./ -jni com.ndk.test.OpenCVTest
    
  3. Edit Android.mk and Application.mk files

  4. Generate .so or .a files using command ndk-build

  5. Load the library and using its methods

NDK Tips

Android NDK 从2013年开始支持了C++11,从2015年开始支持C++14,在 Android.mk 中加入

# c++ 11 标准
LOCAL_CPPFLAGS += -std=c++11
LOCAL_CPPFLAGS += -D__cplusplus=201103L  

# or

# c++ 14 标准
LOCAL_CPPFLAGS += -std=c++1y
LOCAL_CPPFLAGS += -D__cplusplus=201300L

When compiling c++ code with -std=c++11 and using gnustl_shared, many C99 math functions are not provided by the header as they should. At this time,`APP_STL := c++_static` may help.(from Issue: [C++11 cmath functions not in std namespace](https://stackoverflow.com/a/22924781/6560660))

Build Android Project

Build Ant Project

  • generate build.xml for Ant
    android update project -p .
    
  • build ant project
    ant debug/release
    

Build Eclipse Project

Sign APK

  1. Generate keystore file
     keytool -genkey -alias ChenguangCam -keyalg RSA -validity 100000 -keystore AndroidCameraApp.keystore
    
  2. Sign Apk
  • 使用第三方工具:爱加密签名工具
  • 使用命令行
    jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore  
    <path_to_AndroidCameraApp.keystore> -storepass 123456 -keypass 123456 -signedjar <path_to_signed.apk> <path_to_unsign.apk> ChenguangCam
    
  • Eclipse Project: 右键单击项目名称,选择”Android Tools”,再选择”Export Signed Application Package…”;
  • Ant Project: add key.store and key.alias properties to ant.properties file;

Install APK

  • Install apk file to devices
    adb install <path_to_apk>
    # or
    adb install -r <path_to_apk>
    
  • uninstall apk
    adb uninstall <package-name>
    

Debug

Native C++ Crash Debug

当NDK生成的 .so 运行崩掉时,通过NDK工具查找相关信息。

ndk-stack

1) 实时分析日志

程序运行过程中,执行如下命令:

adb logcat | ndk-stack -sym <so文件所在路径>

当程序崩溃时,可输出崩溃信息。

2) 获取日志再分析

程序运行过程中,执行如下命令:

adb logcat > 1.log

程序崩溃后,通过如下命令获取崩溃信息:

ndk-stack -sym <so文件所在路径> -dump 1.log

或 通过关键字查找

  • NDK logcat crash keywords

    ——— beginning of crash

    backtrace

arm-linux-androideabi-addr2line

获取日志中关键函数指针,例如

#00 pc 00031896 /data/app/com.tools/lib/arm/libtools.so

根据地址,使用如下命令找到对应的函数:

arm-linux-androideabi-addr2line -e libtools.so 00031896 -f

参考:如何定位Android NDK开发中遇到的错误

Check File Dependencies

arm-linux-androideabi-readelf

  • check .so file
    arm-linux-androideabi-readelf -d *.so
    

应用认领

应用认领那些事:
http://droidyue.com/blog/2014/12/14/android-yingyong-renling/?utm_source=tuicool&utm_medium=referral

Read More

Android Issues 总结

[TOC]


DateTimePicker Control

自定义对话框

How to draw rectangle in XML?

We can create a new XML file inside the drawable folder, and add the following code, then save it as rectangle.xml.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <solid
        android:color="@android:color/transparent" />
    <stroke
        android:width="2dip"
        android:dashWidth="2dp"   
        android:dashGap="5dp"    
        android:color="#ff0000"/>
</shape>

To use it inside a layout we would set the android:background attribute to the new drawable shape,like the following code segment.

<ImageView
	android:id="@+id/rectimage"
	android:layout_height="100dp"
	android:layout_width="100dp"
	android:src="@drawable/rectangle">
</ImageView>

finally,have a fun!

Link: http://stackoverflow.com/questions/10124919/can-i-draw-rectangle-in-xml

How to change “shape”(in XML) color dynamically?

The “Shape” code in circle2.xml is as like the following segments:

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/shape_circle2"
    android:shape="oval"
    android:useLevel="false" >	        
    <solid
        android:color="@android:color/transparent" />	    
    <stroke
        android:width="1dp"
        android:color="#00ff00"/>
    <size
        android:width="55dp"
        android:height="55dp"/>    
</shape>

The code using “Shape” is as follows:

<ImageView
	android:id="@+id/circle_img"
	android:layout_height="50dp"
	android:layout_width="50dp"
	android:background="@drawable/circle">
</ImageView>

And we can modify the “Shape” color simply like this:

ImageView imgviewCircle  = (ImageView)findViewById(R.id.circle_img);
GradientDrawable backgroundGradient = (GradientDrawable)imgviewCircle.getBackground();
backgroundGradient.setColor(Color.GREEN);

Note: It must be the attribute android:background of ImageView that use the “Shape” as long as we modify the “Shape” color like that!

Link: http://stackoverflow.com/questions/7164630/how-to-change-shape-color-dynamically

Android设置textView水平居中显示

  • 让textView里面的内容水平居中:android:gravity=”center_horizontal”
  • 让textView控件在它的父布局里水平居中:android:layout_gravity=”center_horizontal”

Using lists in Android (ListView) - Tutorial

Link: http://www.vogella.com/tutorials/AndroidListView/article.html

Read More

Ubuntu16.04 下 Android 开发环境

[TOC]

Overview

  • in ~/.bashrc(or /etc/profile or /etc/environment)
    export JAVA_HOME=/home/cg/tools/android_tools/jdk1.8.0_251
    export JRE_HOME=$JAVA_HOME/jre
    export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
    export PATH=$JAVA_HOME/bin:$PATH
    
    export ANDROID_SDK=/home/cg/tools/android_tools/android-sdk-linux
    export PATH=$ANDROID_SDK/tools:$PATH
    export PATH=$ANDROID_SDK/platform-tools:$PATH
    
    export ANDROID_NDK=/home/cg/tools/android_tools/android-ndk-r16b
    export PATH=$ANDROID_NDK:$ANDROID_NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:$PATH
    

JDK

  • 下载JDK包(例如,jdk-8u251-linux-x64.tar.gz)并解压

  • 配置环境变量

  • 查看java版本

    java -version
    javac -version
    

Android SDK

  • online install: http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
  • offline install:
    • windows: installer_r24.4.1-windows.exe
    • linux: android-sdk_r24.4.1-linux.tgz
  • Android SDK开发包国内下载地址

tools

android

  • Android SDK Manager
    android
    
  • android list
    android list [targets]
    
  • update tools
    [tsocks] android update sdk -u
    

ddms

  • DDMS
    ddms
    

emulator

  • emulator
    emulator
    

mksdcard

platform-tools

adb

adb help

adb shell

adb root
adb remount

adb start-server

adb devices
adb get-serialno

adb push/pull
adb install

adb logcat
adb bugreport

Android NDK

  • e.g., android-ndk-r14b, android-ndk-r16b-linux-x86_64.zip, etc.

  • ndk build

    ndk-build -j4
    

toolchains (Cross-Compilation tools)

  • e.g. compilers
    arm-linux-androideabi-g++
    arm-linux-androideabi-gcc
    
  • others
    arm-linux-androideabi-*
    

Android Project

Ant Project

  • install ant
    sudo apt install ant
    
  • generate build.xml for Ant
    android update project -t android-23 -p .
    
  • build ant project (SDK Build-tools and SDK Platform need to be installed)
    ant debug/release
    

Eclipse

Android Studio (AS)

  • ubuntu 删除android studio
    • android-studio文件夹
    • ~/.AndroidStudio
    • ~/.android
    • ~/.local/share/applications/jetbrains-android-studio.desktop
Read More

机器人学之3D欧式变换之旋转ABC

[TOC]

旋转小量

  • 若小旋转向量 $\Delta \boldsymbol{\phi}$,则旋转小量
\[\Delta \mathbf{R} = \exp({\Delta \boldsymbol{\phi}}^\wedge) \approx \mathbf{I} + {\Delta \boldsymbol{\phi}}^\wedge\] \[\Delta \mathbf{q} \approx \begin{bmatrix} 1 \\ \frac{1}{2} \Delta \boldsymbol{\phi} \end{bmatrix}\]
  • 两种对旋转更新的方式
\[\mathbf{R} \leftarrow \mathbf{R} \cdot \Delta \mathbf{R}\] \[\mathbf{q} \leftarrow \mathbf{q} \otimes \Delta \mathbf{q}\]

时间导数

  • 若角速度为 $\boldsymbol{\omega}$,那么旋转的时间导数为
\[\dot{\mathbf{q}} = \mathbf{q} \otimes \begin{bmatrix} 0 \\ \frac{1}{2} \boldsymbol{\omega} \end{bmatrix} = \frac{1}{2} \mathbf{q} \otimes \begin{bmatrix} 0 \\ \boldsymbol{\omega} \end{bmatrix}\] \[\dot{\mathbf{R}}=\mathbf{R} \boldsymbol{\omega}^{\wedge}\]

对旋转求导

李群李代数求导

  • 用李代数表示位姿,然后根据李代数加法来对李代数求导
\[\begin{aligned} \frac{\partial(\boldsymbol{R} p)}{\partial \phi} &= \frac{\partial\left(\exp \left(\boldsymbol{\phi}^{\wedge}\right) \boldsymbol{p}\right)}{\partial \boldsymbol{\phi}} \\ &=\lim _{\delta \phi \rightarrow 0} \frac{\exp \left((\boldsymbol{\phi}+\delta \boldsymbol{\phi})^{\wedge}\right) \boldsymbol{p}-\exp \left(\boldsymbol{\phi}^{\wedge}\right) \boldsymbol{p}}{\delta \boldsymbol{\phi}} \\ &=\lim _{\delta \boldsymbol{\phi} \rightarrow 0} \frac{\exp \left(\left(\boldsymbol{J}_{l} \delta \boldsymbol{\phi}\right)^{\wedge}\right) \exp \left(\boldsymbol{\phi}^{\wedge}\right) \boldsymbol{p}-\exp \left(\boldsymbol{\phi}^{\wedge}\right) \boldsymbol{p}}{\delta \boldsymbol{\phi}} \\ & \approx \lim _{\delta \boldsymbol{\phi} \rightarrow 0} \frac{\left(\boldsymbol{I}+\left(\boldsymbol{J}_{l} \delta \boldsymbol{\phi}\right)^{\wedge}\right) \exp \left(\boldsymbol{\phi}^{\wedge}\right) \boldsymbol{p}-\exp \left(\boldsymbol{\phi}^{\wedge}\right) \boldsymbol{p}}{\delta \boldsymbol{\phi}} \\ &=\lim _{\delta \boldsymbol{\phi} \rightarrow 0} \frac{\left(\boldsymbol{J}_{l} \delta \boldsymbol{\phi}\right)^{\wedge} \exp \left(\boldsymbol{\phi}^{\wedge}\right) \boldsymbol{p}}{\delta \boldsymbol{\phi}} \\ &=\lim _{\delta \boldsymbol{\phi} \rightarrow 0} \frac{-\left(\exp \left(\boldsymbol{\phi}^{\wedge}\right) \boldsymbol{p}\right)^{\wedge} \boldsymbol{J}_{l} \delta \boldsymbol{\phi}}{\delta \boldsymbol{\phi}}=-(\boldsymbol{R} \boldsymbol{p})^{\wedge} \boldsymbol{J}_{l} \end{aligned}\]

with

\[\boldsymbol{J}_{l}=\boldsymbol{J}=\frac{\sin \theta}{\theta} \boldsymbol{I}+\left(1-\frac{\sin \theta}{\theta}\right) \boldsymbol{a} \boldsymbol{a}^{T}+\frac{1-\cos \theta}{\theta} \boldsymbol{a}^{\wedge}\]
  • 对李群左乘或者右乘微小扰动量,然后对该扰动求导,成为左扰动和右扰动模型,这种方式 省去了计算雅克比,所以使用更为常见
\[\begin{aligned} \frac{\partial(\boldsymbol{R} \boldsymbol{p})}{\partial \boldsymbol{\varphi}} &=\lim _{\boldsymbol{\varphi} \rightarrow 0} \frac{\exp \left(\boldsymbol{\varphi}^{\wedge}\right) \exp \left(\boldsymbol{\phi}^{\wedge}\right) \boldsymbol{p}-\exp \left(\boldsymbol{\phi}^{\wedge}\right) \boldsymbol{p}}{\varphi} \\ & \approx \lim _{\varphi \rightarrow 0} \frac{\left(1+\boldsymbol{\varphi}^{\wedge}\right) \exp \left(\boldsymbol{\phi}^{\wedge}\right) \boldsymbol{p}-\exp \left(\boldsymbol{\phi}^{\wedge}\right) \boldsymbol{p}}{\varphi} \\ &=\lim _{\boldsymbol{\varphi} \rightarrow 0} \frac{\boldsymbol{\varphi}^{\wedge} \boldsymbol{R} \boldsymbol{p}}{\varphi}=\lim _{\varphi \rightarrow 0} \frac{-(\boldsymbol{R} \boldsymbol{p})^{\wedge} \boldsymbol{\varphi}}{\varphi} \\ &=-(\boldsymbol{R} \boldsymbol{p})^{\wedge} \end{aligned}\] \[\begin{aligned} \frac{d(\mathbf{R}^{-1} \mathbf{p})}{d \mathbf{R}} &= \frac{\partial{(\mathbf{R}^{-1} \mathbf{p})}}{\partial{\varphi}} \\ &= \lim_{\varphi \rightarrow 0} \frac{(\mathbf{R}\exp(\varphi^{\wedge}))^{-1} \mathbf{p} - \mathbf{R}^{-1} \mathbf{p}} {\varphi} \\ &= \lim_{\varphi \rightarrow 0} \frac{\exp(-\varphi^{\wedge}) \mathbf{R}^{-1} \mathbf{p} - \mathbf{R}^{-1} \mathbf{p}} {\varphi} \\ &\approx \lim_{\varphi \rightarrow 0} \frac{(\mathbf{I}-\varphi^{\wedge}) \mathbf{R}^{-1} \mathbf{p} - \mathbf{R}^{-1} \mathbf{p}} {\varphi} \\ &= \lim_{\varphi \rightarrow 0} \frac{-\varphi^{\wedge} \mathbf{R}^{-1} \mathbf{p}} {\varphi} \\ &= \lim_{\varphi \rightarrow 0} \frac{(\mathbf{R}^{-1}\mathbf{p})^{\wedge} \varphi} {\varphi} \\ &= (\mathbf{R}^{-1}\mathbf{p})^{\wedge} \end{aligned}\] \[\begin{aligned} \frac{d \ln(\mathbf{R}_1 \mathbf{R}_2^{-1})^{\vee}}{d \mathbf{R}_2} &= \lim_{\phi \rightarrow 0} \frac{\ln(\mathbf{R}_1 (\mathbf{R}_2 \exp(\phi^{\wedge}))^{-1})^{\vee} - \ln(\mathbf{R}_1 \mathbf{R}_2^{-1})^{\vee}} {\phi} \\ &= \lim_{\phi \rightarrow 0} \frac{\ln(\mathbf{R}_1 \exp(-\phi^{\wedge}) \mathbf{R}_2^{-1})^{\vee} - \ln(\mathbf{R}_1 \mathbf{R}_2^{-1})^{\vee}} {\phi} \\ &= \lim_{\phi \rightarrow 0} \frac{\ln(\mathbf{R}_1 \mathbf{R}_2^{-1} \exp((-\mathbf{R}_2 \phi)^{\wedge}))^{\vee} - \ln(\mathbf{R}_1\mathbf{R}_2^{-1})^{\vee}} {\phi} \\ &= \lim_{\phi \rightarrow 0} \frac{\ln(\mathbf{R}_1\mathbf{R}_2^{-1})^{\vee} + \mathbf{J}_r^{-1} (-\mathbf{R}_2 \phi) - \ln(\mathbf{R}_1\mathbf{R}_2^{-1})^{\vee}} {\phi} \\ &= -\mathbf{J}_r^{-1}(\ln(\mathbf{R}_1\mathbf{R}_2^{-1})^{\vee}) \mathbf{R}_2 \end{aligned}\]
Read More

^