【ROS】如何在ROS中使用anaconda虚拟环境?

本文介绍了如何在虚拟环境中安装和管理ROS(Robot Operating System)及其Python依赖。通过创建测试工作空间、软件包,演示了从原生环境到虚拟环境的过渡。在虚拟环境中,需要额外安装`rospkg`、`rospy`、`catkin_tools`来支持ROS运行,然后通过`pip`安装缺失的Python包如`scipy`,以确保所有代码能正常运行。

先上结论:只需要在虚拟环境中安装以下几个包。

pip install rospkg rospy catkin_tools

以下是探索过程:

1. 建立测试的工作空间、软件包。

mkdir -p ~/test_ws/src
cd ~/test_ws/src/
catkin_init_workspace
catkin_create_pkg test_ros_python std_msgs rospy
cd ..
catkin_make
echo "source ~/test_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc

创建测试代码。

roscd test_ros_python/
mkdir scripts
touch test_ros_python.py
chmod +x test_ros_python.py

 其中的内容来自官方教程中使用python创建发布者

#!/usr/bin/env python
# license removed for brevity
import rospy
from std_msgs.msg import String

def talker():
    pub = rospy.Publisher('chatter', String, queue_size=
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Guo_Zhanyu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值