Posts

Wednesday, 30 January 2019

Use Korean in Ubuntu 16.04

Use Korean in Ubuntu 16.04

 sudo apt-get install fonts-nanum*  
 sudo apt-get install nabi  
 sudo apt-get install im-config  
 im-config  

Change 'im-config' setting to Hangul and reboot!

Setting to use my gpu : NVIDIA graphic drivers / CUDA


Install NVIDIA Graphic Drivers

Find your NVIDIA driver on NVIDIA website and download it. I downloaded NVIDIA-Linux-x86_64-410.93. It should be installed without lightDM. You should open the TTY with ctrl + alt +f1 before you stop the lightDM. TTY's are text-only terminals commonly used as a way to get access to the computer to fix things, without actually logging into a possibly b0rked desktop.

 sudo service lightdm stop  
 chmod +x ./NVIDIA-Linux-x86_64-410.93  
 sudo ./NVIDIA-Linux-x86_64-410.93  
 sudo reboot  

Install CUDA 9.0 and cuDNN 7.0 on Ubuntu 16.04

Find CUDA version you want on NVIDIA website or if you are looking for the same version with me just follow me from the first row. If you downloaded a different one, start from the second row and change the file name as yours.

 # Uninstall Old Version  
 sudo apt-get purge cuda  
 sudo apt-get purge libcudnn6  
 sudo apt-get purge libcudnn6-dev  

 # Install CUDA toolkit 9.0 and cuDNN 7.0  
 wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb  
 wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb  
 wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb  
 wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl2_2.1.4-1+cuda9.0_amd64.deb  
 wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl-dev_2.1.4-1+cuda9.0_amd64.deb  

If you just formatted your desktop, you need to fo this before dpkg.

 sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub  

 sudo dpkg -i cuda-repo-ubuntu1604_9.0.176-1_amd64.deb  
 sudo dpkg -i libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb  
 sudo dpkg -i libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb  
 sudo dpkg -i libnccl2_2.1.4-1+cuda9.0_amd64.deb  
 sudo dpkg -i libnccl-dev_2.1.4-1+cuda9.0_amd64.deb

 sudo apt-get update  
 sudo apt-get install cuda=9.0.176-1  
 sudo apt-get install libcudnn7-dev  
 sudo apt-get install libnccl-dev  

Modify the PATH. Open '.bashrc' file and end two lines below.

 gedit .bashrc
 export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}  
 export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
 source .bashrc  

And then reboot your desktop.

 reboot  

Verify CUDA installation.

 jihyo@jihyo-desktop:~$ nvidia-smi  
 Wed Jan 30 15:19:03 2019      
 +-----------------------------------------------------------------------------+  
 | NVIDIA-SMI 410.48         Driver Version: 410.48          |  
 |-------------------------------+----------------------+----------------------+  
 | GPU Name    Persistence-M| Bus-Id    Disp.A | Volatile Uncorr. ECC |  
 | Fan Temp Perf Pwr:Usage/Cap|     Memory-Usage | GPU-Util Compute M. |  
 |===============================+======================+======================|  
 |  0 GeForce RTX 2070  Off | 00000000:01:00.0 On |         N/A |  
 | 0%  49C  P8  25W / 215W |  737MiB / 7944MiB |   2%   Default |  
 +-------------------------------+----------------------+----------------------+  
 +-----------------------------------------------------------------------------+  
 | Processes:                            GPU Memory |  
 | GPU    PID  Type  Process name               Usage   |  
 |=============================================================================|  
 |  0   1021   G  /usr/lib/xorg/Xorg              550MiB |  
 |  0   1581   G  compiz                    125MiB |  
 |  0   1980   G  ...uest-channel-token=15398769083618213155  59MiB |  
 +-----------------------------------------------------------------------------+  
 jihyo@jihyo-desktop:~$ nvcc -V  
 nvcc: NVIDIA (R) Cuda compiler driver  
 Copyright (c) 2005-2015 NVIDIA Corporation  
 Built on Tue_Aug_11_14:27:32_CDT_2015  
 Cuda compilation tools, release 7.5, V7.5.17  







Super Easy Way to Install Chrome on Ubuntu


Super Easy Way to Install Chrome on Ubuntu


 wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb

That's it.

Friday, 18 January 2019

Understanding Kalman Filter in case of 1D! (Super Easy)

Previous Story...

Kalman Filter

Kalman Filter is a type of Bayes Filter. It can be used only that has the estimator for the linear Gaussian case and the optimal solution for linear models and Gaussian distribution. Kalman Filter calculates the current position of the robot by recursive state prediction and correction. In state prediction, it is calculating the robot state with the state right before and its motion input. In the correction step, it checks the state prediction is reasonable or not with the sensor observation.

Kalman Filter in 1 Dimension

It is easy to understand in the case of 1 dimension. The mean and the covariance of the distribution can be gotten by just addition. 


In the prediction step, predict the next state by calculating with the robot's motion. Because it is only one dimension, it is already linear so the prediction can be gotten by just addition. Next, in the correction step, calculate new state with the observation of the sensor. This gaussian addition is quite difficult, you can read more here(The product of two Gaussian pdfs is not a pdfs, but it is Gaussian(a.k.a. loving algebra)).

Python Code

I made a simple code of these two steps in python.

# Kalman Filter 1Ddef correction(mean, var, sensor_mean, sensor_var):
    new_mean = (sensor_mean*var + mean*sensor_var)/(var + sensor_var)
    new_var = var*sensor_var/(var + sensor_var)
    return new_mean, new_var

def prediction(mean, var, motion_mean, motion_var):
    new_mean = mean + motion_mean
    new_var = var + motion_var
    return new_mean, new_var

There are two functions named 'correction' and 'prediction'. In 'prediction', input value 'mean' and 'var' are the previous state of the robot. Input value 'motion_mean' and 'motion_var' are the robot's motion.  In 'correction', input value 'mean' and 'var' will be the predicted value return by the function 'prediction'. Input value 'sensor_mean' and 'sensor_var' are the observation value by the sensor. The contents are same with above.

sensor = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
sensor_var = 2
motion = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
motion_var = 1
mean = 0var = 100

I set values like above.

for i in range(len(sensor)):
    # Step 1: State Prediction    mean, var = prediction(mean, var, motion[i], motion_var)
    print i
    print "- prediction -"    print "mean:%d var:%d" % (mean, var)
    # Step 2 : Correction    mean, var = correction(mean, var, sensor[i], sensor_var)
    print "- correction -"    print "mean:%d var:%d" % (mean, var)
    print '-------------------------------------------'


0
- prediction -
mean:1 var:101
- correction -
mean:1 var:1
-------------------------------------------
1
- prediction -
mean:2 var:2
- correction -
mean:2 var:1
-------------------------------------------
2
- prediction -
mean:3 var:2
- correction -
mean:3 var:1
-------------------------------------------
3
- prediction -
mean:4 var:2
- correction -
mean:4 var:1
-------------------------------------------
4
- prediction -
mean:5 var:2
- correction -
mean:5 var:1
-------------------------------------------
5
- prediction -
mean:6 var:2
- correction -
mean:6 var:1
-------------------------------------------
6
- prediction -
mean:7 var:2
- correction -
mean:7 var:1
-------------------------------------------
7
- prediction -
mean:8 var:2
- correction -
mean:8 var:1
-------------------------------------------
8
- prediction -
mean:9 var:2
- correction -
mean:9 var:1
-------------------------------------------
9
- prediction -
mean:10 var:2
- correction -
mean:10 var:1
-------------------------------------------

Process finished with exit code 0


Tuesday, 15 January 2019

Introduction to the Bayes Filter and Related Models

Previous Story ...

Introduction to the Bayes Filter and Related Models


As I mentioned above, the estimate the state x of a system given observations z and robot controls u. The Bayes filter is a framework for recursive state estimation.


There are two steps in Bayes filter, prediction and correction step.


In the prediction step, thanks to the recursive form, the state(t) can be estimated from the state(t-1). In the correction model, sensor - observation - will check that prediction is reasonable. We called the probabilistic models in the prediction model as a motion model and the one in the correction model as a sensor or an observation model. The Bayes Filter is a framework for recursive state estimation. So it is good to use the specialized Bayes Filter in each problem. Think about is it linear or nonlinear? Gaussian distribution only? Parametric or non-parametric? like those.



Motion Models

Robot motion is inherently uncertain. How can we model this uncertainty? We will specify a posterior probability that action u carries the robot from x to x'.


In practice, one often finds two types of motion models, odometry-based and velocity-based. 

Odometry Model

Odometry model is for systems that are equipped with wheel encoders. It is also called to the rotation-transformation-rotation model because the position of the robot is explained in terms of coordinates in cartesian coordinate and the angle. The robot position is (x_bar, y_bar, theta_bar) and it moves to (x_bar_prime, y_bar_prime, theta_bar_prime). The odometry information u is (delta_rot1, delta_trans, delta_rot2). Because it is on the cartesian coordinate, the odometry information can be explained like formula below.


Do not forget we are using probability distribution! So the noise in odometry is also shown as the probability distribution, for example, Gaussian noise.


Velocity-Based Model

Velocity-Based model is usually used when no wheel encoders are available. The robot position is (x_bar, y_bar, theta_bar) and it moves to (x_bar_prime, y_bar_prime, theta_bar_prime) and the velocity information u is (v, w).


But there is a problem in Velocity-based model. The robot has the final orientation because it moves on a circle. I introduce an additional noise term on the final orientation to fix this problem.

Sensor Model

The sensor model is used in the correction step to check the predicted belief is reasonable with the observation that the sensor detected.
  • Model for Laser Scanners
  • Beam-Endpoint Model
  • Ray-Cast Model
  • Model for Perceiving Landmarks with Range-Bearing Sensors

Introduction to SLAM

Let's start with a simple introduction to SLAM.

[ new blog ]

new blog https://jihyo-jeon.github.io/