Triggering an external component

Hello,

We would like to write a controller Component that sends multiple
pieces of data to a subcontroller. The parent controller generates a
new set of data every millisecond. We would like each piece of data to
be transferred over its own connection (as opposed to being part of a
large struct that is sent to a single port). We wish to trigger the
subcontroller's updateHook() when it has a complete set of data.

Since the data is transferred over multiple ports, we are thinking of
having a separate eventport in the subcontroller that can be pinged by
the parent controller to trigger the subcontroller's updateHook().

Alternatively, if we could somehow give the parent controller access
to the subcontroller's TaskContext, we could directly call the
subcontroller's updateHook() from within the parent controller. Or, we
could mash all data into a single struct and have a single event-based
data port, but we think it would be easier to write controllers if
each piece of data is passed over its own connection.

What is the "correct" way to trigger the subcontroller?

Soo-Hyun Yoo
Dynamic Robotics Laboratory
Oregon State University

Triggering an external component

Hi Soo-Hyun Yoo,

On Mon, Jul 9, 2012 at 10:41 PM, Soo-Hyun Yoo <yoos117 [..] ...> wrote:
>
> Hello,
>
> We would like to write a controller Component that sends multiple
> pieces of data to a subcontroller. The parent controller generates a
> new set of data every millisecond. We would like each piece of data to
> be transferred over its own connection (as opposed to being part of a
> large struct that is sent to a single port). We wish to trigger the
> subcontroller's updateHook() when it has a complete set of data.
>
> Since the data is transferred over multiple ports, we are thinking of
> having a separate eventport in the subcontroller that can be pinged by
> the parent controller to trigger the subcontroller's updateHook().

That would work.

>
> Alternatively, if we could somehow give the parent controller access
> to the subcontroller's TaskContext, we could directly call the
> subcontroller's updateHook() from within the parent controller.

Just make the subcontroller a peer of the parent controller and then
use this->getPeer("subcontrollername") in the parent controller to get
a pointer to the task context. Calling updateHook() directly is not at
all advised. Please call peer->update() which will call updateHook if
you assign a slave activity to the subcontroller.

> Or, we
> could mash all data into a single struct and have a single event-based
> data port, but we think it would be easier to write controllers if
> each piece of data is passed over its own connection.

It depends... you probably have this insight because outport-type must
equal inport-type, and smaller structs are easier to agree on across
components ?

Peter

Triggering an external component

On Wed, Jul 11, 2012 at 1:30 PM, Peter Soetens <peter [..] ...> wrote:
> Hi Soo-Hyun Yoo,
>>
>> Alternatively, if we could somehow give the parent controller access
>> to the subcontroller's TaskContext, we could directly call the
>> subcontroller's updateHook() from within the parent controller.
>
> Just make the subcontroller a peer of the parent controller and then
> use this->getPeer("subcontrollername") in the parent controller to get
> a pointer to the task context. Calling updateHook() directly is not at
> all advised. Please call peer->update() which will call updateHook if
> you assign a slave activity to the subcontroller.

This is what we are looking for. Thank you!

>
>> Or, we
>> could mash all data into a single struct and have a single event-based
>> data port, but we think it would be easier to write controllers if
>> each piece of data is passed over its own connection.
>
> It depends... you probably have this insight because outport-type must
> equal inport-type, and smaller structs are easier to agree on across
> components ?

The reasoning behind having individual ports was that it would
decrease the number of message types we would have to compile, but
after some more thought, we've decided that a single pair of ports
between any two subcontrollers will be easy enough.

>
> Peter

Triggering an external component

On Jul 9, 2012, at 17:41 , Soo-Hyun Yoo wrote:

> Hello,
>
> We would like to write a controller Component that sends multiple
> pieces of data to a subcontroller. The parent controller generates a
> new set of data every millisecond. We would like each piece of data to
> be transferred over its own connection (as opposed to being part of a
> large struct that is sent to a single port). We wish to trigger the
> subcontroller's updateHook() when it has a complete set of data.
>
> Since the data is transferred over multiple ports, we are thinking of
> having a separate eventport in the subcontroller that can be pinged by
> the parent controller to trigger the subcontroller's updateHook().
>
> Alternatively, if we could somehow give the parent controller access
> to the subcontroller's TaskContext, we could directly call the
> subcontroller's updateHook() from within the parent controller. Or, we
> could mash all data into a single struct and have a single event-based
> data port, but we think it would be easier to write controllers if
> each piece of data is passed over its own connection.
>
> What is the "correct" way to trigger the subcontroller?

There is never just one "correct" way ...
- your event port would work
- using a slave activity for the subcontroller, and have the master controller trigger the update hook explicitly.
- ...

HTH
S