moveit / moveit_task_constructor

A hierarchical multi-stage manipulation planner
https://moveit.github.io/moveit_task_constructor
BSD 3-Clause "New" or "Revised" License
173 stars 149 forks source link

Clarification on PropertyMap `exposeTo` #584

Open captain-yoshi opened 2 months ago

captain-yoshi commented 2 months ago

When exposing properties to another stage and if that stage property has already been declared, then the property value is not beeing exposed. Is this the intended behavior ?

Stage2 has already a property called timeout

StagePtr stage1 = std::make_shared<stages::CurrentState>();
StagePtr stage2 = std::make_shared<stages::CurrentState>();

std::cout << stage1->properties().get<double>("timeout") << std::endl;
// timeout = 3

stage1->properties().set("timeout", 0.5);
std::cout << stage1->properties().get<double>("timeout") << std::endl;
// timeout = 0.5

stage1->properties().exposeTo(stage2->properties(), { "timeout" });
std::cout << stage2->properties().get<double>("timeout") << std::endl;
// timeout = 3         I would have expected this to be 0.5 ...

With an undeclared property

StagePtr stage1 = std::make_shared<stages::CurrentState>();
StagePtr stage2 = std::make_shared<stages::CurrentState>();

stage1->properties().set("controller_id", 3.0);
std::cout << stage1->properties().get<double>("controller_id") << std::endl;
// controller_id = 3

stage1->properties().set("controller_id", 0.5);
std::cout << stage1->properties().get<double>("controller_id") << std::endl;
// controller_id = 0.5

stage1->properties().exposeTo(stage2->properties(), { "controller_id" });
std::cout << stage2->properties().get<double>("controller_id") << std::endl;
// controller_id = 0.5
rhaschke commented 1 month ago

The function doc states:

declare given property name as other_name in other PropertyMap

Thus, the property is just declared if it doesn't yet exist. Redeclaring a property doesn't modify any of its values. Looks like, I should improve the docs on property handling...