Skip to content

Commit

Permalink
Merge remote-tracking branch 'public_fork/verbalization_working_copy'…
Browse files Browse the repository at this point in the history
… into verbalization_noetic
  • Loading branch information
gerardcanal committed Dec 19, 2022
2 parents 5466e7e + 4f186d0 commit 5390cbb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ Run an interactive bash shell inside the docker, ready to run ROSPlan:
docker run -it --rm kclplanning/rosplan bash
```

## ROSPlan KB GUI
There is a newly developed interface to interact with ROSPlan's Knowledge Base. It was built by Eden Jia, using `tkinter` in Python. You can find it and use it [here](https://github.com/H0PP3R/rosplan_gui).

## Related repositories:

Expand Down
41 changes: 23 additions & 18 deletions rosplan_knowledge_base/src/RDDLExprUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,34 @@ RDDLExprUtils::getExpression(const LogicalExpression *expr, const std::map<std::
}

rosplan_knowledge_msgs::ExprComposite RDDLExprUtils::getExpression(const Connective *expr, const std::map<std::string, std::string>& assign) {
assert(expr->exprs.size() == 2); // Assuming two operands in each
rosplan_knowledge_msgs::ExprComposite ret;

rosplan_knowledge_msgs::ExprBase base;
base.expr_type = rosplan_knowledge_msgs::ExprBase::OPERATOR;
for (int i = 0; i < expr->exprs.size()-1; ++i) {
rosplan_knowledge_msgs::ExprBase base;
base.expr_type = rosplan_knowledge_msgs::ExprBase::OPERATOR;

// Check type
if (dynamic_cast<const Multiplication *>(expr) != nullptr ||
dynamic_cast<const Conjunction *>(expr) != nullptr)
base.op = rosplan_knowledge_msgs::ExprBase::MUL;
else if (dynamic_cast<const Addition *>(expr) != nullptr ||
dynamic_cast<const Disjunction *>(expr) != nullptr)
base.op = rosplan_knowledge_msgs::ExprBase::ADD;
else if (dynamic_cast<const Subtraction *>(expr) != nullptr) base.op = rosplan_knowledge_msgs::ExprBase::SUB;
else if (dynamic_cast<const Division *>(expr) != nullptr) base.op = rosplan_knowledge_msgs::ExprBase::DIV;
else {
NOT_IMPLEMENTED_EXPR;
return ret;
}
ret.tokens.push_back(base);

// Check type
if (dynamic_cast<const Multiplication*>(expr) != nullptr || dynamic_cast<const Conjunction*>(expr) != nullptr) base.op = rosplan_knowledge_msgs::ExprBase::MUL;
else if (dynamic_cast<const Addition*>(expr) != nullptr || dynamic_cast<const Disjunction*>(expr) != nullptr) base.op = rosplan_knowledge_msgs::ExprBase::ADD;
else if (dynamic_cast<const Subtraction*>(expr) != nullptr) base.op = rosplan_knowledge_msgs::ExprBase::SUB;
else if (dynamic_cast<const Division*>(expr) != nullptr) base.op = rosplan_knowledge_msgs::ExprBase::DIV;
else {
NOT_IMPLEMENTED_EXPR;
return ret;
rosplan_knowledge_msgs::ExprComposite operand = getExpression(expr->exprs[i], assign);
join(ret.tokens, operand.tokens);
}
ret.tokens.push_back(base);

rosplan_knowledge_msgs::ExprComposite operand1 = getExpression(expr->exprs[0], assign);
rosplan_knowledge_msgs::ExprComposite operand2 = getExpression(expr->exprs[1], assign);
//ret.tokens.insert(ret.tokens.end(), std::make_move_iterator(operand1.tokens.begin()), std::make_move_iterator(operand1.tokens.end()));
join(ret.tokens, operand1.tokens);
//ret.tokens.insert(ret.tokens.end(), std::make_move_iterator(operand2.tokens.begin()), std::make_move_iterator(operand2.tokens.end()));
join(ret.tokens, operand2.tokens);
// Add last
rosplan_knowledge_msgs::ExprComposite operand = getExpression(expr->exprs[expr->exprs.size()-1], assign);
join(ret.tokens, operand.tokens);
return ret;
}

Expand Down

0 comments on commit 5390cbb

Please sign in to comment.