Only the first element of array of properties is read from cpf file. How to have all the elemets of the array read?

Dear Sirs,

I am working on Orocos toolchain 2.3.2 and I am developing a test components using orogen.

I have problem in reading array of properties from cpf file

I prepared a cpf file using the following lines of code:

obstaclesPositions obs=obstaclesPositions(1.0,2.0,3.0);
obstacleP op(4.0,5.0,6.0);
obs.obsPosition.push_back(op);
_Obstacles.set(obs);
boost::shared_ptr<Marshalling> Marshalling = this->getProvider<RTT::Marshalling>("marshalling");
result = Marshalling->writeProperties("ObstaclesDescription.cpf");

and I get the following ObstaclesDescription.cpf file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "cpf.dtd">
<properties>
<struct name="Obstacles" type="/viewer/obstaclesPositions">
<description>actual number and position of obstacles in the work area</description>
<struct name="obsPosition" type="/std/vector&amp;lt;/viewer/obstacleP&amp;gt;">
<description>Part</description>
<struct name="Element0" type="/viewer/obstacleP">
<description>Item</description>
<simple name="lenght_x" type="double"><description>Part</description><value>1</value></simple>
<simple name="lenght_y" type="double"><description>Part</description><value>2</value></simple>
<simple name="lenght_z" type="double"><description>Part</description><value>3</value></simple>
</struct>
<struct name="Element1" type="/viewer/obstacleP">
<description>Item</description>
<simple name="lenght_x" type="double"><description>Part</description><value>4</value></simple>
<simple name="lenght_y" type="double"><description>Part</description><value>5</value></simple>
<simple name="lenght_z" type="double"><description>Part</description><value>6</value></simple>
</struct>
</struct>
</struct>
</properties>

containing a property of type obstaclesPositions with two elements of type obstacleP.

I write a test component that have to read this file and store the read values in a variable of type
obstaclesPositions.

I tried the following code inserted in configureHook:

boost::shared_ptr<Marshalling> Marshalling = this->getProvider<RTT::Marshalling>("marshalling");
result = Marshalling->readProperties("ObstaclesDescription.cpf");
obstaclesPositions obs;
obs = _Obstacles.get();

But only the Element0 of the array is read.

I tried also the following code:

MarshallingService m=MarshallingService(this);
result=m.readProperty("Obstacles","ObstaclesDescription.cpf");

But even in this case only Element0 is read.

How can I do to have all the elements read and assigned to the properties _Obstacles?

_Obstacles is a property defined in the following orogen code:

name 'viewer3d'
version '1.0'
import_types_from "viewer3d.h"

task_context "Viewer3d" do
needs_configuration
property("Obstacles","viewer/obstaclesPositions").
doc('sizes of obstacles in the work area')
end

And in the file viewer3d.h I defined the following types:

class obstacleP
{
public:
double lenght_x;
double lenght_y;
double lenght_z;

obstacleP()
{

lenght_x=0.0;
lenght_y=0.0;
lenght_z=0.0;
}
};

class obstaclesPositions
{
public:
std::vector<obstacleP> obsPosition;

obstaclesPositions()
{

obstacleP oP;

oP.lenght_x=0.0;
oP.lenght_y=0.0;
oP.lenght_z=0.0;

obsPosition.push_back(oP);
}
};

Thank you for your support.

Gianpaolo Rizzi

Only the first element of array of properties is read from cpf f

On Tuesday 10 May 2011 19:25:50 gprizzi [..] ... wrote:
> Dear Sirs,
>
> I am working on Orocos toolchain 2.3.2 and I am developing a test
> components using orogen.
>
> I have problem in reading array of properties from cpf file
>
> I prepared a cpf file using the following lines of code:
>
> obstaclesPositions obs=obstaclesPositions(1.0,2.0,3.0);
> obstacleP op(4.0,5.0,6.0);
> obs.obsPosition.push_back(op);
> _Obstacles.set(obs);
> boost::shared_ptr<Marshalling> Marshalling =
> this->getProvider<RTT::Marshalling>("marshalling"); result =
> Marshalling->writeProperties("ObstaclesDescription.cpf");
>
> and I get the following ObstaclesDescription.cpf file
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE properties SYSTEM "cpf.dtd">
> <properties>
> <struct name="Obstacles" type="/viewer/obstaclesPositions">
> <description>actual number and position of obstacles in the work
> area</description> <struct name="obsPosition"
> type="/std/vector&amp;lt;/viewer/obstacleP&amp;gt;">
> <description>Part</description>
> <struct name="Element0" type="/viewer/obstacleP">
> <description>Item</description>
> <simple name="lenght_x"
> type="double"><description>Part</description><value>1</value></simple>
> <simple name="lenght_y"
> type="double"><description>Part</description><value>2</value></simple>
> <simple name="lenght_z"
> type="double"><description>Part</description><value>3</value></simple>
> </struct>
> <struct name="Element1" type="/viewer/obstacleP">
> <description>Item</description>
> <simple name="lenght_x"
> type="double"><description>Part</description><value>4</value></simple>
> <simple name="lenght_y"
> type="double"><description>Part</description><value>5</value></simple>
> <simple name="lenght_z"
> type="double"><description>Part</description><value>6</value></simple>
> </struct>
> </struct>
> </struct>
> </properties>
>
>
> containing a property of type obstaclesPositions with two elements of type
> obstacleP.
>
> I write a test component that have to read this file and store the read
> values in a variable of type obstaclesPositions.
>
> I tried the following code inserted in configureHook:
>
>
> boost::shared_ptr<Marshalling> Marshalling =
> this->getProvider<RTT::Marshalling>("marshalling"); result =
> Marshalling->readProperties("ObstaclesDescription.cpf");
> obstaclesPositions obs;
> obs = _Obstacles.get();
>
> But only the Element0 of the array is read.
>
> I tried also the following code:
>
> MarshallingService m=MarshallingService(this);
> result=m.readProperty("Obstacles","ObstaclesDescription.cpf");
>
> But even in this case only Element0 is read.
>
> How can I do to have all the elements read and assigned to the properties
> _Obstacles?

I have pushed and tested a fix on toolchain-2.3. You need to recompile RTT and
your application. Thanks for the example code and the report.

Peter

Only the first element of array of properties is read from cpf f

I can confirm this report. This is the output of the -ldebug flag: (see comments...)

0.016 [ Info ][PropertyLoader::save] viewer3d updating of file ObstaclesDescription.cpf
0.022 [ Debug ][PropertyLoader::save] Returning part: obsPosition
0.023 [ Debug ][PropertyLoader::save] propertyDecomposition: Part size:int is not changeable.
0.023 [ Debug ][PropertyLoader::save] propertyDecomposition: Part capacity:int is not changeable.
0.023 [ Debug ][PropertyLoader::save] Returning part: lenght_x
0.023 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.023 [ Debug ][PropertyLoader::save] Returning part: lenght_y
0.023 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.023 [ Debug ][PropertyLoader::save] Returning part: lenght_z
0.024 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.024 [ Debug ][PropertyLoader::save] Returning part: size
0.024 [ Debug ][PropertyLoader::save] Returning part: lenght_x
0.024 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.024 [ Debug ][PropertyLoader::save] Returning part: lenght_y
0.024 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.024 [ Debug ][PropertyLoader::save] Returning part: lenght_z
0.024 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.024 [ Debug ][PropertyLoader::save] Returning part: size
0.024 [ Debug ][PropertyLoader::save] Returning part: size
0.024 [ Info ][PropertyLoader::save] Writing all properties of viewer3d to file ObstaclesDescription.cpf
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property PropertyBag Obstacles.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property PropertyBag obsPosition.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property PropertyBag Element0.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_x.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_y.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_z.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property PropertyBag Element1.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_x.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_y.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_z.
0.025 [ Info ][PropertyLoader::save] Wrote ObstaclesDescription.cpf

Up until here, the property was written out and contained a sequence of two elements. Next, we clear the property's vector, and we
re-read the same file:

0.048 [ Info ][PropertyLoader:configure] Configuring TaskContext 'viewer3d' with 'ObstaclesDescription.cpf'.
0.054 [ Debug ][PropertyLoader:configure] Returning part: obsPosition
0.054 [ Debug ][PropertyLoader:configure] propertyDecomposition: Part size:int is not changeable.
0.054 [ Debug ][PropertyLoader:configure] propertyDecomposition: Part capacity:int is not changeable.
0.054 [ Debug ][PropertyLoader:configure] Returning part: lenght_x
0.054 [ Debug ][PropertyLoader:configure] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.054 [ Debug ][PropertyLoader:configure] Returning part: lenght_y
0.054 [ Debug ][PropertyLoader:configure] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.054 [ Debug ][PropertyLoader:configure] Returning part: lenght_z
0.054 [ Debug ][PropertyLoader:configure] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.054 [ Debug ][PropertyLoader:configure] Returning part: size
0.055 [ Debug ][PropertyLoader:configure] Returning part: size

What happens here is that a default obsPosition is created, even though the one of our property is empty. It is
decomposed...

0.055 [ Debug ][refreshProperties] refreshing Property PropertyBag obsPosition from PropertyBag obsPosition
0.055 [ Debug ][refreshProperties] refreshing Property PropertyBag Element0 from PropertyBag Element0
0.055 [ Debug ][refreshProperties] refreshing Property double lenght_x from double lenght_x
0.055 [ Debug ][refreshProperties] refreshing Property double lenght_y from double lenght_y
0.055 [ Debug ][refreshProperties] refreshing Property double lenght_z from double lenght_z

'refreshing' means that no expansion is done of the vector. So the default one is refreshed with the results of the file...

0.055 [ Debug ][PropertyLoader:configure] Successfuly composed type from PropertyBag
0.055 [ Debug ][PropertyLoader:configure] Used user's composition function for Obstacles:/viewer/obstaclesPositions
0.055 [ Debug ][refreshProperties] refreshing Property /viewer/obstaclesPositions Obstacles from /viewer/obstaclesPositions Obstacles

Next we write out the result: only one element in the property:

0.055 [ Info ][PropertyLoader::save] viewer3d updating of file ObstaclesDescription2.cpf
0.060 [ Debug ][PropertyLoader::save] Returning part: obsPosition
0.061 [ Debug ][PropertyLoader::save] propertyDecomposition: Part size:int is not changeable.
0.061 [ Debug ][PropertyLoader::save] propertyDecomposition: Part capacity:int is not changeable.
0.061 [ Debug ][PropertyLoader::save] Returning part: lenght_x
0.061 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.061 [ Debug ][PropertyLoader::save] Returning part: lenght_y
0.061 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.061 [ Debug ][PropertyLoader::save] Returning part: lenght_z
0.061 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.061 [ Debug ][PropertyLoader::save] Returning part: size
0.061 [ Debug ][PropertyLoader::save] Returning part: size
0.061 [ Info ][PropertyLoader::save] Writing all properties of viewer3d to file ObstaclesDescription2.cpf
0.061 [ Debug ][PropertyLoader::save] updateProperties: updating Property PropertyBag Obstacles.
0.061 [ Debug ][PropertyLoader::save] updateProperties: updating Property PropertyBag obsPosition.
0.061 [ Debug ][PropertyLoader::save] updateProperties: updating Property PropertyBag Element0.
0.061 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_x.
0.061 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_y.
0.061 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_z.
0.061 [ Info ][PropertyLoader::save] Wrote ObstaclesDescription2.cpf

The fishy part is that refreshproperties does not make sense for sequences (ie vector<T>). I'm working on a fix.

Peter

On Tuesday 10 May 2011 19:25:50 gprizzi [..] ... wrote:
> Dear Sirs,
>
> I am working on Orocos toolchain 2.3.2 and I am developing a test
> components using orogen.
>
> I have problem in reading array of properties from cpf file
>
> I prepared a cpf file using the following lines of code:
>
> obstaclesPositions obs=obstaclesPositions(1.0,2.0,3.0);
> obstacleP op(4.0,5.0,6.0);
> obs.obsPosition.push_back(op);
> _Obstacles.set(obs);
> boost::shared_ptr<Marshalling> Marshalling =
> this->getProvider<RTT::Marshalling>("marshalling"); result =
> Marshalling->writeProperties("ObstaclesDescription.cpf");
>
> and I get the following ObstaclesDescription.cpf file
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE properties SYSTEM "cpf.dtd">
> <properties>
> <struct name="Obstacles" type="/viewer/obstaclesPositions">
> <description>actual number and position of obstacles in the work
> area</description> <struct name="obsPosition"
> type="/std/vector&amp;lt;/viewer/obstacleP&amp;gt;">
> <description>Part</description>
> <struct name="Element0" type="/viewer/obstacleP">
> <description>Item</description>
> <simple name="lenght_x"
> type="double"><description>Part</description><value>1</value></simple>
> <simple name="lenght_y"
> type="double"><description>Part</description><value>2</value></simple>
> <simple name="lenght_z"
> type="double"><description>Part</description><value>3</value></simple>
> </struct>
> <struct name="Element1" type="/viewer/obstacleP">
> <description>Item</description>
> <simple name="lenght_x"
> type="double"><description>Part</description><value>4</value></simple>
> <simple name="lenght_y"
> type="double"><description>Part</description><value>5</value></simple>
> <simple name="lenght_z"
> type="double"><description>Part</description><value>6</value></simple>
> </struct>
> </struct>
> </struct>
> </properties>
>
>
> containing a property of type obstaclesPositions with two elements of type
> obstacleP.
>
> I write a test component that have to read this file and store the read
> values in a variable of type obstaclesPositions.
>
> I tried the following code inserted in configureHook:
>
>
> boost::shared_ptr<Marshalling> Marshalling =
> this->getProvider<RTT::Marshalling>("marshalling"); result =
> Marshalling->readProperties("ObstaclesDescription.cpf");
> obstaclesPositions obs;
> obs = _Obstacles.get();
>
> But only the Element0 of the array is read.
>
> I tried also the following code:
>
> MarshallingService m=MarshallingService(this);
> result=m.readProperty("Obstacles","ObstaclesDescription.cpf");
>
> But even in this case only Element0 is read.
>
> How can I do to have all the elements read and assigned to the properties
> _Obstacles?
>
>
> _Obstacles is a property defined in the following orogen code:
>
> name 'viewer3d'
> version '1.0'
> import_types_from "viewer3d.h"
>
> task_context "Viewer3d" do
> needs_configuration
> property("Obstacles","viewer/obstaclesPositions").
> doc('sizes of obstacles in the work area')
> end
>
> And in the file viewer3d.h I defined the following types:
>
> class obstacleP
> {
> public:
> double lenght_x;
> double lenght_y;
> double lenght_z;
>
> obstacleP()
> {
>
> lenght_x=0.0;
> lenght_y=0.0;
> lenght_z=0.0;
> }
> };
>
>
> class obstaclesPositions
> {
> public:
> std::vector<obstacleP> obsPosition;
>
> obstaclesPositions()
> {
>
> obstacleP oP;
>
> oP.lenght_x=0.0;
> oP.lenght_y=0.0;
> oP.lenght_z=0.0;
>
> obsPosition.push_back(oP);
> }
> };
>
>
> Thank you for your support.
>
> Gianpaolo Rizzi

Only the first element of array of properties is read from cpf f

I can confirm this report. This is the output of the -ldebug flag: (see comments...)

0.016 [ Info ][PropertyLoader::save] viewer3d updating of file ObstaclesDescription.cpf
0.022 [ Debug ][PropertyLoader::save] Returning part: obsPosition
0.023 [ Debug ][PropertyLoader::save] propertyDecomposition: Part size:int is not changeable.
0.023 [ Debug ][PropertyLoader::save] propertyDecomposition: Part capacity:int is not changeable.
0.023 [ Debug ][PropertyLoader::save] Returning part: lenght_x
0.023 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.023 [ Debug ][PropertyLoader::save] Returning part: lenght_y
0.023 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.023 [ Debug ][PropertyLoader::save] Returning part: lenght_z
0.024 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.024 [ Debug ][PropertyLoader::save] Returning part: size
0.024 [ Debug ][PropertyLoader::save] Returning part: lenght_x
0.024 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.024 [ Debug ][PropertyLoader::save] Returning part: lenght_y
0.024 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.024 [ Debug ][PropertyLoader::save] Returning part: lenght_z
0.024 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.024 [ Debug ][PropertyLoader::save] Returning part: size
0.024 [ Debug ][PropertyLoader::save] Returning part: size
0.024 [ Info ][PropertyLoader::save] Writing all properties of viewer3d to file ObstaclesDescription.cpf
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property PropertyBag Obstacles.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property PropertyBag obsPosition.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property PropertyBag Element0.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_x.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_y.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_z.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property PropertyBag Element1.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_x.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_y.
0.024 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_z.
0.025 [ Info ][PropertyLoader::save] Wrote ObstaclesDescription.cpf

Up until here, the property was written out and contained a sequence of two elements. Next, we clear the property's vector, and we
re-read the same file:

0.048 [ Info ][PropertyLoader:configure] Configuring TaskContext 'viewer3d' with 'ObstaclesDescription.cpf'.
0.054 [ Debug ][PropertyLoader:configure] Returning part: obsPosition
0.054 [ Debug ][PropertyLoader:configure] propertyDecomposition: Part size:int is not changeable.
0.054 [ Debug ][PropertyLoader:configure] propertyDecomposition: Part capacity:int is not changeable.
0.054 [ Debug ][PropertyLoader:configure] Returning part: lenght_x
0.054 [ Debug ][PropertyLoader:configure] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.054 [ Debug ][PropertyLoader:configure] Returning part: lenght_y
0.054 [ Debug ][PropertyLoader:configure] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.054 [ Debug ][PropertyLoader:configure] Returning part: lenght_z
0.054 [ Debug ][PropertyLoader:configure] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.054 [ Debug ][PropertyLoader:configure] Returning part: size
0.055 [ Debug ][PropertyLoader:configure] Returning part: size

What happens here is that a default obsPosition is created, even though the one of our property is empty. It is
decomposed...

0.055 [ Debug ][refreshProperties] refreshing Property PropertyBag obsPosition from PropertyBag obsPosition
0.055 [ Debug ][refreshProperties] refreshing Property PropertyBag Element0 from PropertyBag Element0
0.055 [ Debug ][refreshProperties] refreshing Property double lenght_x from double lenght_x
0.055 [ Debug ][refreshProperties] refreshing Property double lenght_y from double lenght_y
0.055 [ Debug ][refreshProperties] refreshing Property double lenght_z from double lenght_z

'refreshing' means that no expansion is done of the vector. So the default one is refreshed with the results of the file...

0.055 [ Debug ][PropertyLoader:configure] Successfuly composed type from PropertyBag
0.055 [ Debug ][PropertyLoader:configure] Used user's composition function for Obstacles:/viewer/obstaclesPositions
0.055 [ Debug ][refreshProperties] refreshing Property /viewer/obstaclesPositions Obstacles from /viewer/obstaclesPositions Obstacles

Next we write out the result: only one element in the property:

0.055 [ Info ][PropertyLoader::save] viewer3d updating of file ObstaclesDescription2.cpf
0.060 [ Debug ][PropertyLoader::save] Returning part: obsPosition
0.061 [ Debug ][PropertyLoader::save] propertyDecomposition: Part size:int is not changeable.
0.061 [ Debug ][PropertyLoader::save] propertyDecomposition: Part capacity:int is not changeable.
0.061 [ Debug ][PropertyLoader::save] Returning part: lenght_x
0.061 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.061 [ Debug ][PropertyLoader::save] Returning part: lenght_y
0.061 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.061 [ Debug ][PropertyLoader::save] Returning part: lenght_z
0.061 [ Debug ][PropertyLoader::save] propertyDecomposition: decomposeType() of double did not return a PropertyBag but a double
0.061 [ Debug ][PropertyLoader::save] Returning part: size
0.061 [ Debug ][PropertyLoader::save] Returning part: size
0.061 [ Info ][PropertyLoader::save] Writing all properties of viewer3d to file ObstaclesDescription2.cpf
0.061 [ Debug ][PropertyLoader::save] updateProperties: updating Property PropertyBag Obstacles.
0.061 [ Debug ][PropertyLoader::save] updateProperties: updating Property PropertyBag obsPosition.
0.061 [ Debug ][PropertyLoader::save] updateProperties: updating Property PropertyBag Element0.
0.061 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_x.
0.061 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_y.
0.061 [ Debug ][PropertyLoader::save] updateProperties: updating Property double lenght_z.
0.061 [ Info ][PropertyLoader::save] Wrote ObstaclesDescription2.cpf

The fishy part is that refreshproperties does not make sense for sequences (ie vector<T>). I'm working on a fix.

Peter

On Tuesday 10 May 2011 19:25:50 gprizzi [..] ... wrote:
> Dear Sirs,
>
> I am working on Orocos toolchain 2.3.2 and I am developing a test
> components using orogen.
>
> I have problem in reading array of properties from cpf file
>
> I prepared a cpf file using the following lines of code:
>
> obstaclesPositions obs=obstaclesPositions(1.0,2.0,3.0);
> obstacleP op(4.0,5.0,6.0);
> obs.obsPosition.push_back(op);
> _Obstacles.set(obs);
> boost::shared_ptr<Marshalling> Marshalling =
> this->getProvider<RTT::Marshalling>("marshalling"); result =
> Marshalling->writeProperties("ObstaclesDescription.cpf");
>
> and I get the following ObstaclesDescription.cpf file
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE properties SYSTEM "cpf.dtd">
> <properties>
> <struct name="Obstacles" type="/viewer/obstaclesPositions">
> <description>actual number and position of obstacles in the work
> area</description> <struct name="obsPosition"
> type="/std/vector&amp;lt;/viewer/obstacleP&amp;gt;">
> <description>Part</description>
> <struct name="Element0" type="/viewer/obstacleP">
> <description>Item</description>
> <simple name="lenght_x"
> type="double"><description>Part</description><value>1</value></simple>
> <simple name="lenght_y"
> type="double"><description>Part</description><value>2</value></simple>
> <simple name="lenght_z"
> type="double"><description>Part</description><value>3</value></simple>
> </struct>
> <struct name="Element1" type="/viewer/obstacleP">
> <description>Item</description>
> <simple name="lenght_x"
> type="double"><description>Part</description><value>4</value></simple>
> <simple name="lenght_y"
> type="double"><description>Part</description><value>5</value></simple>
> <simple name="lenght_z"
> type="double"><description>Part</description><value>6</value></simple>
> </struct>
> </struct>
> </struct>
> </properties>
>
>
> containing a property of type obstaclesPositions with two elements of type
> obstacleP.
>
> I write a test component that have to read this file and store the read
> values in a variable of type obstaclesPositions.
>
> I tried the following code inserted in configureHook:
>
>
> boost::shared_ptr<Marshalling> Marshalling =
> this->getProvider<RTT::Marshalling>("marshalling"); result =
> Marshalling->readProperties("ObstaclesDescription.cpf");
> obstaclesPositions obs;
> obs = _Obstacles.get();
>
> But only the Element0 of the array is read.
>
> I tried also the following code:
>
> MarshallingService m=MarshallingService(this);
> result=m.readProperty("Obstacles","ObstaclesDescription.cpf");
>
> But even in this case only Element0 is read.
>
> How can I do to have all the elements read and assigned to the properties
> _Obstacles?
>
>
> _Obstacles is a property defined in the following orogen code:
>
> name 'viewer3d'
> version '1.0'
> import_types_from "viewer3d.h"
>
> task_context "Viewer3d" do
> needs_configuration
> property("Obstacles","viewer/obstaclesPositions").
> doc('sizes of obstacles in the work area')
> end
>
> And in the file viewer3d.h I defined the following types:
>
> class obstacleP
> {
> public:
> double lenght_x;
> double lenght_y;
> double lenght_z;
>
> obstacleP()
> {
>
> lenght_x=0.0;
> lenght_y=0.0;
> lenght_z=0.0;
> }
> };
>
>
> class obstaclesPositions
> {
> public:
> std::vector<obstacleP> obsPosition;
>
> obstaclesPositions()
> {
>
> obstacleP oP;
>
> oP.lenght_x=0.0;
> oP.lenght_y=0.0;
> oP.lenght_z=0.0;
>
> obsPosition.push_back(oP);
> }
> };
>
>
> Thank you for your support.
>
> Gianpaolo Rizzi