definition of PropertyInitializerSource moved to Stage

This commit is contained in:
Robert Haschke 2018-02-03 15:07:40 +01:00
parent f6253c46a4
commit 4db7e8eb88
5 changed files with 29 additions and 23 deletions

View File

@ -49,21 +49,21 @@ int main(int argc, char** argv){
{
auto move = std::make_unique<stages::Gripper>("open gripper");
move->properties().configureInitFrom(PARENT);
move->properties().configureInitFrom(Stage::PARENT);
move->setTo("open");
t.add(std::move(move));
}
{
auto move = std::make_unique<stages::Move>("move to pre-grasp");
move->properties().configureInitFrom(PARENT);
move->properties().configureInitFrom(Stage::PARENT);
move->setTimeout(8.0);
t.add(std::move(move));
}
{
auto move = std::make_unique<stages::CartesianPositionMotion>("proceed to grasp pose");
move->properties().configureInitFrom(PARENT);
move->properties().configureInitFrom(Stage::PARENT);
move->setMinMaxDistance(.05, 0.1);
move->setCartesianStepSize(0.02);
@ -75,7 +75,7 @@ int main(int argc, char** argv){
{
auto gengrasp = std::make_unique<stages::GenerateGraspPose>("generate grasp pose");
gengrasp->properties().configureInitFrom(PARENT);
gengrasp->properties().configureInitFrom(Stage::PARENT);
gengrasp->setGripperGraspPose("open");
gengrasp->setObject("object");
gengrasp->setGraspFrame(Eigen::Translation3d(0,0,.05)*
@ -88,7 +88,7 @@ int main(int argc, char** argv){
{
auto move = std::make_unique<stages::Gripper>("grasp");
move->properties().configureInitFrom(PARENT);
move->properties().configureInitFrom(Stage::PARENT);
move->setTo("closed");
move->graspObject("object");
t.add(std::move(move));
@ -96,7 +96,7 @@ int main(int argc, char** argv){
{
auto move = std::make_unique<stages::CartesianPositionMotion>("lift object");
move->properties().configureInitFrom(PARENT);
move->properties().configureInitFrom(Stage::PARENT);
move->setMinMaxDistance(0.03, 0.05);
move->setCartesianStepSize(0.01);

View File

@ -49,14 +49,14 @@ int main(int argc, char** argv){
{
auto move = std::make_unique<stages::Gripper>("open gripper");
move->properties().configureInitFrom(PARENT);
move->properties().configureInitFrom(Stage::PARENT);
move->setTo("open");
t.add(std::move(move));
}
{
auto move = std::make_unique<stages::Move>("move to pre-grasp");
move->properties().configureInitFrom(PARENT);
move->properties().configureInitFrom(Stage::PARENT);
move->setTimeout(8.0);
t.add(std::move(move));
}
@ -64,7 +64,7 @@ int main(int argc, char** argv){
{
auto move = std::make_unique<stages::CartesianPositionMotion>("proceed to grasp pose");
// move->addSolutionCallback(std::ref(t.introspection()));
move->properties().configureInitFrom(PARENT);
move->properties().configureInitFrom(Stage::PARENT);
move->setMinMaxDistance(.03, 0.1);
move->setCartesianStepSize(0.02);
@ -76,7 +76,7 @@ int main(int argc, char** argv){
{
auto gengrasp = std::make_unique<stages::GenerateGraspPose>("generate grasp pose");
gengrasp->properties().configureInitFrom(PARENT);
gengrasp->properties().configureInitFrom(Stage::PARENT);
gengrasp->setGripperGraspPose("open");
gengrasp->setObject("object");
gengrasp->setGraspFrame(Eigen::Translation3d(.03,0,0), "s_model_tool0");
@ -87,7 +87,7 @@ int main(int argc, char** argv){
{
auto move = std::make_unique<stages::Gripper>("grasp");
move->properties().configureInitFrom(PARENT);
move->properties().configureInitFrom(Stage::PARENT);
move->setTo("closed");
move->graspObject("object");
t.add(std::move(move));
@ -95,7 +95,7 @@ int main(int argc, char** argv){
{
auto move = std::make_unique<stages::CartesianPositionMotion>("lift object");
move->properties().configureInitFrom(PARENT);
move->properties().configureInitFrom(Stage::PARENT);
move->setMinMaxDistance(0.03, 0.05);
move->setCartesianStepSize(0.01);

View File

@ -53,11 +53,6 @@ class PropertyMap;
/// initializer function, using given name from the passed property map
boost::any fromName(const PropertyMap& other, const std::string& other_name);
enum PropertyInitializerSource {
PARENT,
INTERFACE,
};
/** Property is a wrapper for a boost::any value, also providing a default value and a description.
*
* Properties can be configured to be initialized from another PropertyMap - if still undefined.

View File

@ -80,6 +80,17 @@ class Stage {
public:
PRIVATE_CLASS(Stage)
typedef std::unique_ptr<Stage> pointer;
/** Names for property initialization sources
*
* - INTERFACE allows to pass properties from one stage to the next (in a SerialContainer).
* - PARENT allows to inherit properties from the parent.
*
* INTERFACE takes precedence over PARENT.
*/
enum PropertyInitializerSource {
PARENT,
INTERFACE,
};
virtual ~Stage();
/// auto-convert Stage to StagePrivate* when needed

View File

@ -240,8 +240,8 @@ const InterfaceState& PropagatingEitherWayPrivate::fetchEndState(){
void PropagatingEitherWayPrivate::initProperties(const InterfaceState& state)
{
properties_.reset();
properties_.performInitFrom(PARENT, parent()->properties());
properties_.performInitFrom(INTERFACE, state.properties());
properties_.performInitFrom(Stage::PARENT, parent()->properties());
properties_.performInitFrom(Stage::INTERFACE, state.properties());
}
bool PropagatingEitherWayPrivate::canCompute() const
@ -433,7 +433,7 @@ bool GeneratorPrivate::compute() {
void GeneratorPrivate::initProperties()
{
properties_.reset();
properties_.performInitFrom(PARENT, parent()->properties());
properties_.performInitFrom(Stage::PARENT, parent()->properties());
}
@ -482,10 +482,10 @@ void ConnectingPrivate::newEndState(const Interface::iterator& it)
void ConnectingPrivate::initProperties(const InterfaceState &start, const InterfaceState &end)
{
properties_.reset();
properties_.performInitFrom(PARENT, parent()->properties());
properties_.performInitFrom(Stage::PARENT, parent()->properties());
// properties from start/end states need to be consistent to each other
properties_.performInitFrom(INTERFACE, start.properties());
properties_.performInitFrom(INTERFACE, end.properties(), true);
properties_.performInitFrom(Stage::INTERFACE, start.properties());
properties_.performInitFrom(Stage::INTERFACE, end.properties(), true);
}
bool ConnectingPrivate::canCompute() const{