Transferring your own data between componenents using Corba

Hi,

I want to transfer my own data (and some KDL-data like frames, ...) over the network using Corba.

In the documentation I only found the following paragraph which does not make clear to me what I have to do.

I also explored the source-code that was not very clarifying neither.

1.2.4. Network transfer (CORBA)

In order to transfer your data between components over a network, Orocos requires that you provide the conversion from your type to a CORBA::Any type and back, quite similar to the 'composition' and 'decomposition' of your data. Look at the TemplateTypeInfo interface for the functions you need to implement.

The first step is describing your struct in IDL and generate the 'client' headers with 'Any' support. Next you create such a struct, fill it with your data type's data and next 'stream' it to an Any. The other way around is required as well.

In addition, you will need the CORBA support of Orocos enabled in your build configuration.

What functions to I have to implement?

Can I reuse some code which I already wrote to read and write my data to XML?

Thanks,

Tinne

Transferring your own data between componenents using Corba

On Tuesday 29 January 2008 08:55:00 Tinne De Laet wrote:
> Hi,
>
> I want to transfer my own data (and some KDL-data like frames, ...) over
> the network using Corba. In the documentation I only found the following
> paragraph which does not make clear to me what I have to do. I also
> explored the source-code that was not very clarifying neither.
>
> 1.2.4. Network transfer (CORBA)
> In order to transfer your data between components over a network, Orocos
> requires that you provide the conversion from your type to a CORBA::Any
> type and back, quite similar to the 'composition' and 'decomposition' of
> your data. Look at the TemplateTypeInfo interface for the functions you
> need to implement. The first step is describing your struct in IDL and
> generate the 'client' headers with 'Any' support. Next you create such a
> struct, fill it with your data type's data and next 'stream' it to an Any.
> The other way around is required as well. In addition, you will need the
> CORBA support of Orocos enabled in your build configuration.

This text isn't helpful...

>
> What functions to I have to implement?
> Can I reuse some code which I already wrote to read and write my data to
> XML?

You can't reuse the XML stuff.

You first need to define your data type in IDL. One important aspect is that
you have the 'native' KDL::MyType and the 'CORBA' KDL::Corba::MyType. Both
are different structs, but with the same contents. you need to copy data from
one to the other in both directions...

MyTypes.idl:
module KDL {
module Corba {
typedef sequence my_array_t;

struct MyType {
double v1, v2, v3;
my_array_t array1;
};
}
}

And generate the corba client files (ending in MyTypesC.*) using tao_idl

Next write a new class which specialises AnyConversion (From
CorbaConversion.hpp - this file serves as an example.) as such:

#include "MyTypesC.h"
#include

namespace RTT{
template<>
AnyConversion
{
// makes the link to KDL::Corba::MyType ... as in CorbaConversion.hpp
};
}

This is then used to register the transport in the Toolkit, like in
CorbaLib.cpp:

TypeInfo* ti = .... // your type added with TemplateTypeInfo
ti->addProtocol(ORO_CORBA_PROTOCOL_ID, new
CorbaTemplateProtocol() );

For an example, look at the files OrocosTypes.id and CorbaConversion.hpp (look
for Corba::DoubleSequence) and CorbaLib.cpp

So basically, you need to write one IDL file and add one class and register
that class to your type info object of the object you want to transport.

Peter