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博客
SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. - ROS Answers: Open Source Q&A Forum
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
最后一行添加文章来源:https://www.toymoban.com/news/detail-447467.html
source ~/ros2_ws/install/setup.bash文章来源地址https://www.toymoban.com/news/detail-447467.html
到了这里,关于ROS2 工作空间 包的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!