This package provides a basic generic integration between ROS and typeDB. The package was designed in a way to enable users to easily extend it to fulfill their needs, the package design is explained in the Package Design section.
This package was tested in Ubuntu 22.04 with ROS Humble and typedb v2.27.0.
This repository is in an initial stage and under constant development
To use this package, you need to install ROS 2 Humble, typedb, and typedb python driver.
Follow the official instructions for installing ROS 2 Humble.
Install typedb: follow theofficial instructions.
Install typedb python driver:
pip install typedb-client
Create a ROS workspace and clone the repository:
mkdir -p ~/ros_typedb_ws/src/
cd ~/ros_typedb_ws/src
git clone https://github.com/Rezenders/ros_typedb.git
Install the dependencies:
source /opt/ros/humble/setup.bash
cd ~/ros_typedb_ws/
rosdep install --from-paths src --ignore-src -r -y
Build the project:
cd ~/ros_typedb_ws/
colcon build --symlink-install
source install/setup.bash
The integration between ROS and TypeDB is implemented with 2 classes, TypeDBInterface and ROSTypeDBInterface.
The TypeDBInterface class interacts with the typeDB database using the typedb python api, and it contains basic functionalities that are common for all applications, such as insert_database and match_database.
The ROSTypeDBInterface class is a ROS 2 LifeCycle Node, and it implements 2 ROS interfaces. A ROS service server ros_typedb_interface/query
that is used to query the database, which uses the Query.srv service type. And the ROS topic ros_typedb_interface/events
, where it publishes insert and delete events when data is inserted or deleted from the database with the query service.
Class diagram:
Overview:
To run the ros_typedb_interface:
ros2 run ros_typedb ros_typedb_interface -p schema_path:=<schema_path> -p data_path:=<data_path>
Note: Make sure to replace <schema_path> and <data_path> with the real path for your schema and data file Note 2: Remember that ros_typedb_interface is a LifeCycle node, so you need to change its state to active before using it. Check the lifecycle tutorial.
To extend this package with custom functionalities, you can create a new ROS Node inheriting from ROSTypeDBInterface and a new typedb interface inheriting from TypeDBInterface. Then you simply need to add the new functionalities you need into your class.
Example:
New typedb interface:
class MyModelInterface(TypeDBInterface):
def __init__(self, address, database_name, schema_path, data_path=None,
force_database=False, force_data=False):
super().__init__(
address,
database_name,
schema_path,
data_path,
force_database,
force_data
)
New ROS interface:
class MyModelROSInterface(ROSTypeDBInterface):
def __init__(self, node_name, schema_path='', data_path='', **kwargs):
super().__init__(node_name, schema_path, data_path, **kwargs)
self.typedb_interface_class = MyModelInterface
Spin ROS node:
def main():
rclpy.init()
traceback_logger = rclpy.logging.get_logger(
'mymodel_kb_traceback_logger')
lc_node = MyModelROSInterface('mymodel_kb')
executor = rclpy.executors.MultiThreadedExecutor()
executor.add_node(lc_node)
try:
executor.spin()
except (KeyboardInterrupt, rclpy.executors.ExternalShutdownException):
pass
except Exception as exception:
traceback_logger.error(traceback.format_exc())
raise exception
finally:
lc_node.destroy_node()
This work is part of the Reliable AI for Marine Robotics (REMARO) Project. For more info, please visit: https://remaro.eu/
This project has received funding from the European Union's Horizon 2020 research and innovation programme under the Marie Skłodowska-Curie grant agreement No. 956200.