ROS2 FOXY tutorial - Kraft2k/py_info_inv GitHub Wiki


ROS2 Invironment Setup
$ source /opt/ros/foxy/setup.bash


Create Python package

~ros2_ws/src$ ros2 pkg create my_py_pkg —build-type ament_python —dependencies rclpy


Create C++ package
~/ros2_ws/src$ ros2 pkg create my_cpp_pkg —build-type ament_cmake —dependencies rclpp


Create new package
~/ros2_ws/src$ ros2 pkg create my_new_pkg


Colcon Only [PKG_NAME ..]

~/ros2_ws$ colcon build –packages-select [PKG_NAME …]


Build selected packages including their dependencies

~/ros2_ws$ colcon build —packages-up-to [PKG_NAME …]


If ERROR: failed to create symbolic link ‘……’ because existing path cannot be removed: Is a directory

~/ros2_ws$ colcon build —packages-select [PKG_NAME …] —cmake-clean-cache


Create new Python node

~ros2_ws/src/my_py_pkg/my_py_pkg$ touch my_py_node.py


Change mode executable Python node
~ros2_ws/src/my_py_pkg/my_py_pkg$ chmod +x my_py_node.py


Run Python node
~ros2_ws/src/my_py_pkg/my_py_pkg$ ./my_py_node.py

colcon build —packages-select my_py_pkg —symlink-install
source ~/.bashrc

&&&&&
$ cat ~/.bashrc

$ ros2 node list

$ ros2 node info /py_test


Rename a node at Runtime
$ ros2 run my_py_pkg py_node —ros-args –remap __node:=abc
$ ros2 run my_py_pkg py_node —ros-args –r __node:=node2

⚠️ **GitHub.com Fallback** ⚠️