Extended Karman Filter

Zhenglei 2018 January

This is a project to estimate the car position from Lidar data and Radar data. Lidar data is using Kalman filter. Radar data is using Extended Karman filter, because the radar data is provided by non-linear data(rho, rho-dot, phi). Then we put the two types of sensor data together, and get an more accurate estimate. The solution is so called sensor fusion.

The following gif picture is record from the simulator.

  • Blue circle: radar measurement
  • Red circle: laser measurement
  • Green circle : EKF estimated position

1.Create the enviroment for carnd-term2

I don't have an mac, and my working PC is install windows7

So, this is the options

  1. windows7 professinal + vmware(ubuntu), not work
  2. windows7 professinal + docker, not work
  3. pure ubuntu, it works

    ... I haven't test

So, this is the suggestion, if you are using windows7. Don't try anything on it. It will waste your time.

Buy a computer or borrow a computer, then install ubuntu (16.4 is the version use)

2. From a empty computer to run the code with Simulator

2.1 install ubuntu

   (PreRequirment: you already have another windows PC)

   on the windows pc:

   1)down ubuntu from https://www.ubuntu.com/download/desktop

   2)this installation guide: https://tutorials.ubuntu.com/tutorial/tutorial-create-a-usb-stick-on-windows#0

   3)create a bootable USB flash disk include ubuntu image, using Rufus :https://rufus.akeo.ie/

   on the empty linux comupter:

   1) boot the computer using the USB flash disk

   2) install linux

2.2 download project from github

https://github.com/udacity/CarND-Extended-Kalman-Filter-Project

2.3 install uWebSocket

uWebSocket is software to connect our C++ program and the simulator.

In the project folder, execute sudo sh ./install-ubuntu.sh

This command will installed uWebSockets.

2.4 download simulator

term2_sim.x86_64, download it from https://github.com/udacity/self-driving-car-sim/releases/

hins:

  1. add execute permission to the file sudo chmod -c 777 <your file name>
  2. The simulator may corrupt sometimes, so unzip it from the download file, or download it again

2.5 install anaconda and jupyter notebook

The python jupyter notebook is used for analyze the output log file.

check conda version

conda --version

If you computer don't have anaconda, then you could download anaconda or miniconda. Any of them is OK.

miniconda is about 50M. Download from:

https://conda.io/miniconda.html

anaconda is about 500M. Download from:

https://www.anaconda.com/download/#linux

Then install it,

  • miniconda

    bash Miniconda3-latest-Linux-x86_64.sh
  • anaconda

    bash Anaconda-latest-Linux-x86_64.sh

I use the enviroment from udacity Carnd-term1

https://github.com/udacity/CarND-Term1-Starter-Kit/blob/master/doc/configure_via_anaconda.md

Set the enviroment like this:

git clone https://github.com/udacity/CarND-Term1-Starter-Kit.git
cd CarND-Term1-Starter-Kit

Then run these commands, will create an conda enviroment, include the libraries we need.

conda env create -f environment.yml

If conda download these package too slow, you can use other channels instead. Edit your environment.yml file.

channels:

- https://conda.anaconda.org/menpo

- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/

- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

- conda-forge

Activate the enviroment

source activate carnd-term1

Then get into the jupyter notebook

jupyter notebook

3. Install some usefull software (optional)

3.1 Install chrome in ubuntu

   (If you like, the firefox is good enough also)

https://www.cyberciti.biz/faq/how-to-install-google-chrome-in-ubuntu-linux-12-xx-13-xx/

3.2 Install uGet download tools

If you want download something big in linux, you may need a download tool.

The uGet website: http://ugetdm.com/downloads-ubuntu

Install uget using command line

sudo add-apt-repository ppa:plushuang-tw/uget-stable
sudo apt update
sudo apt install uget

Then, install aria2 plugin for uGet

sudo apt install aria2

After these, search uGet in ubuntu search bar, you will found uGet.

3.3 Haroopad markdown editor

download from this site: http://pad.haroopress.com/user.html

Your downloaded Haroopad package could be an deb package. How to install an deb package?

sudo dpkg -i xxxx.deb

4.Data Flow

  1. The measuremennt processor/matlab simulator is generating the FUSION .txt file:

    "data/obj_pose-laser-radar-synthetic-ukf-input.txt";

    OR

    "../matlab_examples/obj_pose-laser-radar-synthetic-ukf-input.txt";

The Input file format is:

L(for laser) meas_px meas_py timestamp gt_px gt_py gt_vx gt_vy (gt is ground truth)

R(for radar) meas_rho meas_phi meas_rho_dot timestamp gt_px gt_py gt_vx gt_vy (gt is ground truth)

Example:

R 8.60363 0.0290616 -2.99903 1477010443399637 8.6 0.25 -3.00029 0

L 8.45 0.25 1477010443349642 8.45 0.25 -3.00027 0

  1. The EKF Algorithm reads form file reads all the lines and generates measurement structures

  2. The MeasurementProcessor() is called with individual measurements (one by one). The results are saved

    (Attention: no file processing routines are used inside MeasurementProcessor() all the file processing routines are in the main function.

    So the data read/write is decoupled from the algorithm

  3. The results are saved in an output file:

    "data/obj_pose-laser-radar-ekf-output.txt"

Output file format:

est_px est_py est_vx est_vy meas_px meas_py gt_px gt_py gt_vx gt_vy

Example:

4.53271 0.279 -0.842172 53.1339 4.29136 0.215312 2.28434 0.226323

43.2222 2.65959 0.931181 23.2469 4.29136 0.215312 2.28434 0.226323

5.CMakeLists.txt

There is nothing need to change in the CMakeLists.txtx

6.Program structure

overview of the formular

Tools.h

define a class named "tools" , and 2 method:

  • CalculateRMSE
  • CalculateJacobian

Tools.app

Implementation of the 2 method.

measurement_package.h

Defines a class called "MeasurementPackage".

It include the data of a measurement.

Kalman_filter.h

Defines a class named "KalmanFilter"

The class include some data

  • x_ state vector
  • P_ covariance matrix
  • F_ state transition matrix
  • Q_ process covariance matrix
  • H_ measurement matrix
  • R_ measurement covariance

The class defined some method

  • Init: initializes Kalman filter
  • Predict :predicts the state and state covariance, using the process model
  • update :update the state by using standard Kalman Filter equations.
  • updateEKF :update the state by using Extended Kalman Filter equations.

Kalman_filter.cpp

Implementation the method defined by Kalman_filter.h

FusionEKF.h

Head file of FusionEKF.cpp

Define a class called FusionEKF

Define a method ProcessMeasurement, a public KalmanFilter

FusionEKF.cpp

Implementation the method difined by FusionEKF.h

Main.cpp

  • Check_arguments: I add an option to the program, select fusionoronlyRadaroronlyLidar
  • hasData:
  • main:

       - write logfile, depend on the option you select.The logfile could be log_fusion.txt or log_onlyRadar.txt or log_onlyRidar.txt.

       - using uWS to communicate with Simulator.

       - calculate RMSE(root mean squre error) between estimations and ground truth.

       - Json is the message type, send to, or receive from the simulator.

       - extrac variables form istringstream, and put them into

       - Call ProcessMeasurment(meas_package) for Kalman filter

       -

7 Compile and run

  • mkdir build
  • cd build
  • cmake ..
  • make
  • ./ExtendedKF fusion
  • Download simulator term2_sim.app (if in OSX) and open it. Click play! bottom, select Project 1/2: EKF and UKF, and press Start bottom to start.

8. If your program can not run

Download the simulator again. Maybe the simulator is crash.

9. Analyze the Output data.

The analyze can be see in the build/analyz_log_file.ipynb. You can use jupyter notebook to open it.

This picture is the compare of RMSE. Obviously, the error is radar > lidar > fusion.

Outro

The course provide almost full of the code.

In my experience,

1)The hardest part is build a enviroment, at last I choose ubuntu linux platform.

2)If the simulator has no response, download it again, or extract it from the zip file.

Udacity carnd2 Sensor Fusion, Extended Karman Filter (English)的更多相关文章

  1. Sensor fusion(传感器融合)

    From Wikipedia, the free encyclopedia 来自维基百科,免费的百科Sensor fusion is combining of sensory data or data ...

  2. Kalman Filter、Extended Kalman Filter以及Unscented Kalman Filter介绍

    模型定义 如上图所示,卡尔曼滤波(Kalman Filter)的基本模型和隐马尔可夫模型类似,不同的是隐马尔科夫模型考虑离散的状态空间,而卡尔曼滤波的状态空间以及观测空间都是连续的,并且都属于高斯分布 ...

  3. Kalman filter, Laser/Lidar measurement

    You can download this project from https://github.com/lionzheng10/LaserMeasurement The laser measure ...

  4. (转) How a Kalman filter works, in pictures

    How a Kalman filter works, in pictures I have to tell you about the Kalman filter, because what it d ...

  5. 卡尔曼滤波—Simple Kalman Filter for 2D tracking with OpenCV

    之前有关卡尔曼滤波的例子都比较简单,只能用于简单的理解卡尔曼滤波的基本步骤.现在让我们来看看卡尔曼滤波在实际中到底能做些什么吧.这里有一个使用卡尔曼滤波在窗口内跟踪鼠标移动的例子,原作者主页:http ...

  6. probabilistic robotics_Kalman filter(一)

    码农生活告一段落,继续.... 多元正态分布 协方差矩阵,为正定对称矩阵.det表示行列式 协方差反应随机样本变量各分量之间的相关性. 当变量的假设模型不一致时,不适合用高斯滤波. 叠加高斯噪声的线性 ...

  7. LightOJ 1074 - Extended Traffic (SPFA)

    http://lightoj.com/volume_showproblem.php?problem=1074 1074 - Extended Traffic   PDF (English) Stati ...

  8. SQL Server Extended Events 进阶 3:使用Extended Events UI

    开始采用Extended Events 最大的阻碍之一是需要使用Xquery和XML知识用来分析数据.创建和运行会话可以用T-SQL完成,但是无论使用什么目标,数据都会被转换为XML.这个限制在SQL ...

  9. {ICIP2014}{收录论文列表}

    This article come from HEREARS-L1: Learning Tuesday 10:30–12:30; Oral Session; Room: Leonard de Vinc ...

随机推荐

  1. Tomcat分析-启动过程

    Server是Tomcat最顶层的容器 Service用于提供服务 Connector用于处理连接相关的事情,并提供Socket与request和response的转换 Container用于封装和管 ...

  2. 阿里云 Ubuntu16.04 部署 LAMP

    1.更新软件源 sudo apt-get update 2.安装Apache sudo apt-get install apache2 3.查看Apache是否安装成功 apache2 –v 如下所示 ...

  3. java不可见字符 trim

    trim()的作用去掉前后的空格,  但是解析excel,出现一个字符串trim之后还是有”空格“ 做了一下实验,原来一些不可见的字符不一定是“空格”, trim()也去不掉, 只能自己写方法了

  4. c++ primer 中讲的顶层const 和 底层 const 理解

    c++ primer 中讲的    顶层const 和 底层 const   以前没搞懂的顶层const和底层const,这次看了后感觉明白了. 首先,const是一个限定符,被它修饰的变量的值不能改 ...

  5. JVM架构_XmnXmsXmxXss有什么区别:转

    1.XmnXmsXmxXss有什么区别 首先,Xmn.Xms.Xmx.Xss都是JVM对内存的配置参数,我们可以根据不同需要区修改这些参数,以达到运行程序的最好效果. 了解jvm内存管理看这里:jvm ...

  6. Oracle SQL Tuning Advisor 测试

    如果面对一个需要优化的SQL语句,没有很好的想法,可以先试试Oracle的SQL Tuning Advisor. SQL> select * from v$version; BANNER --- ...

  7. Oracle安装后忘记用户名或密码+创建新登陆用户

    新安装的Oracle11g,不料在使用的时候没记住安装时的用户名和密码. 不用担心,打开sqlplus. 按如下步骤,新建一个登陆用户: 第一步:以sys登陆  sys/密码 as sysdba  此 ...

  8. [巩固C#] 三、依赖注入是什么?

    阅读目录   接口 在说依赖注入之前,先了解下什么是接口. 我们在学编程的时候都知道,接口的相关规则:(来源百度百科) 1. 接口是一个引用类型,通过接口可以实现多重继承. 2. C#中接口的成员不能 ...

  9. mysql 将null转代为0(转)

    1.如果为空返回0 select ifnull(null,0) 2.如果为空返回0,否则返回1 select if(isnull(col),0,1) as col. MYSQL 中的IFNULL函数 ...

  10. 拼json对象批量向后台添加数据

    网站中如果遇到批量提交格式相同数据,可以使用json来传输 $("#catalogSave").click(function(){ var array=[]; $("[n ...