Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

This repo is a linux ROS2 Jazzy workspace which holds my code as multiple organized libraries (found in the ros2_libraries folder) and multiple packages (found in the src folder), in which libraries from ros2_libraries are most of the time used in said packages. Each library and package has its own CMakeLists.txt to help build everything easily. Moreover, each package has its own README.md to explain what it its. Finally there are example CMakeLists.txt and package.xml files and a helper_funcitons.cmake file inside ros2_libraries to help start things off.


Installation

  1. Install ROS2 Jazzy (with all optional ROS2 development tools) on your machine from https://docs.ros.org/en/jazzy/Installation/Ubuntu-Install-Debs.html.

  2. Second copy the following bash code into your .bashrc file:

#sources the ROS2 installation so ROS2 commands can be used from any directory in our terminal. The default install path of ROS2 is used here, if you have somehow installed ROS2 in a different directory (not recommended) then edit the path to your actual correct ROS2 path
source /opt/ros/jazzy/setup.bash

#sources the current ROS2 workspace so the packages and nodes in it can be visible to be called and used
function source_ros2_workspace() {
   source $(pwd)/install/setup.bash
   echo "sourced ROS2 workspace from $(pwd)/install/setup.bash"
}

Building

  • All packages in the workspace are easily built by running the following command in the workspace root directory:
colcon build 
  • colcon build command looks for an src folder inside the workspace root directory and searches said folder recursively. While searching src, if it finds a package.xml file inside a folder, it marks that folder as a package and builds it.

  • If you you want to ommit colcon from building certain directories (perhaps it marked a none-package folder as a package), then you have to create an empty AMENT_IGNORE.txt file inside the root directory of the folder that should not be built as a package.

  • If you want to change the packages folder name from colcon's default src to something else of your liking; example to packages_folder, then after renaming the folder you have to call colcon build with an argument:

colcon build --base-paths packages_folder

Notes

  • Sometimes old build files still cause an issue; hence, compile errors still pop up even though the error should be resolved. In such a situation, the best and most agressive solution is to delete the generated install, build and log folders from the workspace root directory

  • The example CMakeLists.txt and package.xml should be read carefully, they can be copied inside every project directory and edited to suit your needs.

  • Understanding helper_functions.cmake and at least one library’s CMakeLists.txt is important.

  • Libraries might have dependencies on each other. Read their CMakeLists.txt carefully.

  • Dont forget to source the workspace in your current shell before trying to run any node. Since we added a sourcing function into the .bashrc file, then you can source the workspace by calling the following function from the workspace root directory:

source_ros2_workspace
  • Looking up toturials on cmake, ROS2, ament and colcon is very important if you dont have enough information about them. The small general information (regarding ROS2, colcon and cmake) provided in this README.md is very miniscule compared to what is actually required to programm for ROS2.

About

ROS2 Jazzy workspace directory containing multiple projects, all divided between libraries, packages and nodes.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages