Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

Raspberry Pi 3 rasbian stretchでROS kineticをビルドする。

参照したサイト
http://wiki.ros.org/kinetic/Installation/Source

環境
OS stretch
Debian version 9.1
kernel Linux raspberrypi 4.9.59-v7+ #1047
gcc gcc (Raspbian 6.3.0-18+rpi1) 6.3.0 20170516
ROS kinetic
python 2.7.13

本家ではraspian jessieですが今回はstretchで試してみます。

Preparations

USBメモリにスワップを割り当てる(2GB)
この2つの記事を参照
https://qiita.com/kashikotuka/items/5d344f75164452cf54f5
https://qiita.com/suisuina/items/4fa8b001d7aa59d865a4 |

Prerequisites

Installing bootstrap dependencies
Install bootstrap dependencies (Ubuntu):

These tools are used to facilitate the download and management of ROS packages and their dependencies, among other things.

Ubuntu or Debian:

rasbian sttechもこれでOK
sudo apt-get install python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential

Initializing rosdep

sudo rosdep init
rosdep update

Installation

Start by building the core ROS packages.

Building the catkin Packages
ROS is in the process of converting to the catkin build system, but not all of the packages have been converted and the two build systems cannot be used simultaneously. Therefore it is necessary to build the core ROS packages first (catkin packages) and then the rest.

Create a catkin Workspace
In order to build the core packages, you will need a catkin workspace. Create one now:

$ mkdir ~/ros_catkin_ws
$ cd ~/ros_catkin_ws
Next we will want to fetch the core packages so we can build them. We will use wstool for this. Select the wstool command for the particular variant you want to install:

Desktop-Full Install: ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators, navigation and 2D/3D perception

$ rosinstall_generator desktop_full --rosdistro kinetic --deps --wet-only --tar > kinetic-desktop-full-wet.rosinstall
$ wstool init -j8 src kinetic-desktop-full-wet.rosinstall
Desktop Install (recommended): ROS, rqt, rviz, and robot-generic libraries

$ rosinstall_generator desktop --rosdistro kinetic --deps --wet-only --tar > kinetic-desktop-wet.rosinstall
$ wstool init -j8 src kinetic-desktop-wet.rosinstall
ROS-Comm: (Bare Bones) ROS package, build, and communication libraries. No GUI tools.

$ rosinstall_generator ros_comm --rosdistro kinetic --deps --wet-only --tar > kinetic-ros_comm-wet.rosinstall
$ wstool init -j8 src kinetic-ros_comm-wet.rosinstall
This will add all of the catkin or wet packages in the given variant and then fetch the sources into the ~/ros_catkin_ws/src directory. The command will take a few minutes to download all of the core ROS packages into the src folder. The -j8 option downloads 8 packages in parallel.

In addition to the 3 variants above, more are defined in REP 131 such as robot, perception, etc. Just change the package path to the one you want, e.g., for robot do:

$ rosinstall_generator robot --rosdistro kinetic --deps --wet-only --tar > kinetic-robot-wet.rosinstall
$ wstool init -j8 src kinetic-robot-wet.rosinstall

If wstool init fails or is interrupted, you can resume the download by running:

wstool update -j 4 -t src
Resolving Dependencies
Before you can build your catkin workspace you need to make sure that you have all the required dependencies. We use the rosdep tool for this:

$ rosdep install --from-paths src --ignore-src --rosdistro kinetic -y
This will look at all of the packages in the src directory and find all of the dependencies they have. Then it will recursively install the dependencies.

The --from-paths option indicates we want to install the dependencies for an entire directory of packages, in this case src. The --ignore-src option indicates to rosdep that it shouldn't try to install any ROS packages in the src folder from the package manager, we don't need it to since we are building them ourselves. The --rosdistro option is required because we don't have a ROS environment setup yet, so we have to indicate to rosdep what version of ROS we are building for. Finally, the -y option indicates to rosdep that we don't want to be bothered by too many prompts from the package manager.

After a while (and maybe some prompts for your password) rosdep will finish installing system dependencies and you can continue.

Building the catkin Workspace
Once it has completed downloading the packages and resolving the dependencies you are ready to build the catkin packages. We will use the catkin_make_isolated command because there are both catkin and plain cmake packages in the base install, when developing on your catkin only workspaces you should use catkin/commands/catkin_make.

Invoke catkin_make_isolated:

$ ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release

Note: You might want to select a different CMake build type (e.g. RelWithDebInfo or Debug, see http://cmake.org/cmake/help/v2.8.12/cmake.html#variable:CMAKE_BUILD_TYPE).

Note: The default catkin installation location would be ~/ros_catkin_ws/install_isolated, if you would like to install some where else then you can do this by adding the --install-space /opt/ros/kinetic argument to your catkin_make_isolated call.

For usage on a robot without Ubuntu, it is recommended to install compiled code into /opt/ros/kinetic just as the Ubuntu packages would do. Don't do this in Ubuntu, as the packages would collide with apt-get packages. It is also possible to install elsewhere (e.g. /usr), but it is not recommended unless you really know what you are doing.

Please see REP 122: Filesystem Hierarchy Layout for more detailed documentation on how the installed files are placed.

Note: In the above command we are running the catkin_make_isolated command from the catkin source folder because it has not been installed yet, once installed it can be called directly.

Now the packages should have been installed to ~/ros_catkin_ws/install_isolated or to wherever you specified with the --install-space argument. If you look in that directory you will see that a setup.bash file have been generated. To utilize the things installed there simply source that file. Lets do that now before building the rest of ROS:

$ source ~/ros_catkin_ws/install_isolated/setup.bash

Maintaining a Source Checkout
If we want to keep our source checkout up to date, we will have to periodically update our rosinstall file, download the latest sources, and rebuild our workspace.

Update the workspace
To update your workspace, first move your existing rosinstall file so that it doesn't get overwritten, and generate an updated version. For simplicity, we will cover the destop-full variant. For other variants, update the filenames and rosinstall_generator arguments appropriately.

$ mv -i kinetic-desktop-full-wet.rosinstall kinetic-desktop-full-wet.rosinstall.old
$ rosinstall_generator desktop_full --rosdistro kinetic --deps --wet-only --tar > kinetic-desktop-full-wet.rosinstall
Then, compare the new rosinstall file to the old version to see which packages will be updated:

$ diff -u kinetic-desktop-full-wet.rosinstall kinetic-desktop-full-wet.rosinstall.old
If you're satisfied with these changes, incorporate the new rosinstall file into the workspace and update your workspace:

$ wstool merge -t src kinetic-desktop-full-wet.rosinstall
$ wstool update -t src
Rebuild your workspace
Now that the workspace is up to date with the latest sources, rebuild it:

$ ./src/catkin/bin/catkin_make_isolated --install

If you specified the --install-space option when your workspace initially, you should specify it again when rebuilding your workspace

Once your workspace has been rebuilt, you should source the setup files again:

$ source ~/ros_catkin_ws/install_isolated/setup.bash
Wiki: kinetic/Installation/Source (last edited 2017-04-14 21:25:28 by DHood)
Except where otherwise noted, the ROS wiki is licensed under the
Creative Commons Attribution 3.0 | Find us on Google+

roscore does not work when these package were not installed

sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo apt-get install python-defusedxml
sudo pip install netifaces

sudo apt-get install libyaml-cpp-dev

sudo apt-get install libswscale-dev

Install python-empy

sudo apt-get install python-empy

Install libboost

sudo apt-get install libboost-all-dev'

Install python-nose

sudo apt-get install python-nose

Install libgtest

sudo apt-get install libgtest-dev

Install console_bridge

mkdir cb_ws
cd cb_wd
git clone https://github.com/ros/console_bridge.git
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=../install ../console_bridge
sudo make install

git clone git://github.com/ros/console_bridge.git
cd console_bridge
cmake .
make
sudo make install

Install poco

https://github.com/MDHSRobotics/TeamWiki/wiki/Installing-POCO-library-on-Ubuntu
tar xvfz poco-1.9.0.tar.gz
cd poco-1.9.0/
./configure
make -s
sudo mkdir /usr/include/Poco
sudo cp -r Foundation/include/Poco/. /usr/include/Poco/
sudo cp -r Util/include/Poco/. /usr/include/Poco/
sudo cp -r JSON/include/Poco/. /usr/include/Poco/
sudo cp -r lib/Linux/armv7l/. /usr/local/lib

Install libeigen3

sudo apt-get install libeigen3-dev

Install Qt4

sudo apt-get install qt4-dev-tools

sip for python_orocos_kdl

https://riverbankcomputing.com/software/sip/download
cd Dwonload
cd tar xvfz sip-4.19.8.tar.gz
cd sip-4.19.8/
python configure.py
make
sudo make install

instal libtinyxml-dev for rospack

sudo apt-get install libtinyxml-dev

Install libtinyxml2-dev for pluginlib

sudo apt-get install libtinyxml2-dev

Install qtbase5-dev for qt_gui_cpp

sudo apt-get install qtbase5-dev

Install python-pyqt5 for qt_gui_cpp

sudo apt-get install python-pyqt5

for qt_gui_cpp

sudo apt-get install sip-dev pyqt5-dev python-sip-dev pyqt5-dev-tools

Install for rosIz4

sudo apt-get install liblz4-dev

Install for rosbag_storage

sudo apt-get install libbz2-dev

exclude tf2 because below errors occurred.

Scanning dependencies of target tf2
[ 9%] Building CXX object gtest/googlemock/CMakeFiles/gmock.dir//googletest/src/gtest-all.cc.o
[ 18%] Building CXX object gtest/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o
[ 27%] Building CXX object gtest/googlemock/CMakeFiles/gmock_main.dir/
/googletest/src/gtest-all.cc.o
[ 36%] Building CXX object CMakeFiles/tf2.dir/src/cache.cpp.o
[ 45%] Building CXX object CMakeFiles/tf2.dir/src/buffer_core.cpp.o
[ 54%] Building CXX object gtest/googlemock/CMakeFiles/gmock_main.dir/src/gmock-all.cc.o
/usb/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp: In member function ‘bool tf2::BufferCore::warnFrameId(const char*, const string&) const’:
/usb/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp:126:34: error: ‘logWarn’ was not declared in this scope
logWarn("%s",ss.str().c_str()); ^
/usb/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp:134:34: error: ‘logWarn’ was not declared in this scope
logWarn("%s",ss.str().c_str()); ^
/usb/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp: In member function ‘bool tf2::BufferCore::setTransform(const TransformStamped&, const string&, bool)’:
/usb/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp:221:195: error: ‘logError’ was not declared in this scope
cause they are the same", authority.c_str(), stripped.child_frame_id.c_str());
^
/usb/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp:227:129: error: ‘logError’ was not declared in this scope
orm from authority \"%s\" because child_frame_id not set ", authority.c_str());
^
/usb/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp:233:177: error: ‘logError’ was not declared in this scope
because frame_id not set", stripped.child_frame_id.c_str(), authority.c_str());
^
/usb/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp:244:15: error: ‘logError’ was not declared in this scope
);
^
/usb/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp:257:136: error: ‘logError’ was not declared in this scope
form.rotation.y, stripped.transform.rotation.z, stripped.transform.rotation.w);
^
/usb/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp:277:264: error: ‘logWarn’ was not declared in this scope
pped.child_frame_id.c_str(), stripped.header.stamp.toSec(), authority.c_str());
^
/usb/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp: In member function ‘geometry_msgs::TransformStamped tf2::BufferCore::lookupTransform(const string&, const string&, const ros::Time&) const’:
/usb/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp:636:48: error: ‘logError’ was not declared in this scope
logError("Unknown error code: %d", retval);
^
/usb/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp: In member function ‘void tf2::BufferCore::chainAsVector(const string&, ros::Time, const string&, ros::Time, const string&, std::vector<std::cxx11::basic_string >&) const’:
/usb/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp:1607:48: error: ‘logError’ was not declared in this scope
logError("Unknown error code: %d", retval);
^
/usb/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp:1626:48: error: ‘logError’ was not declared in this scope
logError("Unknown error code: %d", retval);
^
CMakeFiles/tf2.dir/build.make:86: recipe for target 'CMakeFiles/tf2.dir/src/buffer_core.cpp.o' failed
make[2]: *** [CMakeFiles/tf2.dir/src/buffer_core.cpp.o] Error 1
CMakeFiles/Makefile2:915: recipe for target 'CMakeFiles/tf2.dir/all' failed
make[1]: *** [CMakeFiles/tf2.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 63%] Building CXX object gtest/googlemock/CMakeFiles/gmock
main.dir/src/gmock_main.cc.o
[ 72%] Linking CXX shared library libgmock_main.so
[ 81%] Linking CXX shared library libgmock.so
[ 81%] Built target gmock
[ 81%] Built target gmock_main
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
<== Failed to process package 'tf2':
Command '['/usb/ros_catkin_ws/install_isolated/env.sh', 'make', '-j4', '-l4']' returned non-zero exit status 2

Reproduce this error by running:
==> cd /usb/ros_catkin_ws/build_isolated/tf2 && /usb/ros_catkin_ws/install_isolated/env.sh make -j4 -l4

Command failed, exiting.

opencvのビルドエラーのところまで。

==> Processing plain cmake package: 'opencv3'
==> Building with env: '/usb/ros_catkin_ws/install_isolated/env.sh'
==> cmake /usb/ros_catkin_ws/src/opencv3 -DCMAKE_INSTALL_PREFIX=/usb/ros_catkin_ws/install_isolated -DCMAKE_BUILD_TYPE=Release -G Unix Makefiles in '/usb/ros_catkin_ws/build_isolated/opencv3/install'
-- Looking for ccache - not found
-- FP16 is not supported by C++ compiler
-- Could NOT find TIFF (missing: TIFF_LIBRARY TIFF_INCLUDE_DIR)
CMake Error at 3rdparty/libtiff/CMakeLists.txt:67 (check_type_size):
Unknown CMake command "check_type_size".

-- Configuring incomplete, errors occurred!
See also "/usb/ros_catkin_ws/build_isolated/opencv3/install/CMakeFiles/CMakeOutput.log".
See also "/usb/ros_catkin_ws/build_isolated/opencv3/install/CMakeFiles/CMakeError.log".
<== Failed to process package 'opencv3':
Command '['/usb/ros_catkin_ws/install_isolated/env.sh', 'cmake', '/usb/ros_catkin_ws/src/opencv3', '-DCMAKE_INSTALL_PREFIX=/usb/ros_catkin_ws/install_isolated', '-DCMAKE_BUILD_TYPE=Release', '-G', 'Unix Makefiles']' returned non-zero exit status 1

Reproduce this error by running:
==> cd /usb/ros_catkin_ws/build_isolated/opencv3 && /usb/ros_catkin_ws/install_isolated/env.sh cmake /usb/ros_catkin_ws/src/opencv3 -DCMAKE_INSTALL_PREFIX=/usb/ros_catkin_ws/install_isolated -DCMAKE_BUILD_TYPE=Release -G 'Unix Makefiles'

Command failed, exiting.
pi@raspberrypi:/usb/ros_catkin_ws $

for urdf_parser_plugin

sudo apt-get install liburdfdom-dev

for geometric_shapes

sudo apt-get install libassimp-dev
sudo apt-get install libqhull-dev

exclude geometric_shapes

==> make -j4 -l4 in '/usb/ros_catkin_ws/build_isolated/geometric_shapes'
Scanning dependencies of target gmock_main
Scanning dependencies of target geometric_shapes
Scanning dependencies of target gmock
[ 6%] Building CXX object gtest/googlemock/CMakeFiles/gmock.dir//googletest/src/gtest-all.cc.o
[ 13%] Building CXX object gtest/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o
[ 20%] Building CXX object gtest/googlemock/CMakeFiles/gmock_main.dir/
/googletest/src/gtest-all.cc.o
[ 26%] Building CXX object CMakeFiles/geometric_shapes.dir/src/bodies.cpp.o
/usb/ros_catkin_ws/src/geometric_shapes/src/bodies.cpp: In member function ‘virtual void bodies::ConvexMesh::useDimensions(const shapes::Shape*)’:
/usb/ros_catkin_ws/src/geometric_shapes/src/bodies.cpp:791:42: error: ‘logWarn’ was not declared in this scope
logWarn("Convex hull creation failed");
^
/usb/ros_catkin_ws/src/geometric_shapes/src/bodies.cpp: In member function ‘void bodies::BodyVector::setPose(unsigned int, const Affine3d&)’:
/usb/ros_catkin_ws/src/geometric_shapes/src/bodies.cpp:1177:47: error: ‘logError’ was not declared in this scope
logError("There is no body at index %u", i);
^
/usb/ros_catkin_ws/src/geometric_shapes/src/bodies.cpp: In member function ‘const bodies::Body* bodies::BodyVector::getBody(unsigned int) const’:
/usb/ros_catkin_ws/src/geometric_shapes/src/bodies.cpp:1188:47: error: ‘logError’ was not declared in this scope
logError("There is no body at index %u", i);
^
CMakeFiles/geometric_shapes.dir/build.make:62: recipe for target 'CMakeFiles/geometric_shapes.dir/src/bodies.cpp.o' failed
make[2]: *** [CMakeFiles/geometric_shapes.dir/src/bodies.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/geometric_shapes.dir/all' failed
make[1]: *** [CMakeFiles/geometric_shapes.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 40%] Building CXX object gtest/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o
[ 40%] Linking CXX shared library libgmock.so
[ 40%] Built target gmock
[ 46%] Building CXX object gtest/googlemock/CMakeFiles/gmock_main.dir/src/gmock-all.cc.o
[ 53%] Linking CXX shared library libgmock_main.so
[ 53%] Built target gmock_main
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
<== Failed to process package 'geometric_shapes':
Command '['/usb/ros_catkin_ws/install_isolated/env.sh', 'make', '-j4', '-l4']' returned non-zero exit status 2

Reproduce this error by running:
==> cd /usb/ros_catkin_ws/build_isolated/geometric_shapes && /usb/ros_catkin_ws/install_isolated/env.sh make -j4 -l4

Command failed, exiting.
pi@raspberrypi:/usb/ros_catkin_ws $

exclude below there packages. These are dependency error

--Skipping package: 'tf2'
--Skipping package: 'tf2_py'
--Skipping package: 'tf2_ros'
--Skipping package: 'tf2_kdl'
--Skipping package: 'tf'
---Skipping package: 'interactive_markers'
--Skipping package: 'interactive_marker_tutorials'
--Skipping package: 'laser_geometry'
--Skipping package: 'tf_conversions'
--Skipping package: 'turtlesim'
--Skipping package: 'turtle_actionlib'
--Skipping package: 'turtle_tf'
--Skipping package: 'turtle_tf2'
--Skipping package: 'collada_parser'
--Skipping package: 'robot_state_publisher'

don't need 3D package

--Skipping package: 'rviz'
--Skipping package: 'librviz_tutorial'
--Skipping package: 'rqt_rviz'

build error

--Skipping package: geometric_shapes
--Skipping package: 'collada_urdf'

OpenCV require

apt-get -y install pkg-config libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev zlib1g-dbg zlib1g zlib1g-dev pngtools libtiff5-dev libtiff5 libtiffxx0c2 libtiff-tools libeigen3-dev
echo installing helper apps ...

sudo apt-get update
sudo apt-get upgrade

sudo apt-get install -y build-essential
sudo apt-get install -y cmake
sudo apt-get install -y pkg-config
sudo apt-get install -y libpng12-0 libpng12-dev libpng++-dev libpng3
sudo apt-get install -y libpnglite-dev
sudo apt-get install -y zlib1g-dbg zlib1g zlib1g-dev
sudo apt-get install -y libtiff5-dev libtiff5 libeigen3-dev
sudo apt-get install -y pngtools libtiffxx0c2 libtiff-tools
sudo apt-get install -y libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs
sudo apt-get install -y ffmpeg libavcodec-dev libavcodec53 libavformat53 libavformat-dev
sudo apt-get install -y libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev
sudo apt-get install -y libxine1-ffmpeg libxine-dev libxine1-bin
sudo apt-get install -y libunicap2 libunicap2-dev
sudo apt-get install -y libdc1394-22-dev libdc1394-22 libdc1394-utils
sudo apt-get install -y swig
sudo apt-get install -y libv4l-0 libv4l-dev
sudo apt-get install -y python-numpy
sudo apt-get install -y libpython2.6 python-dev python2.6-dev
sudo apt-get install -y libgtk2.0-dev pkg-config[*]gvg

usb_cam

preparation

sudo pip install netifaces
sudo apt-get install python-defusedxml
sudo apt-get install libogre-dev
sudo apt-get install libassimp-dev
sudo apt-get install bzip2-devs

rosparam set usb_cam/pixel_format yuyv

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away