(訳注:最新の情報は原文を参照してください.)

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: データを記録し,リプレイをする

シンプルなサービスとクライアントの実行

サービスの起動

サービスを起動してみましょう:

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

以下のように表示されます:

Ready to add two ints.

クライアントの起動

必要な引数を渡して,クライアントを起動しましょう:

$ rosrun beginner_tutorials add_two_ints_client 1 3     (C++)
$ rosrun beginner_tutorials add_two_ints_client.py 1 3  (Python) 

以下のように表示されます:

# サービス側
[ INFO] [1412591805.265944566]: request: x=1, y=3
[ INFO] [1412591805.265979694]: sending back response: [4]
---------------------------------------------------------------
# クライアント側
[ INFO] [1412591805.266140878]: Sum: 4

これで、サーバとクライアントの初めての実行を首尾よく済ませたので、次はどのようにデータを記録し、リプレイするかを学びましょう。

サーバーとクライアントノードの更なる例

さらに詳しく知りたくて手軽なサンプルが欲しい場合はここを参照すると良いでしょう.シンプルなクライアントとサーバーの形式で、独自のメッセージ型の使い方を見られます. サービスのノードは C++ で書かれていますが,クライアントに C++、Python、LISP を用いることができます.

Wiki: ja/ROS/Tutorials/ExaminingServiceClient (last edited 2015-10-13 08:39:55 by ShunYasunaga)