2014年12月7日 星期日

Installing UBUNTU without finding SATA HD

Installing UBUNTU without finding SATA HD
Reference from
http://www.pendrivelinux.com/ubuntu-installer-cant-find-my-sata-drive/

How I made Ubuntu Installer detect my SATA drive

Boot Ubuntu from a Live CD or Live USB
Open a Terminal (Applications > Accessories > Terminal) and type sudo su
Type fdisk -l (note which device is your SATA drive)
Type dmraid -E -r /dev/sdX
(Replacing X with your actual device found in step 3)
Confirm that yes, you wish to remove the dmraid information
Return to the desktop and proceed to run the Ubuntu Installer

2014年11月3日 星期一

install rce in ubuntu14.04+ROS indigo with Anaconda python

~/rce$ sudo ./install.sh
會將rce相關套件裝到 /usr/local/lib/python2.7/dist-packages中
如要使用安裝在~/anaconda中的python會找不到rce相關套件
所以
~/rce$ ./setup/provision all
會import不到RCE套件

因此可以用以下兩種方式(擇一即可):
1. 將/usr/local/lib/python2.7/dist-packages中的相關套件與.pth檔複製到
    ~/anaconda/lib/python2.7/site-packages中
2.修改或新增.pth檔到~/anaconda/lib/python2.7/site-packages將相關的RCE egg指到
/usr/local/lib/python2.7/dist-packages
如:
/usr/local/lib/python2.7/dist-packages/rce_util-0.3-py2.7.egg
/usr/local/lib/python2.7/dist-packages/rce_comm-0.3-py2.7.egg
/usr/local/lib/python2.7/dist-packages/autobahn_rce-0.6.0.5-py2.7-linux-x86_64.egg
/usr/local/lib/python2.7/dist-packages/Twisted-14.0.2-py2.7-linux-x86_64.egg
/usr/local/lib/python2.7/dist-packages/rce_core-0.3-py2.7.egg
/usr/local/lib/python2.7/dist-packages/python_iptables-0.5.0-py2.7-linux-x86_64.egg
/usr/local/lib/python2.7/dist-packages/rce_client-0.3-py2.7.egg
/usr/local/lib/python2.7/dist-packages/rce_console-0.3-py2.7.egg

如有缺少zope.interface套件
可用 pip install zope.interface安裝

而RCE只支援到UBUNTU 13.04 + ROS hydro
如要使用UBUNTU 14.04 + ROS indigo需要修改provision檔
可將版本改掉
in my case: 
using 'tursty' to substitute 'Raring'
using 'indigo' to substitute 'hydro'
remove openvswitch-brcompat in _HOST_PKGS , becouse it cannot find it in ubuntu 14.04 and some one say ubuntu 14.04 for OVS don't need that.

http://openvswitch.org/



2014年10月30日 星期四

VC++ 2012 opencv error "0xc0000005讀取位置0x00000000時發生存取違規"

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <opencv/cv.h>

using namespace cv;
using namespace std;

int main( int argc, char** argv ){
    Mat image;
    image = imread("1.jpg");
    namedWindow( "show window", CV_WINDOW_AUTOSIZE );
    imshow( "show window", image );
    waitKey(0);
    return 0;
}

應該是沒找到圖檔
建置VC++空專案時不要為方案建立目錄
將圖檔放在專案資料夾即可找到圖
x64系統
組態管理員->新增x64平台(來源複製Win32,勾選建立新專案平台

2014年10月15日 星期三

replace string in files

if we want to replace some strings in files of a folder, we can use find, xargs and sed.
for example, i want to change string '/opt/anaconda' to 'home/robot2/anaconda in many files of '/home/robot2/anaconda/bin'.
first, go to the folder
$ cd /home/robot2/anaconda/bin
then, find all files to replace the string
$ find * | xargs -i sed -i 's/\/opt\/anaconda/\/home\/robot2\/anaconda/g' {}
where '/' needs '\' to escape

2014年8月19日 星期二

UBUNTU Hardware Enablement Stack (HWE) out of support & rviz segmentation fault

安裝12.04.5 LTS 更新 Hardware Enablement Stack (HWE)後螢幕黑掉,
原來是我加裝的顯卡7V7300GS可能太舊沒有支援。
使用原本主機板上的顯示晶片就可以了。

另外,在更新前使用ROS rviz 執行時會發生的
#rosrun rviz rviz
compiled against OGRE version 1.7.4 (Cthugha)
segmentation fault (core dumped)
也消失了

不過後來rviz又出現令一個錯誤
Ogre::RenderWindow* rviz::RenderSystem::makeRenderWindow(intptr_t, unsigned int, unsigned int): Assertion `false' failed.

我想是之前顯卡的驅動做怪,找到網路上有人這麼做

sudo apt-get purge nvidia-*
sudo rm /etc/X11/xorg.conf # if the file does not exist , then is OK
sudo apt-get install nvidia-common ubuntu-desktop
sudo apt-get install --reinstall xserver-xorg-video-nouveau
sudo dpkg-reconfigure xserver-xorg
sudo reboot

重開機後 rviz is working

2014年8月1日 星期五

python virtualenv packages path not found

I practice to install django with virtualenv in windows.
When i type "django-admin.py startproject mysite", 
it can not import django.core and the error message is    
" from django.core import management
ImportError: No module named django.core"

find the solution from below link

This is because, it still use the python.exe in default (C:\python27) not the python.exe in my virtualenv (D:\venv\Scripts).

using the ftype to check the Python.file
D:> ftype Python.file

using the ftype to change the Python.file
D:\ftype Python.file = "D:\venv\Scripts\python.exe" "1%" %* 

2014年6月9日 星期一

programing for kid

Blockly
https://code.google.com/p/blockly/

Snap
http://snap.berkeley.edu/

Scratch
http://scratch.mit.edu/

Alice
http://www.alice.org/index.php

2014年3月25日 星期二

weka3.6 with LibSVM

Step 1: download LibSVM
https://github.com/cjlin1/libsvm

Step2: unzip the zip file libsvm-master.zip,
  and then find the libsvm.jar in /where you unzip/libsvm-master/java

Step3: copy libsvm.jar into your Weka folder
  ex: in my path is D:\Weka3-6\

Step4: set up the CLASSPATH in your environment or in RunWeka.ini
in your environment
  in Windows:
    In the Control Panel click on System (or right click on My Computer and select Properties) and then go       to the Advanced tab. There you will find a button called Environment Variables, click it.
    Enter the "CLASSPATH" for the variable and add this value "D:\Weka3-6\libsvm.jar" after ";" if you have     other values in CLASSPATH

  DOS command:
    set CLASSPATH=%CLASSPATH%;D:\Weka3-6\libsvm.jar;

  in Linux:
    export CLASSPATH=$CLASSPATH: where your libsvm.jar
    if i put it in /home/user
    export CLASSPATH=$CLASSPATH:/home/user/libsvm.jar

in RunWeka.ini:
  in Windows:
    open RunWeka.ini with any text editor, you can find
    cp=%CLASSPATH%; in the last line
    add your path of libsvm.jar after ";"

    cp=%CLASSPATH%;D:\Weka3-6\libsvm.jar
    or
    cp=%CLASSPATH%;./libsvm.jar


2014年2月26日 星期三

#define in C is expands textually

#include<stdio.h>
#define square(x) x*x
main() 
{
    int x = 2;
    printf("%d\n", square(x + 1));
    return 0;
}

The answer is 5 not 9, because the preprocessor expands it textually like below.

x * x = 2+1 * 2+1 = 2+(1*2)+1=2+2+1=5
That is not function. We can fix it as

#define square (x) (x)*(x) 
or
#define square (x) ((x)*(x)) 


Using Sparse ARFF files as the input of weka association rule

the format is as below test.arff

 @relation test
 @attribute a {y}
 @attribute b {y}
 @attribute c {y}
 @attribute d {y}
 @attribute e {y}
 @attribute f {y}
 @attribute g {y}
 @attribute h {y}

@data
{1 y,3 y,5 y}
{2 y,3 y,5 y}
{2 y,6 y}
{1 y,3 y,5 y}
{3 y,5 y,7 y}
{1 y,2 y,3 y}
{2 y,4 y,5 y}
{2 y,3 y,5 y}
{3 y,5 y,7 y}
{1 y,2 y}
{1 y,5 y,7 y}