Skip to content

Instantly share code, notes, and snippets.

@bhaktatejas922
Last active December 15, 2023 18:57
Show Gist options
  • Save bhaktatejas922/56b07f46ef56fe381029719dbcb08389 to your computer and use it in GitHub Desktop.
Save bhaktatejas922/56b07f46ef56fe381029719dbcb08389 to your computer and use it in GitHub Desktop.
Macos Ros2 install script wth conda
#!/bin/zsh
# Ensure Xcode and Command Line Tools are installed
xcode-select --install
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license
# Install Homebrew
which -s brew
if [[ $? != 0 ]] ; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
brew update
fi
# Check Homebrew configuration
brew doctor
# Install ROS 2 dependencies with Homebrew
brew install asio assimp bison bullet cmake console_bridge cppcheck \
cunit eigen freetype graphviz opencv openssl orocos-kdl pcre poco \
pyqt5 python qt@5 sip spdlog tinyxml tinyxml2
# Set environment variables
echo "export OPENSSL_ROOT_DIR=$(brew --prefix openssl)" >> ~/.zshrc
export CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH:$(brew --prefix qt@5)
export PATH=$PATH:$(brew --prefix qt@5)/bin
conda deactivate && conda env remove --name ros2 -y
conda create --name ros2 python=3.10 -y
conda deactivate && conda activate ros2
# list the current conda environment and the python version
conda info
python --version
# Install Python dependencies
python -m pip install -U \
argcomplete catkin_pkg colcon-common-extensions coverage \
cryptography empy flake8 flake8-blind-except==0.1.1 flake8-builtins \
flake8-class-newline flake8-comprehensions flake8-deprecated \
flake8-docstrings flake8-import-order flake8-quotes \
importlib-metadata jsonschema lark==1.1.1 lxml matplotlib mock mypy==0.931 netifaces \
nose pep8 psutil pydocstyle pydot pygraphviz pyparsing==2.4.7 \
pytest-mock rosdep rosdistro setuptools==59.6.0 vcstool
# Create a workspace and clone ROS 2 repos
mkdir -p ~/ros2_iron/src
cd ~/ros2_iron
vcs import --input https://raw.githubusercontent.com/ros2/ros2/iron/ros2.repos src
# Build the ROS 2 workspace
colcon build --symlink-install --packages-skip-by-dep python_qt_binding
# Set up the ROS 2 environment
echo ". ~/ros2_iron/install/setup.zsh" >> ~/.zshrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment