Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duration and instant action handling in KB and plan parser #288

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
2 changes: 1 addition & 1 deletion rosplan_knowledge_base/src/PDDLKnowledgeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
19 changes: 19 additions & 0 deletions rosplan_knowledge_base/src/VALVisitorOperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace KCL_rosplan {

/* encoding state */
bool parsing_duration;
bool cond_neg;
bool eff_neg;
VAL1_2::time_spec cond_time;
Expand All @@ -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
*/
Expand Down Expand Up @@ -51,6 +65,7 @@ namespace KCL_rosplan {
op->effects->visit(this);

// conditions
parsing_duration = false;
if (op->precondition) op->precondition->visit(this);
}

Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion rosplan_knowledge_msgs/msg/DomainOperator.msg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down