hotch-potch, Note to self

いろいろ作業記録

ROSをRaspbianのパッケージからインストール

はじめに

RaspberryPiで、えいやぁとROSをインストールして、さっくり使うまでの手順です。

Raspbianのパッケージ群からインストールします。

(2019/8月現在、Kineticが入ります)

試した環境

~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 9.9 (stretch)
Release:        9.9
Codename:       stretch
~ $ uname -a
Linux raspiap 4.19.66+ #1253 Thu Aug 15 11:37:30 BST 2019 armv6l GNU/Linux

インストール

パッケージを指定してインストールします。

~ $ sudo apt install ros-desktop-python-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  adwaita-icon-theme at-spi2-core bzip2-doc bzr catkin cl-actionlib-msgs cl-diagnostic-msgs
(・・・略・・・)
Need to get 132 MB of archives.
After this operation, 668 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
(・・・略・・・)
Setting up ros-base-python-dev (1.7) ...
Setting up ros-viz-python-dev (1.7) ...
Setting up ros-robot-python-dev (1.7) ...
Setting up ros-desktop-python-dev (1.7) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Processing triggers for systemd (232-25+deb9u11) ...
Processing triggers for libgdk-pixbuf2.0-0:armhf (2.36.5-2+deb9u2) ...
~ $

インストール後の処理

rosdepのインストール

~ $ sudo rosdep init
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run

        rosdep update

~ $ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Add distro "crystal"
Add distro "dashing"
Add distro "eloquent"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Add distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
updated cache in /home/pi/.ros/rosdep/sources.cache
~ $ sync
~ $ 

catkinワークスペースの設定

~ $ mkdir -p ~/catkin_ws/src
~ $ cd ~/catkin_ws/src
~/catkin_ws/src $ catkin_init_workspace
~/catkin_ws/src $ cd ~/catkin_ws
~/catkin_ws $ catkin_make
Base path: /home/pi/catkin_ws
Source space: /home/pi/catkin_ws/src
Build space: /home/pi/catkin_ws/build
Devel space: /home/pi/catkin_ws/devel
Install space: /home/pi/catkin_ws/install
(・・・略・・・)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/catkin_ws/build
####
#### Running command: "make -j1 -l1" in "/home/pi/catkin_ws/build"
####
~/catkin_ws $ cd
 

bashrcの設定

.bashrcの末尾に、下記の内容を追加します。
(よく使うコマンドのエイリアスも入ってます)

~/catkin_ws $ 
~$ nano .bashrc 
(・・・略・・・)
#for ROS Development
source ~/catkin_ws/devel/setup.bash
alias cw='cd ~/catkin_ws'
alias cs='cd ~/catkin_ws/src'
alias cm='cd ~/catkin_ws && catkin_make'
export ROS_HOSTNAME=`/bin/hostname`
export ROS_MASTER_URI=http://${ROS_HOSTNAME}:11311

.bashrcを再読込みします。

~$ . .bashrc 

動作確認

~ $ roscore
... logging to /home/pi/.ros/log/83138f4e-c53f-11e9-a812-00e04c683e7e/roslaunch-raspiap-7514.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://raspiap:38553/
ros_comm version 1.12.6


SUMMARY
========

PARAMETERS
 * /rosdistro: kinetic
 * /rosversion: 1.12.6

NODES

auto-starting new master
process[master]: started with pid [7525]
ROS_MASTER_URI=http://raspiap:11311/

setting /run_id to 83138f4e-c53f-11e9-a812-00e04c683e7e
process[rosout-1]: started with pid [7538]
started core service [/rosout]
^C[rosout-1] killing on exit
[master] killing on exit
shutting down processing monitor...
... shutting down processing monitor complete
done
~ $

確認できたら、[Ctrl-C]で終了します。


(おまけ)Grove Base Hat for Raspberry Piも使う

様々なセンサやドライバが豊富なGROVEを活用する際に、
便利なRaspberryPi用IFボード「Grove Base Hat for Raspberry Pi」があります。

wiki.seeedstudio.com

これを駆動するのに必要な関連ファイルをインストールします。

前準備

pipをインストールします。

~ $ sudo apt install python-pip -y

インストール

~ $ curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh | sudo bash -s -
(・・・略・・・)
Installing collected packages: RPi.GPIO, grove.py
  Found existing installation: RPi.GPIO 0.6.5
    Not uninstalling rpi.gpio at /usr/lib/python3/dist-packages, outside environment /usr
  Running setup.py install for grove.py ... done
Successfully installed RPi.GPIO-0.7.0 grove.py-0.6
9#######################################################
  Lastest Grove.py from github install complete   !!!!!
#######################################################
~ $ 

動作確認

      • -