Rclswi: a ROS2 client for SWI-prolog

Announcing a ROS2 client library for SWI-Prolog

About ROS
ROS is short for Robotics Operating System. In a nutshell ROS provides a micro-services infrastructure to make nodes that can be distributed over computers in a robot and external computers talk to each other using publish/subscribe, services and actions. The communication is binary and pretty efficient. ROS also provides a packaging and build infrastructure. So far this is not specific to robotics. For the robotics field it provides packages that do common tasks in robotics such as movement planning, vision, etc.

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.

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.

4 Likes