We use ROS Humble, since it is the current LTS version. This requires Ubuntu 22.04 at least.
ros-humble-desktop-full
should be good for most.
Like with ROS1, setup a workspace. Usually colcon_ws
.
Notice that ROS2 moved from catkin to colcon for its build process, and there are some minor differences from a user standpoint.
Colcon, unlike catkin, cares about your current directory when building, by default.
This is a dumb default.
Put in ~/.colcon/defaults.yaml
the following, with paths changed to fit your setup:
{
"build": {
"symlink-install": true,
"build-base": "/code/ros2_ws/build",
"install-base": "/code/ros2_ws/install",
"base-paths": ["/code/ros2_ws/src"]
},
"test": {
"build-base": "/code/ros2_ws/build",
"install-base": "/code/ros2_ws/install",
"event-handlers": ["console_direct+"],
"base-paths": ["/code/ros2_ws/src"],
}
}
Now you can run colcon build
and colcon test
from anywhere in your system and it will create its files in the same place, all the time.
You might need to change this if you ever need multiple workspaces and don't want to delete the created folders.
You can also find this file here
Do the following steps in order on a clean ubuntu 22.04 system. Missing a step will likely produce errors.
cd
commands are given as inexact, do what they intend to do :)
mkdir -p colcon_ws/src
cd colcon_ws/src
git clone https://github.com/smarc-project/smarc2.git
cd smarc2
./scripts/get-submodules.sh external_packages
apt update && apt upgrade # Optional but good
apt install python3-colcon-ros python3-rosdep python3-pip apt-utils ros-dev-tools
pip install --user setuptools==58.2.0 # Optional. Stops useless warnings when building
rosdep init
rosdep update
cd colcon_ws
./src/smarc2/scripts/rosdep_install_from_src.sh
cd colcon_ws
source /opt/ros/humble/setup.bash # if you havent put this in your .bashrc
colcon build
cd colcon_ws
echo "source /home/YOUR_USERNAME/colcon_ws/install/setup.sh" >> ~/.bashrc
and/or
cd colcon_ws
source install/setup.sh
In any terminal you want to use ros in.