Rclswi: a ROS2 client for SWI-prolog

This is the first public announcement of rclswi, a ROS2 client for SWI-Prolog. This can be seen as a followup of rosprolog which was created as part of the Knowrob project that was developed for ROS1.

Many applications need a little or a lot of reasoning and Prolog is proven technology to provide simple rule reasoning, constraint based reasoning as well as Datalog style reasoning including well founded semantics to deal with negation and incomplete knowledge. SWI-Prolog offers a lot on top of the old core language to play a key role in reasoning about robotics.

Rclswi is layered on top of the ROS2 rcl and rmw core libraries. The library consists of a C part with an abstraction that is comparable to rclpy, the standard Python ROS2 client. Unlike the Python version, message types are not compiled but messages are translated to/from Prolog data structures using type introspection. A quick and dirty performance evaluation using the ROS2 add two ints
is promising.

The high level interface is provided for creating multi-threaded Prolog applications. It currently covers pub/sub, services, actions, logging, parameters, QoS support, clocks, guard conditions, spinning and examining the available nodes and connections they provide.

Where ROSProlog aimed first of all at providing a logic based reasoning service, Rclswi aims at implementing arbitrary (including time critical) ROS services such as reasoning, planning and monitoring. This is facilitated by a various SWI-Prolog properties:

  • Full multi-core preemptive concurrency. Concurrent non-blocking garbage collection for shared resources. These features provide good utilization of resources and near real-time behavior.
  • Safe concurrent Prolog database management. This includes atomicity and isolation provided by transactions.
  • Extensive thread synchronization. Wait on message queues, wait for database updates as well as asynchronous signalling.
  • Tabled execution provides Datalog termination quarantees and Well Founded Semantics to deal safely with negation. Restraints allow for safe reasoning based on incomplete knowledge.
  • Incremental and monotonic tabling provide efficient tabled reasoning in a changing world.

Status and plans

  • The current version is incomplete and not well tested. It should be good enough for prototyping and testing.
  • ROSProlog and Rclswi are completely different. That is no surprise as ROS1 and ROS2 have a quite different architecture. ROSProlog can be implemented as a library on top of Rclswi.

Feedback

For comments and questions, please use either the SWI-Prolog Discourse forum or ROS questions and answers. Bug fixes and feature requests can use the issue tracker of the GitHub repository.

All contributions are welcome: example code, fixes, better interfaces, ports, tests, etc. Please provide as Git pull requests if possible.

3 Likes

Hi @JanWielemaker,

Is there the possibility to have this library working with Galactic distro?

Thanks,
Gianstiff