Hello,
I have the following problem. In a certain task, I have a method which has as input parameter a struct. I want to call this method in the taskcontext, but I am not able to give through the right parameter(the struct). Is there a way to call this method directly in the taskcontext ?
Stefaan
declaring structs in taskcontext
On Tuesday 30 September 2008 11:05:44 sspr [..] ... wrote:
> Hello,
>
> I have the following problem. In a certain task, I have a method which has
> as input parameter a struct. I want to call this method in the
> taskcontext, but I am not able to give through the right parameter(the
> struct). Is there a way to call this method directly in the taskcontext ?
If you want to extend the types in scripts, read this document:
You'll have to create the appropriate 'constructor' anyway to initialise your
struct such that you'll have something like:
comp.meth( struct_t( 3.0, 5.0, "OK") )
For advanced examples, you'll have to look at how it is done for ('array') in orocos-rtt/src/RealTimeToolkit.cpp
std::vector
Peter
declaring structs in taskcontext
Thanks to the information, I managed to do it.
Thank you
Stefaan
declaring structs in taskcontext
Hello,
I have still a problem. In the Orocos environment, I have simulated the prewinder. As we have several prewinders, I created multiple instances of this prewinder. The struct I want to use in the taskcontext is located inside this prewinder component (in the .hpp file). The problem I have is that in the logging I get several times the warning :
0.417 [ Warning][Logger] Overriding TypeInfo for 'ScheduleIdentification'.
0.417 [ Warning][Logger] Attempt to register Type 'ScheduleIdentification' twice to the Orocos Type System.
This ScheduleIdentification is the name of the struct. Is there a way to avoid this warning ?
The code in my .hpp file is :
struct ScheduleIdentification
{
ScheduleIdentification() : _cycle(0), _position(0), _delay(0) {}
ScheduleIdentification(int cycle, double position, int delay)
: _cycle(cycle), _position(position), _delay(delay)
{}
unsigned int _cycle;
double _position;
unsigned int _delay;
};
struct ScheduleIdentificationTypeInfo : public RTT::TemplateTypeInfo("ScheduleIdentification")
{
ScheduleIdentificationTypeInfo() : RTT::TemplateTypeInfo
{}
};
ScheduleIdentification createScheduleIdentification(int cycle, double position, int delay) {
return ScheduleIdentification(cycle,position,delay);
}
The code in the .cpp file is (inside the constructor):
TypeInfoRepository::Instance()->addType(new ScheduleIdentificationTypeInfo());
TypeInfoRepository::Instance()->type("ScheduleIdentification")->addConstructor( newConstructor(&createScheduleIdentification));
Stefaan
declaring structs in taskcontext
On Monday 06 October 2008 13:44:25 sspr [..] ... wrote:
> Hello,
>
> I have still a problem. In the Orocos environment, I have simulated the
> prewinder. As we have several prewinders, I created multiple instances of
> this prewinder. The struct I want to use in the taskcontext is located
> inside this prewinder component (in the .hpp file). The problem I have is
> that in the logging I get several times the warning : 0.417 [
> Warning][Logger] Overriding TypeInfo for 'ScheduleIdentification'. 0.417 [
> Warning][Logger] Attempt to register Type 'ScheduleIdentification' twice to
> the Orocos Type System.
These warnings are not a real problem for the application. Everything will work fine. To avoid them change:
TypeInfoRepository::Instance()->addType(new ScheduleIdentificationTypeInfo());
TypeInfoRepository::Instance()->type("ScheduleIdentification")->addConstructor( newConstructor(&createScheduleIdentification));
to
if ( TypeInfoRepository::Instance()->type("ScheduleIdentification") == 0 ) {
TypeInfoRepository::Instance()->addType(new ScheduleIdentificationTypeInfo());
TypeInfoRepository::Instance()->type("ScheduleIdentification")->addConstructor( newConstructor(&createScheduleIdentification));
}
That should do it... then you don't have to write a separate toolkit...
Peter
declaring structs in taskcontext
Ok, this works
Thank you
Stefaan
declaring structs in taskcontext
On Monday 06 October 2008 13:44:25 sspr [..] ... wrote:
> Hello,
>
> I have still a problem. In the Orocos environment, I have simulated the
> prewinder. As we have several prewinders, I created multiple instances of
> this prewinder. The struct I want to use in the taskcontext is located
> inside this prewinder component (in the .hpp file). The problem I have is
> that in the logging I get several times the warning : 0.417 [
> Warning][Logger] Overriding TypeInfo for 'ScheduleIdentification'. 0.417 [
> Warning][Logger] Attempt to register Type 'ScheduleIdentification' twice to
> the Orocos Type System.
>
> This ScheduleIdentification is the name of the struct. Is there a way to
> avoid this warning ?
Write a toolkit for your types, see
xml/orocos-toolkit-plugin.html#id2503994>
if you use the deployer, you can make the deployer load your toolkit and the
types will only be registered once.
Ruben
declaring structs in taskcontext
Hello,
To make the deployer load the toolkit, do I have to make a component from the toolkit ? Or is there another way to load the toolkit ?
Stefaan
declaring structs in taskcontext
On Monday 06 October 2008 15:46:39 sspr [..] ... wrote:
> Hello,
>
> To make the deployer load the toolkit, do I have to make a component from
> the toolkit ? Or is there another way to load the toolkit ?
You should put your toolkit library in a standard path where the deployer will
look for existing plugins, i could not find any documentation about this in the
deployers manual but on the mailinglist i found this:
Ruben