Loading the lesson...
In the print dialog, choose "Save as PDF" as the destination.
ROS 2 Practical - Lesson 1
The ROS 2 workspace, package, and node model
Workspace
Belongs to an organization or project
Package
Responsible for one specific task, e.g. robot controller or camera driver
Node
Talks to other nodes using pub-sub messaging
colcon is the CLI build tool for ROS 2sudo sh -c 'echo "deb [arch=amd64,arm64] http://repo.ros2.org/ubuntu/main `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo apt update
sudo apt install python3-colcon-common-extensions
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bashsrc/ directorycolcon build compiles everything inside src/install/setup.bash must be sourced to use built packagesmkdir -p ros_ws/src
cd ros_ws
colcon build
source install/setup.bashros2 pkg create--build-type ament_python flag and the rclpy dependency# C++ package
ros2 pkg create my_first_pkg
# Python package
ros2 pkg create my_first_py_pkg --build-type ament_python --dependencies rclpychmod +xtouch ./my_first_py_pkg/my_first_py_pkg/my_first_node.py
chmod +x ./my_first_py_pkg/my_first_py_pkg/my_first_node.pyrclpy init
Node class
spin
shutdown
setup.py so ros2 run can find itentry_points={
'console_scripts': [
"test_node = my_first_py_pkg.my_first_node:main"
],
},setup.py, using --symlink-install to avoid rebuilding on every Python code changeros2 runcolcon build --symlink-install
ros2 run my_first_py_pkg test_noderqt_graph visualizes running nodes and their pub/sub connectionsros2 node list lists all running nodesros2 node info shows details about a specific noderqt_graph
ros2 node list
ros2 node info /my_first_nodecolcon + ament is the standard build tool chain--symlink-install speeds up the Python dev loopentry_points in setup.pyrqt_graph, ros2 node list, and ros2 node info are your first debugging toolsMahmoud Abas|How it works ?