ROS2配置python虚拟环境
项目需求需要使用python写一个3D检测的ROS2节点,通过修改ROS2的配置文件来间接的让系统使用虚拟环境中的Python解释器。
·
说明
项目需求需要使用python写一个3D检测的ROS2节点,通过修改ROS2的配置文件来间接的让系统使用虚拟环境中的Python解释器
参考链接:ROS2虚拟环境配置指南
步骤
- 修改setup.cfg文件,添加如下配置
# src/{node}/setup.cfg
[build_scripts]
executable = /usr/bin/env python3
- 创建虚拟环境 在创建虚拟环境时,需要将系统环境中的ROS2包链接到虚拟环境中
python3 -m venv your_venv_name --system-site-packages --symlinks
- 激活ros2环境配置和虚拟环境配置
source /opt/ros/foxy/setup.zsh
source ./venv/bin/activate
- colcon build并运行
colcon build
source install/setup.bash
ros2 run package_name node_name
更多推荐
所有评论(0)