source /opt/ros/humble/setup.bash
colcon
sudo apt install python3-colcon-common-extensions
创建工作空间
mkdir -p ~/ros2_ws/src
编译
ros2_ws目录下
colcon build
创建包
ros2 pkg create --build-type ament_python --node-name my_node test_kiki
编译失败
Starting >>> test_kiki
--- stderr: test_kiki
/usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
---
Finished <<< test_kiki [1.29s]
Summary: 1 package finished [1.55s]
1 package had stderr output: test_kiki
解决 参考
ROS2 delete package_ros删除package-CSDN博客
python3
>>> import setuptools
>>> print(setuptools.__version__)
如果高于 58.2.0 则降级
quit()退出python3环境
pip install setuptools==58.2.0
提示安装pip
sudo apt install python3-pip
colcon build --packages-select test_kiki
Starting >>> test_kiki
Finished <<< test_kiki [1.20s]
Summary: 1 package finished [1.43s]
新窗口中
source ./install/local_setup.bash
ros2 run test_kiki my_node
Hi from test_kiki.
ps: 可以添加到bashrc 不用每次 source
sudo gedit ~/.bashrc
最后一行添加
source ~/ros2_ws/install/setup.bash