1.1运行发布者
首先运行roscore:
$ rosrun
在尝试使用你的应用前,请确认你已经在调用catkin_make后启用了你工作空间的setup.sh文件.(最好将它写入~/.bashrc文件)
# In your catkin workspace
$ cd ~/catkin_ws
$ source ./devel/setup.bash
现在运行上一篇教程中创建的叫做”talker”的发布者:
$rosrun beginner_tutorials talker (C++)
你将会看到类似于:
[INFO] [WallTime: 1314931831.774057] hello world 1314931831.77
[INFO] [WallTime: 1314931832.775497] hello world 1314931832.77
[INFO] [WallTime: 1314931833.778937] hello world 1314931833.78
[INFO] [WallTime: 1314931834.782059] hello world 1314931834.78
[INFO] [WallTime: 1314931835.784853] hello world 1314931835.78
[INFO] [WallTime: 1314931836.788106] hello world 1314931836.79
发布者node在运行,现在需要运行从发布者接收message的订阅者:
1.2运行订阅者
运行上一个教程中创建的叫做”listneer”的订阅者:
$rosrun beginner_tutorials listener (C++)
你将会看到类似于这样的输出:
INFO] [WallTime: 1314931969.258941] /listener_17657_1314931968795I heard hello world 1314931969.26
[INFO] [WallTime: 1314931970.262246] /listener_17657_1314931968795I heard hello world 1314931970.26
[INFO] [WallTime: 1314931971.266348] /listener_17657_1314931968795I heard hello world 1314931971.26
[INFO] [WallTime: 1314931972.270429] /listener_17657_1314931968795I heard hello world 1314931972.27
[INFO] [WallTime: 1314931973.274382] /listener_17657_1314931968795I heard hello world 1314931973.27
[INFO] [WallTime: 1314931974.277694] /listener_17657_1314931968795I heard hello world 1314931974.28
[INFO] [WallTime: 1314931975.283708] /listener_17657_1314931968795I heard hello world 1314931975.28
至此,你已经验证了一个简单的发布者这和订阅者.