[Documentation] [TitleIndex] [WordIndex

Note: This tutorial assumes that you have completed the previous tutorials: 写一个简单的消息发布器和订阅器 (python) (c++).
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

测试消息发布器和订阅器

Description: 本教程将测试上一教程所写的消息发布器和订阅器。

Tutorial Level: BEGINNER

Next Tutorial: 写一个简单的服务端和客户端 (python) (c++)

启动发布器

确保roscore可用,并运行:

$ roscore

catkin specific 如果使用catkin,确保你在调用catkin_make后,在运行你自己的程序前,已经source了catkin工作空间下的setup.sh文件:

# In your catkin workspace
$ cd ~/catkin_ws
$ source ./devel/setup.bash

In the last tutorial we made a publisher called "talker". Let's run it:

$ rosrun beginner_tutorials talker      (C++)
$ rosrun beginner_tutorials talker.py   (Python) 

你将看到如下的输出信息:

发布器节点已经启动运行。现在需要一个订阅器节点来接受发布的消息。

启动订阅器

上一教程,我们编写了一个名为"listener"的订阅器节点。现在运行它:

$ rosrun beginner_tutorials listener     (C++)
$ rosrun beginner_tutorials listener.py  (Python) 

你将会看到如下的输出信息:

你已经测试完了发布器和订阅器,下面我们来编写一个服务和客户端(python) (c++).


2019-10-19 12:34