This tutorial show how to perform a installation of ROS 2 at OS X
You can also perform this installation at Linux. Go to Tutorial #2 for that.
Before install ROS 2 these packages are necessary:
It is really important to read the terms and conditions and agree it for download the .dmg file for "Mac OS X x64"
Install the JDK from the .dmg
Optionally you can check the version of java installed:
$ find /Library/Java | grep jni.h /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/include/jni.h $ java -version java version "1.8.0_60" Java(TM) SE Runtime Environment (build 1.8.0_60-b27) Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
Some "stuff" is required. For install them you need brew. Maybe brew is already installed at your system, if not go to http://brew.sh/
The next sources should be added to brew:
brew tap osrf/ros2 brew tap ros/deps
brew install homebrew/science/opencv --without-python brew install python3 wget cmake cppcheck gtest
Use pip3 (not pip, which will install Python 2.7 packages!) to install more stuff:
pip3 install empy setuptools nose vcstool pep8 pydocstyle pyflakes flake8 mock coverage
The next lines will import the repos of ROS 2
mkdir -p ~/ros2_ws/src cd ~/ros2_ws wget https://raw.githubusercontent.com/ros2/ros2/release-latest/ros2.repos vcs import ~/ros2_ws/src < ros2.repos
The next command will build ROS 2. This can take a wile. If the command do not end correctly chech Troubleshooting section.
cd ~/ros2_ws src/ament/ament_tools/scripts/ament.py build --build-tests --symlink-install
Open a terminal and launch the next bash. After that launch a 'talker'
. ~/ros2_install/ros2-osx/setup.bash talker
Using another terminal launch the same bash and after that a 'listener'
. ~/ros2_install/ros2-osx/setup.bash lister
You should be able to see how the listener is listening the messages that is publishing the talker.
If you upgrade to CLT 10.10.3, you might get this error:
[100%] Building CXX object CMakeFiles/rmw_connext_cpp.dir/src/functions.cpp.o In file included from /Users/william/ros2/src/ros2/rmw_connext/rmw_connext_cpp/src/functions.cpp:15: In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iostream:38: In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ios:216: In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__locale:15: In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:439: In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:628: In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:604: /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iterator:341:10: fatal error: '__debug' file not found #include <__debug> ^ 1 error generated. make: *** [CMakeFiles/rmw_connext_cpp.dir/src/functions.cpp.o] Error 1 make: *** [CMakeFiles/rmw_connext_cpp.dir/all] Error 2 make: *** [all] Error 2
This is the solution (http://stackoverflow.com/a/29576048/671658):
$ echo '#define _LIBCPP_ASSERT(x, m) ((void)0)' | sudo tee -a /Library/Developer/CommandLineTools/usr/include/c++/v1/__debug > /dev/null
It can be undone with:
$ sudo rm /Library/Developer/CommandLineTools/usr/include/c++/v1/__debug
If you have opencv installed you might get this:
dyld: Symbol not found: __cg_jpeg_resync_to_restart Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO Expected in: /usr/local/lib/libJPEG.dylib in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO /bin/sh: line 1: 25274 Trace/BPT trap: 5 /usr/local/bin/cmake
If so, to build you'll have to do this:
$ brew unlink libpng libtiff libjpeg
But this will break opencv, so you'll also need to update it to continue working:
$ sudo install_name_tool -change /usr/local/lib/libjpeg.8.dylib /usr/local/opt/jpeg/lib/libjpeg.8.dylib /usr/local/lib/libopencv_highgui.2.4.dylib $ sudo install_name_tool -change /usr/local/lib/libpng16.16.dylib /usr/local/opt/libpng/lib/libpng16.16.dylib /usr/local/lib/libopencv_highgui.2.4.dylib $ sudo install_name_tool -change /usr/local/lib/libtiff.5.dylib /usr/local/opt/libtiff/lib/libtiff.5.dylib /usr/local/lib/libopencv_highgui.2.4.dylib $ sudo install_name_tool -change /usr/local/lib/libjpeg.8.dylib /usr/local/opt/jpeg/lib/libjpeg.8.dylib /usr/local/Cellar/libtiff/4.0.4/lib/libtiff.5.dylib
The first command is necessary to avoid things built against the system libjpeg (etc.) from getting the version in /usr/local/lib. The others are updating things built by Homebrew so that they can find the version of libjpeg (etc.) without having them in /usr/local/lib.