美文网首页Ubuntu学步者ubuntuROS机器人操作系统
ROS 学习-5<消息发布器和订阅器>

ROS 学习-5<消息发布器和订阅器>

作者: 曹博博 | 来源:发表于2016-10-18 15:52 被阅读59次

用Python写一个简单的消息发布器和订阅器
先进入package,创建一个草稿文件夹,并进入这个文件夹下面

roscd beginner_tutorials
mkdir scripts
cd scripts

从网上下载python脚本,并编译

wget https://raw.github.com/ros/ros_tutorials/kinetic-devel/rospy_tutorials/001_talker_listener/talker.py
chmod +x talker.py
#上面的是talker脚本
wget https://raw.github.com/ros/ros_tutorials/kinetic-devel/rospy_tutorials/001_talker_listener/listener.py
chmod +x listener.py
#这个是listener的脚本

然后总体进行 catkinmake 节点

cd ~/catkin_ws
catkin_make

验证:

1.Running the Publisher

Make sure that a roscore is up and running:

 roscore

先source一下

# In your catkin workspace
cd ~/catkin_ws
source ./devel/setup.bash
rosrun beginner_tutorials talker.py

2.Running the Subscriber

如果没source,也要先source一下

rosrun beginner_tutorials listener.py

相关文章

网友评论

    本文标题:ROS 学习-5<消息发布器和订阅器>

    本文链接:https://www.haomeiwen.com/subject/btktuttx.html