2019年9月2日 星期一

Git 學習 - git format-patch 和 git am 搬移資料

透過 git format-patch 來產生一連串的 patch 檔案, 接着透過 git am 來匯入並加入每一個 patch
這功能對於 repo 搬移資料, 非常強大也非常方便 (不需要自己手動匯入每一筆 patch)

  • 製作 Patch

    `git format-patch --root -o ./patches`

    從第一筆 commit 開始產生 Patch 檔案, 輸出到 patches 資料夾底下

    `git format-patch -2 -o ./patches`

    產生最近 2 筆 commit 的 patch 檔案, 輸出到 patches 資料夾底下

    `git format-patch f259d..93ee9 -o ./patches`

    產生指定範圍 coomit 的 patch 檔案, 輸出到 patches 資料夾底下




  • 匯入 Patch

    `git am --abort`

    取消前一次匯入動作, 並清除錯誤結果

    `git am ./patches`

    匯入 patches 資料夾底下所有的 patch 檔案

2019年8月26日 星期一

ROS 學習 - ROS 初次見面就上手

沒錯!今天就是要來講如何在 ubuntu 上安裝 ROS!但這要注意的是, 不同版本的 ubuntu系統需要對應不同的 ROS 版本, 所以這邊不要安裝錯誤 ROS 版本了.

ROS Melodic -> ubuntu Artful (17.10) 以及 Bionic (18.04) LTS
ROS Kinetic   -> ubuntu Wily (15.10) 以及 Xenial (16.04) LTS

我們就選擇 ROS Melodic 安裝在ubuntu Bionic 18.04 LTS

  1. ubuntu repositories 設定

    開始安裝 ROS 之前, 必須先設定好 ubuntu repositories唷. 在 Software & Updates 設定, 必須開啟 “restricted”, "universe", 以及 "multiverse" 選項.

  2. 設定 Sources.list

    接着我們必須告訴 ubuntu 要去哪裡下載, 所以利用下面指令設定 sources.list

    sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

  3. 設定金鑰

    由於檔案伺服器需要有認證機制, 因此我們也必須設定好金鑰. 下面指令可以設定好金鑰

    sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

  4. 安裝 ROS

    終於可以開始安裝!?不, 安裝之前, 必須確定好 ubunut package 指引是否更新了

    sudo apt-get update

    選擇相對應版本的 ROS, 這次我們選擇是 ROS Melodic Desktop-Full Install (包含了 ROS, rqt, rviz, robot-generic library, 2D/3D simulator 和 2D/3D perception 這樣可以省去以後麻煩 lol)

    sudo apt-get install ros-melodic-desktop-full

  5. 初始化 rosdep

    經過一陣子安裝時間, 相信大家都順利安裝完成了. 接着我們來安裝 rosdep
    rosdep 可以幫助我們往後解決 compile source code 相依性問題. 必裝!

    sudo apt-get install python-rosdep
    sudo pip install -U rosdep

    安裝完 rosdep 後, 就來初始化 rosdep 並更新 rosdep package index.

    sudo rosdep init
    rosdep update

  6. 環境設定

    終於來到最後一步了!為了省去以後需要手動設定 ROS 環境變數, 我們就把它設定到 .bashrc 下,
    如此一來, 我們就不用每次開機都需要重新設定了 \O/

    echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
    source ~/.bashrc

  7. 系統相依性套件

    這邊建議大家, 可以順便安裝一些往後會用的套件

    sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential



    Reference : http://wiki.ros.org/melodic/Installation/Ubuntu
    Reference : https://help.ubuntu.com/community/Repositories/Ubuntu
    Reference : http://wiki.ros.org/rosdep
    Reference : http://wiki.ros.org/action/show/TestingRepository?action=show&redirect=ShadowRepository

2019年8月25日 星期日

ubuntu - ubuntu 18.04 中文輸入法

因為 ubuntu 內建並沒有中文輸入法, 因此你必須自己安裝...Orz
那今天就來講如何安裝中文輸入法吧
  1. 使用 iBus 當作 Keyboard input method
    sudo apt-get install ibus-sunpinyin



    Note : 當然你可以使用其他 Keyboard input method, 像是 gcin, fcitx, 但記得需要安裝相對應的中文輸入法
  2. Language Support -> 安裝中文語言 (設定完成, 需要Logout唷)


  3. Region & Language -> 新增 Chinese (Bopomofo)





  4. 最後記得設定為繁體中文, 除非你想用簡體中文




2014年9月14日 星期日

How about Holography + HUD (Head Up Display) ?

How about Holography + HUD (Head Up Display) ?

Now HUD is more and more popular! Not just for military but also applied to mobile car, such as HUDWAY (apps), Garmin HUD and etc. I think this kind of products are great and valuable. When I drive a car, I don't wanna look down to check my velocity、gasoline or something. It is annoying. So I will make some experiments for my HUD. This might combined with the holography, trying to make everything in 3D. The two videos below are just for finding a idea what to do and how to do. If you have any idea of my new project, if you would like, please let me know. And maybe we could collaborate for a totally new and amazing HUD :)







2014年9月3日 星期三

Cross Compiler for Raspberry Pi

Speaking to embedded system, you have to know about cross compiler, toolchain and CMake. Cross Compiler is a compiler which could create the executable code for a platform other than the one which the compiler is running. You don't want to compile your huge source code on the embedded system where maybe took lots of time. In order to set up the environment, toolchain consisting of a compiler and linker could transform the source code into a executable program, libraries to provide interfaces to the operating system and a debugger. In this case, CMake will help you figure out the environment of the platform via toolchain. Basically, you could compile your source code to executabl program which could execute on the Raspberry Pi by these three main tools. It will save your lots of time and more convenient for further processing. Let's see how it works.

Before the beginning of the process, make sure that you have install CMake, git, rsync 
(sudo apt-get install cmake git rsync)

Install Cross Compilation toolchain
At first, you have to download a pre-built cross compilation tool chain for a slightly different version of gcc and libc :




And install the toolchain by adding the environment variable. 
sudo nano ~/.bashrc  and add below line at the end of file.
export PATH=$PATH:/home/gtossk2/Desktop/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin










(After that, you enter "ar" characters and enter tab twice. You see something like arm-linux-gnueabihf-gcc which means successfully intallation.)


Make Raspberry Pi development files (header files, libraries) available on the host
mkdir mnt_rpi and cd mnt_rpi    Now tell rsync to copy the entirely of the /usr and /lib directories of the Raspberry Pi file system into the newly created folder on your computer.






After that, there is a important thing to be done. The files /usr/lib/arm-linux-gnueabihf/libc.so and /usr/lib/arm-linux-gnueabihf/libpthread.so are actually linker scripts refer to absolute paths, which are incorrect when cross compiling. Please remove the absolute path from linker script.

For example :
Becomes :





Make a cmake toolchain file for cross compilation
Now create a toolchain for cmake to set up the environment. Name it as Toolchain-RaspberryPi.cmake in path/rpi

For example :















Cross compile on Ubuntu
Now you can use Toolchain-RaspberryPi.cmake for cross-compiling.
For example :

Note : you have to set CMAKE_EXE_LINKER_FLAGS cause arm-linux-gnueabihf-ld could not recognize the sysroot. You have to set --sysroot=/home/gtossk2/Desktop/rpi/mnt_rpi for CMAKE_EXE_LINKER_FLAGS


Or you will get some linker errors :


Run on the Raspberry Pi
Using scp to transfer the executable file to Raspberry Pi and execute it on Raspberry Pi. See how it works. 






Reference:



2014年9月2日 星期二

Setting DHCP Server for Raspberry Pi

DHCP stands for Dynamic Host Configuration Protocol. That is an standardized networking protocol used on Internet Protocol (IP) networks for dynamically distributing network configuration parameters, such as IP address for interfaces and services. There are  two general purposes for

  • Automatically distributing IP address to users from local area network or ISP
  • A centralized management for all computers within local area network
In order to control my humanoid robot remotely, DHCP sounds a great idea. I could set up the DHCP server on raspberry pi and plugin RJ45 on both computers. It allows to remote command-line login via SSH (Secure Shell) and transfer a file via SCP (Secure Copy). It is very helpful for program and debug.
So let's see how to make it out !!

A popular DHCP server for Raspberry Pi is ISC's dhcpd. You can install the package in a normal way using apt-get (Before it, make sure to update the local package cache using apt-get update)


The DHCP server requires a static IP address and by default, the Pi will have a DHCP one.  Edit /etc/network/interfaces


And modify the records that pertain to eth0 using the network parameters for your network


Edit /etc/dhcp/dhcpd.conf 
The configuration file to suit your requirements. All of the main configuration items are commented out and this is why the startup failed previously.




Edit /etc/default/isc-dhcp-server and uncomment the following records, inserts your network interface name as appreciate and changing the file path if you have chosen to put the file somewhere.


Finally, restart the DHCP daemon process using service command (Make sure to plugin the RJ45 before restart DHCP daemon)



Reference :


2014年8月28日 星期四

The Way To A Humanoid Robot (2)

Yesterday I had finished the heart of the humanoid robot. So now I am about to assemble the robot with my dirty hand...I really enjoy it :)
Due to the bad design that I didn't consider the assembling process, it is very hard to tight the screw. Poor me. I will think about everything twice before sending the blue print to the factory next time. I am just too careless :P There is one thing important before assembling the robot. That is you need to calibrate every servo to be center. It is very important, or you will get.....a poorly discipline robot. Be careful !!!
Let's see today's result !! Pretty cool !! I love it !!
Yup I don't have too much time to finish its head and arms. I will finish them next two day!!