はじめに
Raspbian(2018-11-13-raspbian-stretch)のROSパッケージをそのままインストールしてみました。
古いバージョンを使うことになるので、実際の所、良いのか分かりませんが、ひとまず手順を残します。
ROSの入門は、こちらを教科書にさせて頂きました。
ROS講座00 目次 - Qiita
下調べ
apt-cache で、RaspbianのROSのバージョンを調べてみました。
だいぶ古いバージョン(2016年春頃のリリース)のようです。
~ $ apt-cache show ros-core Package: ros-core Source: ros-metapackages Version: 1.7 Installed-Size: 8 Maintainer: Debian Science Maintainers <debian-science-maintainers@lists.alioth.debian.org> Architecture: all Depends: python-rosclean, python-rosbag, python-rosgraph, python-roslaunch, python-rosmaster, python-rosmsg, python-rosnode, python-rosparam, python-rosservice, python-rostopic, python-message-filters, python-roswtf, rosout, topic-tools Recommends: rosbash Size: 2380 SHA256: e256a50ff7da3fb0c7ba72b73d2caeb5a26106fd5da2e73668f49525c08729b1 SHA1: 894bb519f4775444c2282053a13ce3ec2e5737e5 MD5sum: e7e6afb83388f46e2f52cf06672bacd3 Description: Robot OS core metapackage This package is part of Robot OS (ROS). It is a metapackage providing all the ROS core system. . Different to upstream, this packages does not provide geneus and rosbag_migration_rule. Please install them from source, if you need them. Description-md5: 4b79f51f56b69a7611fb956936b6da3c Section: metapackages Priority: extra Filename: pool/main/r/ros-metapackages/ros-core_1.7_all.deb
インストール
”desktop-full-dev”というパッケージで、一通り必要な機能が入ります。
こちらを参考にしています。
ROS講座02 インストール - Qiita
pi@raspi3:~ $ sudo apt-get install ros-desktop-full-dev Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: autoconf automake autopoint autotools-dev bzip2-doc bzr catkin cl-actionlib cl-actionlib-msgs cl-bond ... x11proto-scrnsaver-dev x11proto-xext-dev x11proto-xf86vidmode-dev x11proto-xinerama-dev xorg-sgml-doctools xtrans-dev 0 upgraded, 863 newly installed, 0 to remove and 1 not upgraded. Need to get 323 MB of archives. After this operation, 1520 MB of additional disk space will be used. Do you want to continue? [Y/n] y ...
インストール前後のディスク使用量
インストール前
pi@raspi3:~ $ df -h Filesystem Size Used Avail Use% Mounted on /dev/root 15G 9.9G 4.0G 72% /
インストール後
pi@raspi3:~ $ df -h Filesystem Size Used Avail Use% Mounted on /dev/root 15G 12G 2.2G 85% /
ROSの初期化
pi@raspi3:~ $ sudo rosdep init Wrote /etc/ros/rosdep/sources.list.d/20-default.list Recommended: please run rosdep update pi@raspi3:~ $ 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.yaml Add distro "ardent" Add distro "bouncy" Add distro "crystal" Add distro "groovy" Add distro "hydro" Add distro "indigo" Add distro "jade" Add distro "kinetic" Add distro "lunar" Add distro "melodic" updated cache in /home/pi/.ros/rosdep/sources.cache
catkinの準備
pi@raspi3:~ $ mkdir -p ~/catkin_ws/src pi@raspi3:~ $ cd ~/catkin_ws/src pi@raspi3:~/catkin_ws/src $ catkin_init_workspace Creating symlink "/home/pi/catkin_ws/src/CMakeLists.txt" pointing to "/usr/share/catkin/cmake/toplevel.cmake" pi@raspi3:~/catkin_ws/src $ ls -la total 8 drwxr-xr-x 2 pi pi 4096 Feb 6 17:34 . drwxr-xr-x 3 pi pi 4096 Feb 6 17:34 .. lrwxrwxrwx 1 pi pi 38 Feb 6 17:34 CMakeLists.txt -> /usr/share/catkin/cmake/toplevel.cmake pi@raspi3:~/catkin_ws/src $ cd ~/catkin_ws pi@raspi3:~/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 #### #### Running command: "cmake /home/pi/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/pi/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/pi/catkin_ws/install -G Unix Makefiles" in "/home/pi/catkin_ws/build" #### -- The C compiler identification is GNU 6.3.0 -- The CXX compiler identification is GNU 6.3.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Using CATKIN_DEVEL_PREFIX: /home/pi/catkin_ws/devel -- Using CMAKE_PREFIX_PATH: -- Found PythonInterp: /usr/bin/python (found version "2.7.13") -- Using PYTHON_EXECUTABLE: /usr/bin/python -- Using Debian Python package layout -- Using empy: /usr/bin/empy -- Using CATKIN_ENABLE_TESTING: ON -- Call enable_testing() -- Using CATKIN_TEST_RESULTS_DIR: /home/pi/catkin_ws/build/test_results -- Found gtest sources under '/usr/src/gtest': gtests will be built -- nosetests not found, Python tests can not be run (try installing package 'python-nose') -- catkin 0.7.4 -- BUILD_SHARED_LIBS is on -- Configuring done -- Generating done -- Build files have been written to: /home/pi/catkin_ws/build #### #### Running command: "make -j4 -l4" in "/home/pi/catkin_ws/build" ####
ROSのサンプルプログラムを試してみる
こちらを参考にします。
ROS講座03 Pub & Sub 通信 - Qiita
コンパイルまで終わらせます。
pi@raspi3:~/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 #### #### Running command: "make cmake_check_build_system" in "/home/pi/catkin_ws/build" #### #### #### Running command: "make -j4 -l4" in "/home/pi/catkin_ws/build" #### [100%] Built target basic_simple_talker [100%] Built target basic_simple_listener
ターミナル1つ目:roscoreを動かします
pi@raspi3:~/catkin_ws $ source ~/catkin_ws/devel/setup.bash pi@raspi3:~/catkin_ws $ roscore ... logging to /home/pi/.ros/log/2ab1e868-29f0-11e9-8b33-b827ebaf3240/roslaunch-raspi3-1072.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://raspi3:41255/ ros_comm version 1.12.6 SUMMARY ======== PARAMETERS * /rosdistro: kinetic * /rosversion: 1.12.6 NODES auto-starting new master process[master]: started with pid [1082] ROS_MASTER_URI=http://raspi3:11311/ setting /run_id to 2ab1e868-29f0-11e9-8b33-b827ebaf3240 process[rosout-1]: started with pid [1095] started core service [/rosout]
ターミナル2つ目:talkerを動かします
pi@raspi3:~/catkin_ws $ source ~/catkin_ws/devel/setup.bash pi@raspi3:~ $ rosrun basic_lecture basic_simple_talker [ INFO] [1549445114.110764374]: hello world! [ INFO] [1549445114.210512172]: hello world! ...
ターミナル3つ目:listenerを動かします
pi@raspi3:~/catkin_ws $ source ~/catkin_ws/devel/setup.bash pi@raspi3:~ $ rosrun basic_lecture basic_simple_listener [ INFO] [1549445114.412048604]: I heard: [hello world!] [ INFO] [1549445114.511398797]: I heard: [hello world!] ...
talkerの方のターミナルで、プログラムを止めるとメッセージが止まり、プログラムを動かすとメッセージが流れます。
ターミナルを開くたびに、毎回
source ~/catkin_ws/devel/setup.bash
を入力していますが、教科書の通り、.bashrcに追記した方が良いですね。
(覚え)roscoreを動かし忘れたとき
このようなエラーメッセージが出ます。
ターミナル2つ目:talker
pi@raspi3:~ $ rosrun basic_lecture basic_simple_talker [ERROR] [1549445150.003231955]: [registerPublisher] Failed to contact master at [localhost:11311]. Retrying... ^Cpi@raspi3:~ $
ターミナル3つ目:listener
pi@raspi3:~ $ rosrun basic_lecture basic_simple_listener [ERROR] [1549445154.933464174]: [registerPublisher] Failed to contact master at [localhost:11311]. Retrying... ^Cpi@raspi3:~ $