diff --git a/rosplan_knowledge_base/include/rosplan_knowledge_base/VALVisitorOperator.h b/rosplan_knowledge_base/include/rosplan_knowledge_base/VALVisitorOperator.h index afae913fb..aa1df000e 100644 --- a/rosplan_knowledge_base/include/rosplan_knowledge_base/VALVisitorOperator.h +++ b/rosplan_knowledge_base/include/rosplan_knowledge_base/VALVisitorOperator.h @@ -36,6 +36,8 @@ namespace KCL_rosplan { /* visitor methods */ virtual void visit_proposition(VAL1_2::proposition *); virtual void visit_operator_(VAL1_2::operator_ *); + virtual void visit_action(VAL1_2::action * s); + virtual void visit_durative_action(VAL1_2::durative_action * s); virtual void visit_simple_goal(VAL1_2::simple_goal *); virtual void visit_qfied_goal(VAL1_2::qfied_goal *); diff --git a/rosplan_knowledge_base/src/PDDLKnowledgeBase.cpp b/rosplan_knowledge_base/src/PDDLKnowledgeBase.cpp index 959157581..559e91ccb 100644 --- a/rosplan_knowledge_base/src/PDDLKnowledgeBase.cpp +++ b/rosplan_knowledge_base/src/PDDLKnowledgeBase.cpp @@ -118,7 +118,7 @@ namespace KCL_rosplan { VAL1_2::operator_list* operators = domain_parser.domain->ops; for (VAL1_2::operator_list::const_iterator ci = operators->begin(); ci != operators->end(); ci++) { if((*ci)->name->symbol::getName() == req.name) { - op_visitor.visit_operator_(*ci); + (*ci)->visit(&op_visitor); res.op = op_visitor.msg; return true; } diff --git a/rosplan_knowledge_base/src/VALVisitorOperator.cpp b/rosplan_knowledge_base/src/VALVisitorOperator.cpp index cb3001d3b..24d37d1c6 100644 --- a/rosplan_knowledge_base/src/VALVisitorOperator.cpp +++ b/rosplan_knowledge_base/src/VALVisitorOperator.cpp @@ -4,6 +4,7 @@ namespace KCL_rosplan { /* encoding state */ + bool parsing_duration; bool cond_neg; bool eff_neg; VAL1_2::time_spec cond_time; @@ -14,6 +15,19 @@ namespace KCL_rosplan { /* operators */ /*-----------*/ + void VALVisitorOperator::visit_durative_action(VAL1_2::durative_action * op) { + visit_operator_(op); + parsing_duration = true; + msg.instant_action = false; + op->dur_constraint->visit(this); + parsing_duration = false; + } + + void VALVisitorOperator::visit_action(VAL1_2::action * op) { + visit_operator_(op); + msg.instant_action = true; + } + /** * Visit an operator to pack into ROS message */ @@ -51,6 +65,7 @@ namespace KCL_rosplan { op->effects->visit(this); // conditions + parsing_duration = false; if (op->precondition) op->precondition->visit(this); } @@ -143,6 +158,10 @@ namespace KCL_rosplan { case VAL1_2::E_EQUALS: ineq.comparison_type = rosplan_knowledge_msgs::DomainInequality::EQUALS; break; } + if(parsing_duration) { + msg.duration = ineq; + return; + } switch(cond_time) { case VAL1_2::E_AT_START: msg.at_start_comparison.push_back(ineq); break; case VAL1_2::E_AT_END: msg.at_end_comparison.push_back(ineq); break; diff --git a/rosplan_knowledge_msgs/msg/DomainOperator.msg b/rosplan_knowledge_msgs/msg/DomainOperator.msg index fc1dcb741..01fd1e5c3 100644 --- a/rosplan_knowledge_msgs/msg/DomainOperator.msg +++ b/rosplan_knowledge_msgs/msg/DomainOperator.msg @@ -4,7 +4,8 @@ rosplan_knowledge_msgs/DomainFormula formula # (2) duration constraint - +bool instant_action +rosplan_knowledge_msgs/DomainInequality duration # (3) effect lists rosplan_knowledge_msgs/DomainFormula[] at_start_add_effects