How do I run an Answer Set Programming file from a

2019-09-22 07:02发布

问题:

What methods are there that I can use to run an ASP file from the main function of my C++ code?

I'm doing a project in which I am expected to control a simulated turtlebot using a C++ file, and use ASP code to construct an action plan that the robot can use to achieve a specified goal.

I'm using Ubuntu 14.04, SPARC (an ASP solver), ROS indigo, and gazebo.

回答1:

Am I correct that SPARC is implemented in Java (this link)?

If this is the case, there are quite a few options:

  1. You can use Java Native Interface to interact with SPARC tool directly from c++ code
  2. Other option is to create a separate process from c++ code and communicate with it via stdout/files
  3. You can implement ROS node in Java which accepts requests and uses SPARC as a library to process them. In this case your c++ doesn't care about exact SPARC implementation

Resume:

I would suggest you to try the last option. It's slightly more difficult than other 2 options, but it fits perfectly into ROS infrastructure.