Skip to content

Tour Persistence Node

Overview

This package provides a ROS node for managing persistent tour-related data in MongoDB.

It supports operations like creating, updating, reading and deleting tours.

The core implementation is located in src/tour_persistence/tour_persistence/node.py.

Workflow

The following diagram illustrates the interaction between the client, the ROS node, and the MongoDB backend during a typical operation:

sequenceDiagram
    participant Client
    participant Server as ROS Node (node.py)
    participant Converter as Converter (ros_to_mongodb.py)
    participant DBClient as DBClient(mongodb_server/base_motor.py)
    participant MongoDB

    Client->>Server: Call service '/tour_create'(send TourCreate request with Tour)
    activate Server
    note right of Server: on_create starts

    %% Insert MongoDB processing here
    Server->>Converter: Transform ROS msg to MongoDB-friendly format
    Converter-->>Server: Return transformed data
    Server->>DBClient: Connect to MongoDB via Database client
    DBClient->>MongoDB: Insert transformed data
    MongoDB-->>DBClient: Acknowledge insertion

    Server-->>Client: Return TourCreate response (success: true/false)
    deactivate Server
    note right of Server: on_create ends

Services

The node provides the following services:

  • /tour_create: Create a new tour in the database.

  • /tour_update: Update an existing tour in the database.

  • /tour_delete: Delete a tour from the database.

  • /tour_list: List names of tours in the database.

  • /tour_get: Get a specific tour by name from the database.

Format of the service requests and responses is defined in the ric_messages package.

Testing

To test the system: 1. Ensure the MongoDB container is running from the mongodb_server 2. In the project root, run

docker compose up --build
3. Then you can try to send a request using helloric_ui_com. Or you can use the command line to test the service directly:

# Step 1: Enter the container
docker exec -it tour_persistence /bin/bash

# Step 2: Then inside the container
ros2 service call /tour_list ric_messages/srv/TourList

If everything is working, you should see something like this in the terminal, where you ran the docker compose up command:

tour_persistence  | [INFO] [1753977953.019991590] [persistent_tour_node]: Got tour list request
tour_persistence  | [INFO] [1753977953.022035559] [persistent_tour_node]: Found 8 tours
And in terminal where you ran the ros2 service call command, you should see the response:

requester: making request: ric_messages.srv.TourList_Request()

response:
ric_messages.srv.TourList_Response(name=['sample_tour2', 'sample_tour1', 'davaj', 'davaj_paka', 'ESO-Tour', 'tour_eso', 'tour_school', 'tour_tourism'])

You can also add a dummy tour to the database using the following command:

ros2 service call /tour_create ric_messages/srv/TourCreate "{
  tour: {
    tour_name: 'test_tour',
    map_name: 'test_map',
    step: [
      {
        description: 'Go to entrance',
        destination: 'entrance',
        dialogue: 'Welcome to the tour!'
      },
      {
        description: 'Show main hall',
        destination: 'main_hall',
        dialogue: 'This is the main hall.'
      }
    ]
  }
}"
And your response should look like this:

requester: making request: ric_messages.srv.TourCreate_Request(tour=ric_messages.msg.Tour(tour_name='test_tour', map_name='test_map', step=[ric_messages.msg.Step(index=0, description='Go to entrance', destination='entrance', dialogue='Welcome to the tour!'), ric_messages.msg.Step(index=0, description='Show main hall', destination='main_hall', dialogue='This is the main hall.')]))

response:
ric_messages.srv.TourCreate_Response(success=True)