Description: TODO(GITHUB_NAME):
These instructions assume you are running on Ubuntu 20.04:
-
Install ROS2 foxy. You can stop following along with the tutorial after you complete the section titled: Environment setup. Make sure you setup your environment with:
source /opt/ros/foxy/setup.bash
NOTE: You may want to add that line to your
~/.bashrc
-
NOTE: If installing on a fresh OS, run
sudo rosdep init
androsdep update
before the install script -
Create a colcon workspace (Note: Feel free to change
~/ws_ros2
to whatever absolute path you want):export COLCON_WS=~/ws_ros2/ mkdir -p $COLCON_WS/src
-
Get the repo:
cd $COLCON_WS/src git clone git@github.com:PickNikRobotics/my_project.git
-
Download the required repositories and install any dependencies:
cd $COLCON_WS/src vcs import < my_project/my_project.repos rosdep install --ignore-src --from-paths . -y # Pick a ROS_DOMAIN_ID that doesn't clash with others echo 'export ROS_DOMAIN_ID='<YOUR-NUMBER> >> ~/.bashrc
-
Configure and build the workspace:
cd $COLCON_WS colcon build --symlink-install --event-handlers log-
-
Source the workspace.
source $COLCON_WS/install/setup.bash
Note: Whenever you open a new terminal be sure to run
source /opt/ros/foxy/setup.bash
,export COLCON_WS=~/ws_ros2
, andsource $COLCON_WS/install/setup.bash
. You may want to add those commands to your~/.bashrc
To make sure you have the latest repos:
cd $COLCON_WS/src/my_project
git checkout main
git pull origin main
cd $COLCON_WS/src
vcs import < my_project/my_project.repos
rosdep install --from-paths . --ignore-src -y
pre-commit is a tool to automatically run formatting checks on each commit, which saves you from manually running clang-format (or, crucially, from forgetting to run them!).
Install pre-commit like this:
pip3 install pre-commit
Run this in the top directory of the repo to set up the git hooks:
pre-commit install
To test the pacakges in my_project, use the following command with colcon.
export TEST_PACKAGES="PROJECT_PACKAGE_NAMES"
colcon build --packages-up-to ${TEST_PACKAGES}
colcon test --packages-select ${TEST_PACKAGES}
colcon test-result
ccache is a useful tool to speed up compilation times with GCC or any other sufficiently similar compiler.
To install ccache on Linux:
sudo apt-get install ccache
For other OS, search the package manager or software store for ccache, or refer to the ccache website
To use ccache after installing it there are two methods. you can add it to your PATH or you can configure it for more specific uses.
ccache must be in front of your regular compiler or it won't be called. It is recommended that you add this line to your .bashrc
:
export PATH=/usr/lib/ccache:$PATH
To configure ccache for more particular uses, set the CC and CXX environment variables before invoking make, cmake, catkin_make or catkin build.
For more information visit the ccache website. {"mode":"full","isActive":false}