How the data ports share data with service ports?

4 個の投稿 / 0 new
最終投稿
Amigoshan
オフライン
Last seen: 9年 5ヶ月 前
登録日: 2011-12-01 14:18
How the data ports share data with service ports?

Dear all:

I’m writing a component that containing both data port and service port.

Actually it is a camera for robot tracking. And the data port is used for outputing the location of the robot. While the service port provides an interface for querying whether the robot is insight or not.

I program this with C++ language. In the onExecute() function, I do the vision processing and have a variable storing whether the robot is insight or not. The problem is, in the getStateSVC_impl.cpp where the code for the service port is implemented, I don’t want to do the vision processing again. I would rather use the result from onExecute() function, which is real-time enough. But I can not get the variable in onExecute() function because I can not have an object of it. Since the framework of getStateSVC_impl.cpp is automatically generated by the RTBuilder, I’m not sure if the constructor function can be added with extra parameters, which allow me to pass some object into this class.

My compromising way to solve this is to use static variable. But as the functionality of the service port gets more complicated, more and more static variables are needed, and even static functions are needed. Please help me if there are any better solution.

Thank you very much!

Wenshan

未定義
Ando Noriaki
オフライン
Last seen: 1年 8ヶ月 前
登録日: 2011-09-04 17:20
[openrtm-users 02840] How the data ports share data with servic

Hello,

Since there are no limitation for the constructor of service provider
implementation, in order to get/set some variables in the component
class, you can give a pointer to the service implementation class
(getState class) in the constructor.

But sharng variables between the component class and the service
provider implementation class through static variables and static
functions is dangerous. If you have two or more components in one
process, your strategy would fail.

A reasonable way is the following.
1. Making a class (ex. ImageProcesing) for your image processing core logic.
2. Instantiate the ImageProcessing class in the your component class.
3. When instantiating the service provider class (getState), give the
pinter of the ImageProcessing to the getState class.
4. Do all the operations (processing, getting data, setting parameters
and so on) through member functions of the ImageProcessing class
when you need data/parameters/functions of the ImageProcessing class
in onXXXXX() and/or service provider functions.

Attached figure shows a class diagram of the structure.

Best regards,
Noriaki Ando

2013/7/6 :
> Dear all: I’m writing a component that containing both data port and
> service port. Actually it is a camera for robot tracking. And the data port
> is used for outputing the location of the robot. While the service port
> provides an interface for querying whether the robot is insight or not. I
> program this with C++ language. In the onExecute() function, I do the vision
> processing and have a variable storing whether the robot is insight or not.
> The problem is, in the getStateSVC_impl.cpp where the code for the service
> port is implemented, I don’t want to do the vision processing again. I
> would rather use the result from onExecute() function, which is real-time
> enough. But I can not get the variable in onExecute() function because I can
> not have an object of it. Since the framework of getStateSVC_impl.cpp is
> automatically generated by the RTBuilder, I’m not sure if the constructor
> function can be added with extra parameters, which allow me to pass some
> object into this class. My compromising way to solve this is to use static
> variable. But as the functionality of the service port gets more
> complicated,
> more and more static variables are needed, and even static functions are
> needed. Please help me if there are any better solution. Thank you very
> much!
> Wenshan
>
> _______________________________________________
> openrtm-users mailing list
> openrtm-users@openrtm.org
> http://www.openrtm.org/mailman/listinfo/openrtm-users

Comment Upload: 
添付サイズ
イメージアイコン imageprocessing.png0 byte
Amigoshan
オフライン
Last seen: 9年 5ヶ月 前
登録日: 2011-12-01 14:18
re:Ando Noriaki

I'm so grateful for your patient explaination and expert solution! I've tried your way and it solved my problem. You help me out again.

Best wishes!

Wenshan

Amigoshan
オフライン
Last seen: 9年 5ヶ月 前
登録日: 2011-12-01 14:18
[openrtm-users 02841] Ando Noriaki

I'm so grateful for your patient explaination and expert solution! I've tried
your way and is solved my problem. You help me out again. Best wishes!
Wenshan

_______________________________________________
openrtm-users mailing list
openrtm-users@openrtm.org
http://www.openrtm.org/mailman/listinfo/openrtm-users

コメントを投稿するにはログインまたはユーザー登録を行ってください

ダウンロード

最新バージョン : 2.0.1-RELESE

統計

Webサイト統計
ユーザ数:2160
プロジェクト統計
RTコンポーネント307
RTミドルウエア35
ツール22
文書・仕様書2

Choreonoid

モーションエディタ/シミュレータ

OpenHRP3

動力学シミュレータ

OpenRTP

統合開発プラットフォーム

産総研RTC集

産総研が提供するRTC集

TORK

東京オープンソースロボティクス協会

DAQ-Middleware

ネットワーク分散環境でデータ収集用ソフトウェアを容易に構築するためのソフトウェア・フレームワーク