用Python寫一個(gè)簡(jiǎn)單的消息發(fā)布器和訂閱器
先進(jìn)入package岸更,創(chuàng)建一個(gè)草稿文件夾漩蟆,并進(jìn)入這個(gè)文件夾下面
roscd beginner_tutorials
mkdir scripts
cd scripts
從網(wǎng)上下載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
#這個(gè)是listener的腳本
然后總體進(jìn)行 catkinmake 節(jié)點(diǎn)
cd ~/catkin_ws
catkin_make
驗(yàn)證:
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
如果沒(méi)source,也要先source一下
rosrun beginner_tutorials listener.py