orocos-toolchain / rtt

Orocos Real-Time Toolkit
http://www.orocos.org
Other
72 stars 79 forks source link

Value parse problem with user defined data in a property bag #326

Open liufang-robot opened 3 years ago

liufang-robot commented 3 years ago

Hello, I have a problem... When I try to add a user defined type data in a property bag, the value parse will get an error with the user data.

Here is an example: Create a simple data structure:.

struct UserData
{
    /** Contains a sequence of doubles. */
    std::vector<double> samples;
    std::string name;
    int id;
};

create the typekit by typegen (or manually). add the UserData property instance in a component (simply named 'hello'):

/// user_data_, user_data_in_bag_ are UserData type members of hello component.
/// test_bag_ is PropertyBag type member of hello component

/// in the constructor of component.
/// add a UserData type data as a plain property.
addProperty("user_data", user_data_)
/// add a UserData type data in a propertybag.
test_bag_.addProperty("user_data",user_data_in_bag_);
addProperty("test_bag",test_bag_);

And the ValueParser will not handle the propertybag case correctly. we can simple use deployer to check(deployer use rtt scripting ValueParser to get the value). In a deployer:

# input this and enter, try to get the id value. this is OK
hello.user_data.id

# input this and enter, try to get the id value.  this is Not OK
hello.test_bag.user_data.id
# It gives an error:
Semantic error: Property test_bag not present in PropertyBag test_bag in hello.

The error is logged in scripting/ValueParser.cpp line 168. I looked into the code and found it seems that the case a user defined data in a property bag is never considered. In the code, it only try to recursively use a propertybag to analysis the expression. Is this true? Thanks for your reply.