1, Download Raspbian Jessie Lite Image

2, Clone from Raspbian SD Image

3, Resize Partition Size of SD Card

5, Setup Raspbian

4, Install Required Packages

5, Add user, pi, for Machinekit

6, Enable SPI device

6, Build Packages from Source

pigpio

ar-tools

libwosi

libbacktrace

machinekit

build binary package

build from source

Remote UI

Use AXIS to debug Machinekit

7, Build ROS from Source

ROS-Industrial

8, GANTRY Demo

This does NOT support RPi3


Build Machinekit with Raspbian Jessie

1, Download Raspbian Jessie Lite Image

2, Clone from Raspbian SD Image

sudo ddrescue --sector-size=4M --force <raspbian-jessie.img>  </dev/sdc> # assume sd card is at /dev/sdc

3, Resize Partition Size of SD Card

sudo parted /dev/sdc

print # display partition table

resizepart 2 # End at 3700MB for 4GB SD, or 15.25GB for a 16G SD card

quit

sudo e2fsck -f /dev/sdc2

sudo resize2fs /dev/sdc2

5, Setup Raspbian

Boot up Raspbian from SD Image

login: pi

password: raspberry

sudo raspi-config

  1. Internationalization => Change Keyboard Layout => Generic 105 Key => Englist (US), change from UK to US
  2. Internationalization => Change wi-fi country
  3. Boot option => Wait for network at boot => disable
  4. Boot option => Console Auto-login

4, Install Required Packages

Install required packages

sudo su -

apt-get update

apt-get dist-upgrade -y

apt-get install -y git-core bash-completion tofrodos python-zmq python3-zmq libjansson-dev git dpkg-dev libudev-dev cmake libconfuse-dev swig python-dev libboost-all-dev ntp automake bc nfs-kernel-server nfs-common check nfs-kernel-server nfs-common bwidget kernel-package dphys-swapfile cython vim-gtk libcanberra-gtk-module tofrodos git-core git-cola bash-completion gnuplot-qt blueman xinput openssh-server screen python-avahi doxygen libdw-dev python-pyinotify fakeroot build-essential ncurses-dev libtool curl cpufrequtils debhelper dpkg-dev devscripts equivs libgnomeprintui2.2  python-configobj python-glade2 python-gst0.10 python-gtkglext1 python-gtksourceview2 python-imaging-tk python-vte python-xlib tcl-tclreadline wireless-regdb iw crda firmware-realtek firmware-ralink firmware-brcm80211 libnss-mdns sudo pkg-config xauth sudo apt-utils ntpdate binfmt-support netplug apt-show-versions xcompmgr libgl1-mesa-dri consolekit rpi-update python-netaddr

sudo locale-gen "en_US.UTF-8"

sudo dpkg-reconfigure locales # check en_US.UTF-8, and others such as, zh_CN.UTF-8, zh_TW.UTF-8

locale -a # list available locales

sudo rpi-update # to update firmware

Install 3rd party packages

sudo -s

echo deb http://deb.dovetail-automata.com jessie main > /etc/apt/sources.list.d/machinekit.list

apt-get update

apt-get install -y --force-yes dovetail-automata-keyring

apt-cache showpkg libczmq-dev

apt-cache showpkg libczmq2

apt-get install libczmq2=2.2.0-0.6~1jessie~1da

apt-get install libczmq-dev=2.2.0-0.6~1jessie~1da

apt-mark hold libczmq2 libczmq-dev # hold this version for Debian Jessie

apt-get install -y libwebsockets-dev

這兩個版本的 binary 安裝檔,也放在 machinekit/raspbian/jessie/ 目錄內

http://www.machinekit.io/docs/getting-started/APT-packages-jessie/  (This is for Debian Stretch)

Increase swap file size to 512MB for compiling software

sudo gvim /etc/dphys-swapfile

CONF_SWAPSIZE=512

ntp settings (reference)

Just commented out three lines in /etc/init.d/ntp to fix the problem:

#  if [ -e /var/lib/ntp/ntp.conf.dhcp ]; then

#         NTPD_OPTS="$NTPD_OPTS -c /var/lib/ntp/ntp.conf.dhcp"

#  fi

sudo systemctl stop ntp

sudo systemctl daemon-reload

sudo systemctl start ntp

ntpq -p # show connected ntp servers

For typical applications, remove SWAP file.

systemctl disable dphys-swapfile # close SWAP, confirm /var/swap removed, then reboot

set suid_dumpable; for Machinekit

sudo vim /etc/rc.local

echo 1 > /proc/sys/fs/suid_dumpable

Setting Time Zone

sudo rm /etc/localtime

sudo ln -s /usr/share/zoneinfo/Asia/Taipei /etc/localtime


5, Add user, pi, for Machinekit

sudo visudo

        %sudo   ALL=NOPASSWD: ALL

sudo adduser pi

sudo adduser pi sudo # add user(pi) to sudo group

sudo adduser pi dialout # add to dialout group

sudo adduser pi root # add to root group

sudo adduser pi adm # add user(pi) to adm group

logout and login as ‘pi’ for the following operations

# setup permission for dbus/consolekit to shutdown machine

sudo vim /var/lib/polkit-1/localauthority/50-local.d/custom-actions.pkla

[Actions for pi user]

Identity=unix-user:pi

Action=org.freedesktop.upower.*;org.freedesktop.consolekit.system.*;org.freedesktop.udisks.*

ResultAny=yes

ResultInactive=no

ResultActive=yes


6, Enable SPI device

Enabling The SPI Interface On The Raspberry Pi

sudo vim /boot/config.txt # and add:

dtparam=spi=on

After reboot, there should be /dev/spidev0.0 and /dev/spidev0.1

6, Build Packages from Source

pigpio

mkdir -p ~/proj/; cd ~/proj

git clone https://github.com/joan2937/pigpio

make -j2

sudo make install

ar-tools

mkdir -p ~/proj/; cd ~/proj

git clone git@github.com:araisrobo/ar-tools.git

git checkout rpi2

cd rpi2_fpga

make

ar11_fpga.sh # load FPGA bit-file

libwosi

mkdir -p ~/proj; cd ~/proj

git clone git@github.com:araisrobo/libwosi.git

cd libwosi

git checkout rpi2-spi

git checkout bbb-spi

./autogen.sh

dpkg-buildpackage -b -us -uc

sudo dpkg -i ../libwosi-dev_2015-04-29_armhf.deb ../libwosi_2015-04-29_armhf.deb

libbacktrace

cd ~/proj

Installation instructions:https://github.com/mhaberler/libbacktrace

git clone https://github.com/mhaberler/libbacktrace.git

machinekit

cd ~/proj

git clone git@github.com:araisrobo/machinekit.git

cd machinekit

git checkout -b rpi2-spi

# to add upstream repository

git remote add upstream https://github.com/machinekit/machinekit

git checkout master

git pull upstream master

./debian/configure -p # enable POSIX

sudo mk-build-deps -ir

build binary package

dpkg-buildpackage -b -us -uc -j2         # generated packages are at ../machinekit*deb

cd ../

sudo dpkg -i machinekit*deb         # install binary packages

  1. 問 rtapi.ini 是否更新時選 Y,用新設定蓋掉舊設定
  2. 安裝完之後要修改 /etc/linuxcnc/machinekit.ini 的內容
  1. MKUUID 要更新
  2. REMOTE=1
  1. sudo chmod 4755 /usr/bin/wosi_trans

build from source

cd src

./autogen.sh

./configure --with-posix --enable-build-documentation=no

make -j2

sudo make setuid

Remote UI

Within the same LAN of each  Machinekit you can only have one  MKUUID: Remote UI

gvim ~/proj/machinekit/etc/linuxcnc/machinekit.ini

Update the MKUUID setting with the results from running uuidgen

mkdir ~/proj/remote-ui; cd ~/proj/remote-ui

git clone git@github.com:araisrobo/RA605face.git

Use AXIS to debug Machinekit

ar11_fpga.sh # Will test that installation was a success and display “config success !”

export FLAVOR=posix

linuxcnc <ini-file>

ps -Leo pid,tid,class,rtprio,stat,comm,wchan | grep `pidof rtapi:0`

Machinekit-Build-for-Multiple-RT-Operating-Systems#options-to-the-realtime-script

debugging RT components

7, Build ROS from Source

  1. Installing ROS Indigo on the Raspberry Pi
  2. sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu jessie main" > /etc/apt/sources.list.d/ros-latest.list'
  3. wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add -
  4. sudo apt-get update
  5. sudo apt-get upgrade
  6. sudo apt-get install python-pip python-setuptools python-yaml python-distribute python-docutils python-dateutil python-six
  7. sudo pip install rosdep rosinstall_generator wstool rosinstall
  8. sudo rosdep init
  9. rosdep update
  10. sudo chown -Rf pi:pi /opt
  11. mkdir ~/ros_catkin_ws
  12. cd ~/ros_catkin_ws
  13. rosinstall_generator robot --rosdistro indigo --deps --wet-only --tar > indigo-robot-wet.rosinstall
  14. wstool init src indigo-robot-wet.rosinstall
  15. install collada-dom-dev
  • Change  ‘Name’ to collada-dom-dev
  • Do you want me to list them?  [n]: => ENTER
  • Should I exclude them from the package?  [n]: => yes ENTER
  1. patch collada_urdf.cpp
  1. cd ~/ros_catkin_ws
  2. rosdep install --from-paths src --ignore-src --rosdistro indigo -y -r --os=debian:jessie
  3. ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/indigo  -j2 -l2
  4. source /opt/ros/indigo/setup.bash

ROS-Industrial

  1. cd ~/ros_catkin_ws
  2. sudo apt-get install python-pyassimp python-lxml
  3. rosinstall_generator industrial_core moveit_ros_planning_interface moveit_planners_ompl moveit_simple_controller_manager --rosdistro indigo --deps --wet-only --exclude roslisp --tar > indigo-industrial.rosinstall
  4. wstool merge -t src indigo-industrial.rosinstall
  5. wstool update -t src
  6. rosdep install --from-paths src --ignore-src --rosdistro indigo -y -r --os=debian:jessie
  7. ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/indigo -j1

8, GANTRY Demo

  1. bootup with HDMI+Keyboard+Mouse
  2. login: pi, password: …..
  3. sudo vim /etc/wpa_supplicant/wpa_supplicant.conf # setup your WLAN password
  4. sudo /sbin/reboot
  5. ssh pi22 # connect pi22 from your PC
  6. gantry
  7. . go.sh
  8. terminal : ctrl-shift-t