用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
网友评论