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

用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
    原文作者:曹博博
    原文地址: https://www.jianshu.com/p/5f63d2ba2c7f
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞