Building and Sourcing Packages - ArcturusNavigation/all_seaing_vehicle GitHub Wiki

Back: Tutorials

Building packages using colcon

Build dev_ws by running the following command. colcon build compiles the source code and installs necessary files of all packages in the workspace.

cd ~/arcturus/dev_ws
colcon build --symlink-install

If installed the VRX simulation environment, build vrx_ws by running:

cd ~/arcturus/vrx_ws
colcon build --merge-install

You can also select specific packages to build by running the following command where <packages_to_select> is a space-separated list of packages.

colcon build --symlink-install --packages-select <packages_to_select>

A good rule of thumb is to rebuild a package if you added a new file or modified a C++ file. But when in doubt, colcon build!

If you run out of memory when building a specific package, try reducing the memory usage with the following --executor sequential flag:

colcon build --symlink-install --packages-select <packages_to_select> --executor sequential

This flag tells CMake to run the build process sequentially instead of in parallel with multiple processes, thus reducing the total memory usage but increasing the overall runtime.

Sourcing the setup file

To use a ROS package, you have to source the setup file of the workspace the package is in. First, to have access to ROS 2 commands, you need to run this command on every new shell:

source /opt/ros/humble/setup.bash

Then, to use the all_seaing_vehicle packages, you have to source dev_ws by running this command:

source ~/arcturus/dev_ws/install/setup.bash

Finally, if applicable, source vrx_ws:

source ~/arcturus/vrx_ws/install/setup.bash

Adding the commands to .bashrc

Running these commands in every new terminal can be time-consuming, so it is recommended that you put them in your .bashrc, a shell script that runs every time a new terminal is opened.

Open ~/.bashrc using your favorite text editor. Some common ones are nano, vim, neovim, emacs, and gedit.

nano ~/.bashrc

Add the following lines to the end:

source /opt/ros/humble/setup.bash
source ~/arcturus/dev_ws/install/setup.bash
source ~/arcturus/vrx_ws/install/setup.bash

Save your new .bashrc and open a new terminal. Your new terminal should have ROS 2 and all_seaing_vehicle packages activated.