ROS 2 Galactic on Mac M1 with Monterey
I’ve finally been able to install ROS 2 on my M1 macbook pro.
Though I had to search a bit to get things to work, my two main sources were:
- Building ROS 2 on MacOS: The official ROS 2 guide for building from source on MacOS
- How to build and install ROS2 on macOS Big Sur M1: Kilmet Mamykin’s blog on building and installing ROS 2 — I’m shortening this to KM’s ROS 2 blog
Here’s an outline of the steps I followed:
- Had homebrew installed already
- Also had numpy and pillow installed but anyone who has issues can follow the instructions at KM’s ROS 2 blog
Getting Started
- Followed steps 1–6 here: building ROS 2 on MacOS: Install prereqs
- Ran into an error in step 6 with the package ast-typed. So I followed the instructions under install prerequisites here: KM’s ROS 2 blog
Getting ROS 2
- Now I was ready to get the code by following building ROS 2 on MacOS: get the code
- Before getting the sources as in line
vcs import src < ros2.repos
I made one change to the file ros2.repos:
* I found the listing for the package mimic_vendor and changed the branch to master
* This is because in my earlier attempts mimic_vendor gave me errors as in the github issue here - Finally I ran
vcs import src < ros2.repos
Building ROS 2
- I followed the instructions in building ROS 2 on MacOS: build the code
- But I ran into errors:
* rviz_ogre_vendor gave me errors, so I downloaded the latest rviz version as a zip file and pasted it in src/ros2/rviz (overriding the previous folder) [possibly not smart but hey]
* I also changed the line in file src/ros2/rviz/rviz_ogre_vendor/CMakeLists.txt fromlist(APPEND extra_cmake_args "-DCMAKE_OSX_ARCHITECTURES='x86_64'")
tolist(APPEND extra_cmake_args "-DCMAKE_OSX_ARCHITECTURES='arm64'")
(from the patches section in KM’s ROS 2 blog) - Now I ran the
colcon build
command again - But as stated in KM’s ROS 2 blog I ran into errors again! This time I had to patch
build/rviz_ogre_vendor/ogre-v1.12.1-prefix/src/ogre-v1.12.1/OgreMain/include/OgrePlatformInformation.h
- So I followed the instructions in KM’s ROS 2 blog and changed the line
# define OGRE_CPU OGRE_CPU_X86
to# define OGRE_CPU OGRE_CPU_ARM
- Finally I ran the build command again i.e.
colcon build --symlink-install --packages-skip-by-dep python_qt_binding
- It took a while but things worked!!! 1 package failed but 303 of 305 succeeded
Running the talker/listener demo
- To run the talker/listener demo I first had to source the setup file as in building ROS 2 on MacOS: environment setup
. /full-path-to-ros-folder/install/setup.zsh
- I was now able to successfully run the talker and listener
- Rejoice!!