Re: Defining DataObject Types

Peter Soetens <[email protected]>
Newsgroups gmane.science.robotics.orocos.user
Organization KU Leuven
Message-ID <[email protected]>
On Tuesday 06 April 2004 17:40, Andrea Consonni wrote:
> Hi,
>
> we have a question about defining of dataobject types in a component.
>
> In every component you have written this:
>
>    typedef typename Base::SetPointType SetPointType;
>    typedef typename Base::InputType InputType;
>    typedef typename Base::ModelType ModelType;
>    typedef typename Base::OutputType OutputType;
>
> Here seems that we don't know the types of DataObjects, but we have to know
> them if we want to use its attributes/methods during the calculate(). It
> isn't clear for us why you have
> done this choice. We think that you want to be sure that the DataObject
> which is shared by
> two components is of the same type for both componets (which is the type
> of the DataObject held by the Kernel).
>
> Do we think right?

You are right that you need to know the datatype, and it is defined by the 
component which writes to it (eg. generator writes setpoints). So the 
generator knows the setpoint type. In the 'older' (StandardControlKernel) 
kernels, the receiving component (eg controller) has to 'guess' the type of 
the data and try to use them. If you use them wrong, the compiler will detect 
it, but this is not very userfriendly. For small systems, this is ok though 
because its rapidly implemented and very efficient.

If you want to use a more userfriendly system, you have to switch to the 
NSControlKernel implementation. It does not need the above definitions (ouf!) 
and works like this :

template<class Base>
class MyController : public Base
{
//... I want to read a Frame as setpoint
    DataObjectInterface<Geometry::Frame>* setpoint_f;
//...
    virtual bool componentLoaded()
    {
          if ( Base::SetPoint::dObj()->Get("EndEffectorFrame", setpoint_f) == 
false) {
		cerr << "This component needs an EndEffectorFrame setpoint!"<<endl;
		return false;
	  }
	  // do setpoint_f->Get(); to get the frame value.
          return true;
     }
};

The difference is thus that you say in the component, which specific 
dataobjects you want, and when it is loaded in the kernel, it checks if it is 
there. This will be available in 0.14.0, which I will release shortly. For an 
example, look at the CartesianNSComponents.hpp file.

You still have to get the NSControlKernel<...> types correct. It is hard to 
circumvent the type listing in the kernel, if you want to be able to use any 
datatype between two components. A userfriendly solution is possible, but 
that will be for 0.16.0.

The way the Orocos documentation is written is a bit historically. We should 
first start explaining the NSControlKernel (the easiest) and then the 
StandardControl kernel (the harder, but a bit faster).

Peter

-- 
------------------------------------------------------------------------
Peter Soetens, Research Assistent                  http://www.orocos.org
Katholieke Universiteit Leuven
Division Production Engineering,                      tel. +32 16 322773
Machine Design and Automation                         fax. +32 16 322987
Celestijnenlaan 300B                   [email protected]
B-3001 Leuven Belgium                 http://www.mech.kuleuven.ac.be/pma
------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.