Welcome to the Robot Programming with ROS2 repository. This repository contains the source code examples and extended project materials based on the book "A Concise Introduction to Robot Programming with ROS2" by Francisco Martín Rico. This project aims to provide a comprehensive guide and additional resources for readers and practitioners of the book to deepen their understanding of robot programming using ROS2.
"A Concise Introduction to Robot Programming with ROS2" offers readers a structured and clear introduction to robot programming with ROS2.
Order the book here: Book
This repository extends and provides solutions to some issues found in the original book's repository. You can find the original source code and materials at fmrico/book_ros2.
This repository is tested and maintained for the Humble Hawksbill branch, requiring:
- Ubuntu 22.04 LTS
- ROS2 Humble Hawksbill
Follow these steps to set up your environment and start with the robot programming projects:
locale
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
localesudo apt install software-properties-common
sudo add-apt-repository universe
sudo apt update && sudo apt install curl -ysudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpgecho "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/nullsudo apt-get update
sudo apt upgrade
sudo apt install ros-humble-desktopsource /opt/ros/humble/setup.bash
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrcsudo apt install -y python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential python3-vcstool python3-colcon-common-extensionssudo rosdep init
rosdep updatemkdir -p ~/bookros2_ws/src
cd ~/bookros2_ws/src
git clone https://github.com/eather0056/Robot-Programming-with-ROS2.gitcd ~/bookros2_ws/src
vcs import . < Robot-Programming-with-ROS2/third_parties.reposcd ~/bookros2_ws
rosdep install --from-paths src --ignore-src -r -y
sudo apt update
colcon build --symlink-installActivate workspace as an overlay
source ~/bookros2_ws/install/setup.bashActivating by default when opening a terminal
echo "source ~/bookros2_ws/install/setup.bash" >> ~/.bashrcIf you want to skip rebuilding packages that haven't had any changes since the last build in order to save time, you can use
colcon build --symlink-install --packages-up-to <package_name>You must re-source the workspace since you have created a new program.
See the messages that are published
ros2 run rqt_console rqt_console
ros2 run rqt_graph rqt_graphif any unwaned node running and overring your current mssages then you migh need to terminate the process ID(PID)
kill -SIGINT <PID>You can find running processes by
ps auxor specific one like joystick_relay
ps aux | grep joystick_relayAfter installation, you can explore the various packages and launch files included in this repository. Each chapter of the book corresponds to specific packages and examples. Refer to the book for detailed explanations and instructions on running the examples.
Contributions to this repository are welcome. Please submit issues and pull requests with any suggestions, bug reports, or new content you believe would be beneficial for others learning ROS2.
