Create a ROS 2 Workspace
Create Your First ROS 2 Workspace
mkdir -p "$HOME/ros2_ws/src"
cd "$HOME/ros2_ws/src"
ros2 pkg create \
--build-type ament_python \
--node-name hello_node \
my_first_pkg
cd "$HOME/ros2_ws"
colcon build --symlink-install
source install/setup.bashRun the node you just created:
ros2 run my_first_pkg hello_nodeWhenever you use this workspace in the future, run:
source /opt/ros/humble/setup.bash
source "$HOME/ros2_ws/install/setup.bash"You can also add the workspace environment to ~/.bashrc:
grep -Fqx 'source "$HOME/ros2_ws/install/setup.bash"' "$HOME/.bashrc" || \
printf '%s\n' 'source "$HOME/ros2_ws/install/setup.bash"' >> "$HOME/.bashrc"ROS 2 Humble Desktop, RViz2, the development tools, and the workspace are now ready to use.

