Skip to content

Instantly share code, notes, and snippets.

@SebastianBitsch
Last active July 22, 2024 16:30
Show Gist options
  • Save SebastianBitsch/2309c4eca0242466cc9feb8643dc52d2 to your computer and use it in GitHub Desktop.
Save SebastianBitsch/2309c4eca0242466cc9feb8643dc52d2 to your computer and use it in GitHub Desktop.
ROS2 + Gazebo Installation for ARM64 Mac M1

Installing ROS2 + Gazebo natively on ARM M1 Mac

The setup makes use of Robostack to install ROS2 and Gazebo natively in a Conda environment - without the need for Docker-containers, Parallels, VMs, etc.

Steps

1. Update Xcode + OS

to version 14.x which is required by RoboStack. This in turn requires macOS Sonoma. Update your system to match

2. Install Homebrew

The default install directory for Homebrew on Apple Silicon is /opt/homebrew/. This doesn't work for our use, make sure to install brew at /usr/localand NOT at /opt/homebrew/

# install homebrew
cd ~
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# follow the instructions and
# dont forget to paste the two commands
(echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> /Users/[YOUR_NAME]/.zprofile      
    eval "$(/usr/local/bin/brew shellenv)"

Check the installation with

brew doctor

3. Setup Conda enviornment

Install conda if you haven't already.
Install mamba package manager (just a fast wrapper around conda). if mamba doesn't work just use conda instead of mamba for all the commands below

# install mamba
conda install mamba -c conda-forge

Create an environment

mamba create -n ros_env
mamba activate ros_env

# this adds the conda-forge channel to the new created environment configuration 
conda config --env --add channels conda-forge
# and the robostack channel
conda config --env --add channels robostack-staging
# remove the defaults channel just in case, this might return an error if it is not in the list which is ok
conda config --env --remove channels defaults

4. Install ROS2

and dependencies. See which packages are available pre-built on Robostack.

# re init the environment
mamba deactivate
mamba activate ros_env

# install ros, dependencies, etc.
mamba install ros-humble-desktop
mamba install compilers cmake pkg-config make ninja colcon-common-extensions catkin_tools

5. Install Gazebo

NOTE: Has to be installed in the base environment, i.e. call conda deactivate twice to get from (ros_env) -> (base) -> ( )

conda deactivate
conda deactivate

# install gazebo
curl -ssL http://get.gazebosim.org | sh 

brew update && brew upgrade

brew doctor

6. Finalize

6.1 Workspace

Create a workspace whereever you want on your local computer

mkdir -p ~/ros2_ws/src

Install packages

mamba install ros-humble-turtlebot3 ros-humble-turtlebot3-gazebo

6.2 Download course material

(Specific for DTU 34761) Download framework

git clone https://github.com/RasmusAndersen/RobotAutonomy.git ~/path/to/your/ws/src

6.3 Set up environment variables

Add commands to script automatically sourced on conda activate.
Find the location of your conda env with conda info -e

Create a file in the directory of where conda stores activation scripts. touch /path/to/your/conda/envs/ros_env/etc/conda/activate.d/ros_env_activate.sh

Add whatever you want to run on startup to the script ros_env_activate.sh

#!/bin/bash

source ~/ros2_ws/install/setup.zsh

# Add environment variables for ROS and Gazebo
export ROS_DOMAIN_ID=11
export TURTLEBOT3_MODEL=burger
export GAZEBO_MODEL_PATH=
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:$(ros2 pkg prefix my_turtlebot)/share/my_turtlebot/models
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:$(ros2 pkg prefix turtlebot3_gazebo)/share/turtlebot3_gazebo/models

Make it executeable with chmod +x ros_env_activate.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment