plasmodic/ecto

Buffer/Queue Cell

stwirth opened this issue · 8 comments

In many applications some sensor input has to be buffered for further processing, i.e. an algorithm needs not only the current but also N past sensor values for processing. An example would be a median/mean/etc. filter of a fixed width.
Is there some functionality in ecto for that? If not, I am willing to write a cell that does that:
Input: any type
Params: number of values to buffer
Output: N outputs of same type as input, dependent on the number of values given as param.
This cell would gather N inputs before writing anything to the output. The output could be a vector as well, what do you suggest?

Maybe just construct a cell that outputs a circular buffer of type T. You'd
need to instantiate it for your T. As I recall there is a circular buffer
in boost somewhere. A circular buffer of tendrils would be possible but a
hassle to work with if you cared what was in them...
On May 25, 2012 1:57 PM, "Stephan" <
reply@reply.github.com>
wrote:

In many applications some sensor input has to be buffered for further
processing, i.e. an algorithm needs not only the current but also N past
sensor values for processing. An example would be a median/mean/etc. filter
of a fixed width.
Is there some functionality in ecto for that? If not, I am willing to
write a cell that does that:
Input: any type
Params: number of values to buffer
Output: N outputs of same type as input, dependent on the number of values
given as param.
This cell would gather N inputs before writing anything to the output. The
output could be a vector as well, what do you suggest?


Reply to this email directly or view it on GitHub:
#204

Hm, or a std::deque.
On May 25, 2012 3:52 PM, "Troy Straszheim" troy@industrial-perception.com
wrote:

Maybe just construct a cell that outputs a circular buffer of type T.
You'd need to instantiate it for your T. As I recall there is a circular
buffer in boost somewhere. A circular buffer of tendrils would be possible
but a hassle to work with if you cared what was in them...
On May 25, 2012 1:57 PM, "Stephan" <
reply@reply.github.com>
wrote:

In many applications some sensor input has to be buffered for further
processing, i.e. an algorithm needs not only the current but also N past
sensor values for processing. An example would be a median/mean/etc. filter
of a fixed width.
Is there some functionality in ecto for that? If not, I am willing to
write a cell that does that:
Input: any type
Params: number of values to buffer
Output: N outputs of same type as input, dependent on the number of
values given as param.
This cell would gather N inputs before writing anything to the output.
The output could be a vector as well, what do you suggest?


Reply to this email directly or view it on GitHub:
#204

If i just want to pass a "delayed" value, not the whole buffer: is it possible to write the cell independent of the type of input/output? Just like the passthrough cell but with a buffer in between.

Sure, deque of tendrils ought to do it

On Fri, May 25, 2012 at 5:02 PM, Stephan <
reply@reply.github.com

wrote:

If i just want to pass a "delayed" value, not the whole buffer: is it
possible to write the cell independent of the type of input/output? Just
like the passthrough cell but with a buffer in between.


Reply to this email directly or view it on GitHub:
#204 (comment)

Troy Straszheim
Cofounder, CEO
Industrial Perception, Inc.

Could you please have a look at my implementation and tell me what's wrong?
https://github.com/stwirth/ecto/compare/delay_cell
The second test of test_delay.py does not work as expected, the output of the adder is always 0.

On Fri, May 25, 2012 at 5:58 PM, Stephan <
reply@reply.github.com

wrote:

Could you please have a look at my implementation and tell me what's wrong?
https://github.com/stwirth/ecto/compare/delay_cell
The second test of test_delay.py does not work as expected, the output of
the adder is always 0.


Reply to this email directly or view it on GitHub:
#204 (comment)

It looks like the ecto bits are correct. You might use std::deque and
push_front/pop_back to be sure you're using the datastructure the right
way. Print its contents and all that.

Troy Straszheim
Cofounder, CEO
Industrial Perception, Inc.

Thanks! I forgot to return ecto::OK. What is the right way to return from process() when the outputs are not touched? return ecto::BREAK, return ecto::CONTINUE? When I always return ecto::OK, the first N outputs of my Delay cell are None values which the subsequent cells (like Add) do not like. I thought process would not be called on cells whose inputs are not set.

Well, that makes sense but we usually just deal with that by stacking
things into member variables.
(cf
https://github.com/wg-perception/tod/blob/master/src/training/ModelStacker.cpp
)

If you feel like writing a cell, please ! Maybe it should take a vector or
N outputs ? (or list maybe to make it more efficient)

On Fri, May 25, 2012 at 6:57 AM, Stephan <
reply@reply.github.com

wrote:

In many applications some sensor input has to be buffered for further
processing, i.e. an algorithm needs not only the current but also N past
sensor values for processing. An example would be a median/mean/etc. filter
of a fixed width.
Is there some functionality in ecto for that? If not, I am willing to
write a cell that does that:
Input: any type
Params: number of values to buffer
Output: N outputs of same type as input, dependent on the number of values
given as param.
This cell would gather N inputs before writing anything to the output. The
output could be a vector as well, what do you suggest?


Reply to this email directly or view it on GitHub:
#204