Port with polymorphic type

Hi all.

I'm rather new to Orocos and trying to make it work in a project I've been
working on.

I have a set of components that need to report to a supervisor component.
Problem is, the data they would need to pass is not fixed... and that's why
I need to use a polymorphic type in a port. The idea is to avoid having lots
and lots of ports (one port for each type for each component).

The drawback on this approach is that we would need some sort of real time
safe factory to manage the creation and destruction of the data (which I
think is somewhat doable).

Another bad point is that intra process communication wouldn't be possible
since we're reading by value.

Any ideas on this matter?

Jordan.

Port with polymorphic type

On Wed, 12 Jan 2011, Jordan Palacios wrote:

> Hi all.
>
> I'm rather new to Orocos and trying to make it work in a project I've been
> working on.
>
> I have a set of components that need to report to a supervisor component.
> Problem is, the data they would need to pass is not fixed... and that's why I
> need to use a polymorphic type in a port. The idea is to avoid having lots and
> lots of ports (one port for each type for each component).
>
> The drawback on this approach is that we would need some sort of real time safe
> factory to manage the creation and destruction of the data (which I think is
> somewhat doable).

If you want realtime performance, than just foresee a message that is as
large as the largest object you want to communicate, so that you can always
reuse the same data structures, without the need for dynamic
creation/deletion.

> Another bad point is that intra process communication wouldn't be possible since
> we're reading by value.

What do you mean exactly? Since ports _are_ used for intra process
communication (depending on what "middleware" you use).

> Any ideas on this matter?
>
> Jordan.

Herman

Port with polymorphic type

Thanks for your response.

Sorry, my mistake. I meant inter process communication.

Jordan.

On Wed, Jan 12, 2011 at 7:07 PM, Herman Bruyninckx <
Herman [dot] Bruyninckx [..] ...> wrote:

> On Wed, 12 Jan 2011, Jordan Palacios wrote:
>
> Hi all.
>>
>> I'm rather new to Orocos and trying to make it work in a project I've been
>> working on.
>>
>> I have a set of components that need to report to a supervisor component.
>> Problem is, the data they would need to pass is not fixed... and that's
>> why I
>> need to use a polymorphic type in a port. The idea is to avoid having lots
>> and
>> lots of ports (one port for each type for each component).
>>
>> The drawback on this approach is that we would need some sort of real time
>> safe
>> factory to manage the creation and destruction of the data (which I think
>> is
>> somewhat doable).
>>
>
> If you want realtime performance, than just foresee a message that is as
> large as the largest object you want to communicate, so that you can always
> reuse the same data structures, without the need for dynamic
> creation/deletion.
>
>
> Another bad point is that intra process communication wouldn't be possible
>> since
>> we're reading by value.
>>
>
> What do you mean exactly? Since ports _are_ used for intra process
> communication (depending on what "middleware" you use).
>
>
> Any ideas on this matter?
>>
>> Jordan.
>>
>
> Herman
>

Port with polymorphic type

On Wed, Jan 12, 2011 at 19:07, Herman Bruyninckx <
Herman [dot] Bruyninckx [..] ...> wrote:

> On Wed, 12 Jan 2011, Jordan Palacios wrote:
>
> > Hi all.
> >
> > I'm rather new to Orocos and trying to make it work in a project I've
> been
> > working on.
> >
> > I have a set of components that need to report to a supervisor component.
> > Problem is, the data they would need to pass is not fixed... and that's
> why I
> > need to use a polymorphic type in a port. The idea is to avoid having
> lots and
> > lots of ports (one port for each type for each component).
> >
> > The drawback on this approach is that we would need some sort of real
> time safe
> > factory to manage the creation and destruction of the data (which I think
> is
> > somewhat doable).
>
> If you want realtime performance, than just foresee a message that is as
> large as the largest object you want to communicate, so that you can always
> reuse the same data structures, without the need for dynamic
> creation/deletion.
>

Take a look at Boost.Variant library - variant is "multi-type, single
value."
This is a object-oriented improvement of the "union" concept from old plain
C.

>
> > Another bad point is that intra process communication wouldn't be
> possible since
> > we're reading by value.
>
> What do you mean exactly? Since ports _are_ used for intra process
> communication (depending on what "middleware" you use).
>
> > Any ideas on this matter?
> >
> > Jordan.
>
> Herman
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>

Port with polymorphic type

On Thu, Jan 13, 2011 at 1:52 PM, Piotr Trojanek <piotr [dot] trojanek [..] ...>wrote:

> On Wed, Jan 12, 2011 at 19:07, Herman Bruyninckx <
> Herman [dot] Bruyninckx [..] ...> wrote:
>
>> On Wed, 12 Jan 2011, Jordan Palacios wrote:
>>
>> > Hi all.
>> >
>> > I'm rather new to Orocos and trying to make it work in a project I've
>> been
>> > working on.
>> >
>> > I have a set of components that need to report to a supervisor
>> component.
>> > Problem is, the data they would need to pass is not fixed... and that's
>> why I
>> > need to use a polymorphic type in a port. The idea is to avoid having
>> lots and
>> > lots of ports (one port for each type for each component).
>> >
>> > The drawback on this approach is that we would need some sort of real
>> time safe
>> > factory to manage the creation and destruction of the data (which I
>> think is
>> > somewhat doable).
>>
>> If you want realtime performance, than just foresee a message that is as
>> large as the largest object you want to communicate, so that you can
>> always
>> reuse the same data structures, without the need for dynamic
>> creation/deletion.
>>
>
> Take a look at Boost.Variant library - variant is "multi-type, single
> value."
> This is a object-oriented improvement of the "union" concept from old plain
> C.
>
>
>>
>> > Another bad point is that intra process communication wouldn't be
>> possible since
>> > we're reading by value.
>>
>> What do you mean exactly? Since ports _are_ used for intra process
>> communication (depending on what "middleware" you use).
>>
>> > Any ideas on this matter?
>> >
>> > Jordan.
>>
>> Herman
>> --
>> Orocos-Users mailing list
>> Orocos-Users [..] ...
>> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>>
>
> --
> Piotr Trojanek
> Robot Control and Recognition Systems Team <http://robotics.ia.pw.edu.pl />,
>
> Institute of Control & Computation Engineering<http://www.ia.pw.edu.pl/iaiis_en />
> , <http://www.ia.pw.edu.pl />
> Warsaw University of Technology <http://eng.pw.edu.pl />
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>
>
Looked into that Boost Varian Library. Seems like it would be just what I
was looking for.

Thanks for your answer.

Jordan.

Port with polymorphic type

On Monday 17 January 2011 09:44:45 Jordan Palacios wrote:
> On Thu, Jan 13, 2011 at 1:52 PM, Piotr Trojanek
<piotr [dot] trojanek [..] ...>wrote:
> > On Wed, Jan 12, 2011 at 19:07, Herman Bruyninckx <
> >
> > Herman [dot] Bruyninckx [..] ...> wrote:
> >> On Wed, 12 Jan 2011, Jordan Palacios wrote:
> >> > Hi all.
> >> >
> >> > I'm rather new to Orocos and trying to make it work in a project I've
> >>
> >> been
> >>
> >> > working on.
> >> >
> >> > I have a set of components that need to report to a supervisor
> >>
> >> component.
> >>
> >> > Problem is, the data they would need to pass is not fixed... and
> >> > that's
> >>
> >> why I
> >>
> >> > need to use a polymorphic type in a port. The idea is to avoid having
> >>
> >> lots and
> >>
> >> > lots of ports (one port for each type for each component).
> >> >
> >> > The drawback on this approach is that we would need some sort of real
> >>
> >> time safe
> >>
> >> > factory to manage the creation and destruction of the data (which I
> >>
> >> think is
> >>
> >> > somewhat doable).
> >>
> >> If you want realtime performance, than just foresee a message that is as
> >> large as the largest object you want to communicate, so that you can
> >> always
> >> reuse the same data structures, without the need for dynamic
> >> creation/deletion.
> >
> > Take a look at Boost.Variant library - variant is "multi-type, single
> > value."
> > This is a object-oriented improvement of the "union" concept from old
> > plain C.
> >
> >> > Another bad point is that intra process communication wouldn't be
> >>
> >> possible since
> >>
> >> > we're reading by value.
> >>
> >> What do you mean exactly? Since ports _are_ used for intra process
> >> communication (depending on what "middleware" you use).
> >>
> >> > Any ideas on this matter?
> >> >
> >> > Jordan.
> >>
> >> Herman
> >> --
> >> Orocos-Users mailing list
> >> Orocos-Users [..] ...
> >> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
> >
> > --
> > Piotr Trojanek
> > Robot Control and Recognition Systems Team
> > <http://robotics.ia.pw.edu.pl />,
> >
> > Institute of Control & Computation
> > Engineering<http://www.ia.pw.edu.pl/iaiis_en />
> >
> > , <http://www.ia.pw.edu.pl />
> >
> > Warsaw University of Technology <http://eng.pw.edu.pl />
> >
> > --
> > Orocos-Users mailing list
> > Orocos-Users [..] ...
> > http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>
> Looked into that Boost Varian Library. Seems like it would be just what I
> was looking for.
>
> Thanks for your answer.

Note that this library will only work out of the box for intra-process
communication. You'll have to write your own typekit and type transport to
move the data between processes since neither of our transport code generators
(nor corba/typegen, nor ROS) can read boost::variant.

Writing a type transport yourself is doable, but not a 'walk in the park'.

>From a least effort/quickest result view, I would opt to make a larger struct
that can contain all cases your supervision system can handle and let the
components fill that in. In that case, you can use typegen to generate all code
for you and start off really fast.

Peter

Port with polymorphic type

Another drawback of boost.variant is that, because the never-empty
guarantee, the current implementation uses a temporary backup in the
heap possibly breaking RT.
See:
http://www.boost.org/doc/libs/1_40_0/doc/html/variant/design.html#varian...

Anyway, the next sections of the link explain how to avoid the problem.

On Mon, Jan 17, 2011 at 10:14, Peter Soetens <peter [..] ...> wrote:
> On Monday 17 January 2011 09:44:45 Jordan Palacios wrote:
>> On Thu, Jan 13, 2011 at 1:52 PM, Piotr Trojanek
> <piotr [dot] trojanek [..] ...>wrote:
>> > On Wed, Jan 12, 2011 at 19:07, Herman Bruyninckx <
>> >
>> > Herman [dot] Bruyninckx [..] ...> wrote:
>> >> On Wed, 12 Jan 2011, Jordan Palacios wrote:
>> >> > Hi all.
>> >> >
>> >> > I'm rather new to Orocos and trying to make it work in a project I've
>> >>
>> >> been
>> >>
>> >> > working on.
>> >> >
>> >> > I have a set of components that need to report to a supervisor
>> >>
>> >> component.
>> >>
>> >> > Problem is, the data they would need to pass is not fixed... and
>> >> > that's
>> >>
>> >> why I
>> >>
>> >> > need to use a polymorphic type in a port. The idea is to avoid having
>> >>
>> >> lots and
>> >>
>> >> > lots of ports (one port for each type for each component).
>> >> >
>> >> > The drawback on this approach is that we would need some sort of real
>> >>
>> >> time safe
>> >>
>> >> > factory to manage the creation and destruction of the data (which I
>> >>
>> >> think is
>> >>
>> >> > somewhat doable).
>> >>
>> >> If you want realtime performance, than just foresee a message that is as
>> >> large as the largest object you want to communicate, so that you can
>> >> always
>> >> reuse the same data structures, without the need for dynamic
>> >> creation/deletion.
>> >
>> > Take a look at Boost.Variant library - variant is "multi-type, single
>> > value."
>> > This is a object-oriented improvement of the "union" concept from old
>> > plain C.
>> >
>> >> > Another bad point is that intra process communication wouldn't be
>> >>
>> >> possible since
>> >>
>> >> > we're reading by value.
>> >>
>> >> What do you mean exactly? Since ports _are_ used for intra process
>> >> communication (depending on what "middleware" you use).
>> >>
>> >> > Any ideas on this matter?
>> >> >
>> >> > Jordan.
>> >>
>> >> Herman
>> >> --
>> >> Orocos-Users mailing list
>> >> Orocos-Users [..] ...
>> >> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>> >
>> > --
>> > Piotr Trojanek
>> > Robot Control and Recognition Systems Team
>> > <http://robotics.ia.pw.edu.pl />,
>> >
>> >  Institute of Control & Computation
>> >  Engineering<http://www.ia.pw.edu.pl/iaiis_en />
>> >
>> > , <http://www.ia.pw.edu.pl />
>> >
>> >  Warsaw University of Technology <http://eng.pw.edu.pl />
>> >
>> > --
>> > Orocos-Users mailing list
>> > Orocos-Users [..] ...
>> > http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>>
>> Looked into that Boost Varian Library. Seems like it would be just what I
>> was looking for.
>>
>> Thanks for your answer.
>
> Note that this library will only work out of the box for intra-process
> communication. You'll have to write your own typekit and type transport to
> move the data between processes since neither of our transport code generators
> (nor corba/typegen, nor ROS) can read boost::variant.
>
> Writing a type transport yourself is doable, but not a 'walk in the park'.
>
> >From a least effort/quickest result view, I would opt to make a larger struct
> that can contain all cases your supervision system can handle and let the
> components fill that in. In that case, you can use typegen to generate all code
> for you and start off really fast.
>
> Peter
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>

Port with polymorphic type

Indeed, I have not looked at the real-time penalty of Boost.Variant.

Solution that I use in my code (not related to the Orocos) is to have a big
structure and serialize
the right variant just before transporting to another node. The "right
variant" is chosen based on
the value of the discriminant field. This is easy to implement within
boost::serialization framework
that we rely on.

By the way - this solution is similar to the variant parts of the record in
Ada, which requires an explicit
discriminant.

On Mon, Jan 17, 2011 at 14:48, Carles Lopez
<carles [dot] lopez [..] ...>wrote:

> Another drawback of boost.variant is that, because the never-empty
> guarantee, the current implementation uses a temporary backup in the
> heap possibly breaking RT.
> See:
>
> http://www.boost.org/doc/libs/1_40_0/doc/html/variant/design.html#varian...
>
> Anyway, the next sections of the link explain how to avoid the problem.
>
> On Mon, Jan 17, 2011 at 10:14, Peter Soetens <peter [..] ...>
> wrote:
> > On Monday 17 January 2011 09:44:45 Jordan Palacios wrote:
> >> On Thu, Jan 13, 2011 at 1:52 PM, Piotr Trojanek
> > <piotr [dot] trojanek [..] ...>wrote:
> >> > On Wed, Jan 12, 2011 at 19:07, Herman Bruyninckx <
> >> >
> >> > Herman [dot] Bruyninckx [..] ...> wrote:
> >> >> On Wed, 12 Jan 2011, Jordan Palacios wrote:
> >> >> > Hi all.
> >> >> >
> >> >> > I'm rather new to Orocos and trying to make it work in a project
> I've
> >> >>
> >> >> been
> >> >>
> >> >> > working on.
> >> >> >
> >> >> > I have a set of components that need to report to a supervisor
> >> >>
> >> >> component.
> >> >>
> >> >> > Problem is, the data they would need to pass is not fixed... and
> >> >> > that's
> >> >>
> >> >> why I
> >> >>
> >> >> > need to use a polymorphic type in a port. The idea is to avoid
> having
> >> >>
> >> >> lots and
> >> >>
> >> >> > lots of ports (one port for each type for each component).
> >> >> >
> >> >> > The drawback on this approach is that we would need some sort of
> real
> >> >>
> >> >> time safe
> >> >>
> >> >> > factory to manage the creation and destruction of the data (which I
> >> >>
> >> >> think is
> >> >>
> >> >> > somewhat doable).
> >> >>
> >> >> If you want realtime performance, than just foresee a message that is
> as
> >> >> large as the largest object you want to communicate, so that you can
> >> >> always
> >> >> reuse the same data structures, without the need for dynamic
> >> >> creation/deletion.
> >> >
> >> > Take a look at Boost.Variant library - variant is "multi-type, single
> >> > value."
> >> > This is a object-oriented improvement of the "union" concept from old
> >> > plain C.
> >> >
> >> >> > Another bad point is that intra process communication wouldn't be
> >> >>
> >> >> possible since
> >> >>
> >> >> > we're reading by value.
> >> >>
> >> >> What do you mean exactly? Since ports _are_ used for intra process
> >> >> communication (depending on what "middleware" you use).
> >> >>
> >> >> > Any ideas on this matter?
> >> >> >
> >> >> > Jordan.
> >> >>
> >> >> Herman
> >> >> --
> >> >> Orocos-Users mailing list
> >> >> Orocos-Users [..] ...
> >> >> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
> >> >
> >> > --
> >> > Piotr Trojanek
> >> > Robot Control and Recognition Systems Team
> >> > <http://robotics.ia.pw.edu.pl />,
> >> >
> >> > Institute of Control & Computation
> >> > Engineering<http://www.ia.pw.edu.pl/iaiis_en />
> >> >
> >> > , <http://www.ia.pw.edu.pl />
> >> >
> >> > Warsaw University of Technology <http://eng.pw.edu.pl />
> >> >
> >> > --
> >> > Orocos-Users mailing list
> >> > Orocos-Users [..] ...
> >> > http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
> >>
> >> Looked into that Boost Varian Library. Seems like it would be just what
> I
> >> was looking for.
> >>
> >> Thanks for your answer.
> >
> > Note that this library will only work out of the box for intra-process
> > communication. You'll have to write your own typekit and type transport
> to
> > move the data between processes since neither of our transport code
> generators
> > (nor corba/typegen, nor ROS) can read boost::variant.
> >
> > Writing a type transport yourself is doable, but not a 'walk in the
> park'.
> >
> > >From a least effort/quickest result view, I would opt to make a larger
> struct
> > that can contain all cases your supervision system can handle and let the
> > components fill that in. In that case, you can use typegen to generate
> all code
> > for you and start off really fast.
> >
> > Peter
> > --
> > Orocos-Users mailing list
> > Orocos-Users [..] ...
> > http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
> >
>
>
>
> --
> Carles Lopez
> Software Engineer
>
> Pal Robotics
> http://www.pal-robotics.com
> Tel: +34.93.414.53.47
> Fax: +34.93.209.11.09
>
> c/ Pujades 77-79, 4t, 4-5
> 08005 Barcelona
>
>
>
> AVISO DE CONFIDENCIALIDAD: Este mensaje y sus documentos adjuntos,
> pueden contener información privilegiada y/o confidencial que está
> dirigida exclusivamente a su destinatario. Si usted recibe este
> mensaje y no es el destinatario indicado, o el empleado encargado de
> su entrega a dicha persona, por favor, notifíquelo inmediatamente y
> remita el mensaje original a la dirección de correo electrónico
> indicada. Cualquier copia, uso o distribución no autorizados de esta
> comunicación queda estrictamente prohibida.
>
> CONFIDENTIALITY NOTICE: This e-mail and the accompanying document(s)
> may contain confidential information which is privileged and intended
> only for the individual or entity to whom they are addressed. If you
> are not the intended recipient, you are hereby notified that any
> disclosure, copying, distribution or use of this e-mail and/or
> accompanying document(s) is strictly prohibited. If you have received
> this e-mail in error, please immediately notify the sender at the
> above e-mail address.
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>