[openrtm-users 01431] Re: Regarding Subscription type in dataport

Geoffrey Biggs geoffrey.biggs @ aist.go.jp
2010年 10月 12日 (火) 09:17:06 JST


Hi Tony,

There are three types of publisher provided by default in OpenRTM-aist:

- Flush

As soon as you write data to the port, the data is written to the
connected ports. The write occurs in the thread of whoever calls
write(). This means that, if a write takes a while, it will delay your
component's execution. Do not use this publisher for components that
must meet their execution deadlines.

- New

Similar to the Flush publisher, but the write takes place in a separate
process. This publisher supports push policies (ALL, FIFO, SKIP and
NEW), because the task that performs the write may get its execution
time after several calls to write() have occurred. The ALL policy means
to push all available data in the buffer, one after another. The FIFO
policy will send one item from the buffer. The SKIP policy will skip a
certain number of items in the buffer, allowing (for example) every 5th
value to be sent. The NEW policy will send the newest value in the
buffer, ignoring any written previously.

- Periodic

This publisher runs a separate task performing the write at a configured
frequency. It will write data from the buffer according to the push
policy (see New, above) each time.


In addition, you can also control the buffer on the receiving end. This
is useful if the values will arrive faster than your component can
handle them. In the configuration file for your component (e.g.
mycomp.conf), add lines like the following:

# InPort's name is "in". OutPort's name is "out".
# The default length of the InPort’s buffer is 8.
port.inport.in.buffer.length: 1

# Policy controlling what to do when the buffer is empty:
# readback (default), do_nothing, block
port.inport.in.buffer.read.empty_policy: block


You will need to add lines to the rtc.conf file to tell it that this
configuration file is for your component:

comp_category.comp_name.config_file: mycomp.conf


For your situation, I recommend using either the Flush or New publisher
(use New if your component cannot be allowed to block) and setting the
buffer on the receiving end to 1. You could also use a pull connection,
but this will delay the receiving component while the data is transferred.

Don't forget that you can also write your own publishers and load them
as plugins.

Geoff


On 10/10/10 11:55, Tony Kuo wrote:
> Dear OpenRTM ML:
> 
> I have always been using the default flush subscription type when i
> connect my components in RTSystemEditor.
> But I don't know how is it different to the "new" subscription type?
> 
> I found a slide that explains that but is not clear.
> slide 19 on
> http://www.openrtm.org/OpenRTM-aist/download/resume/070523/070523-01.pdf
> 
> What I actually want to do is,
> I wanna make sure whenever I read data in from one of the data port in
> my component, I get the newest data no matter how many data are already
> in the connector buffer (i.e. discard all except the newest one)
> 
> If you can point me in the right direction,
> it's very much appreciated!
> 
> Thanks
> Tony
> 



openrtm-users メーリングリストの案内