Closed DaniGarciaLopez closed 6 months ago
You just need to manually declare the properties in your SerialContainer. Have a look at the PickPlaceBase
class for an example:
https://github.com/moveit/moveit_task_constructor/blob/a8896e4e5d76d37726278eeb3328daa2c71156e5/core/src/stages/pick.cpp#L23
https://github.com/moveit/moveit_task_constructor/blob/a8896e4e5d76d37726278eeb3328daa2c71156e5/core/src/stages/pick.cpp#L45
Thanks @rhaschke. Adding the following lines I can correctly see the property in the SerialContainer
:
serial_container->properties().declare<std::string>("group");
serial_container->properties().property("group").configureInitFrom(mtc::Stage::PARENT, "group");
However, how to propagate the property to child stages of the SerialContainer
? I tried to add the following but it has no effect:
stage->properties().configureInitFrom(mtc::Stage::PARENT, {"group"});
I can set the property declaring and configuring it from parent (as you pointed out) in each stage:
stage->properties().declare<std::string>("group");
stage->properties().property("group").configureInitFrom(mtc::Stage::PARENT, "group");
But I think this is too much boilerplate if I have several properties that I want to be accessible to all children, right? Is there a simpler way to inherit all properties from the parent?
No, there is no simpler way. It was a deliberative design decision to require explicit declaration and forwarding of properties to each child.
I'm trying to pass properties declared in the task to a
SerialContainer
defined in another function:When doing this, the stage
MoveRelative
reports that the propertygroup
is not declared. I think what is missing is a call toexposeTo
as shown in the demo:However, this requires passing a reference to the task within the
Pick
function, which I would like to avoid if possible. I tried the following approach, but it seems that the parent stage is empty:I found that there is a function named
forwardProperties
which might be what I need, but I couldn't find enough information on how to use it.Thanks!