Mapdesc Persistence Node
Overview
This package provides a ROS node for managing persistent map-related data in MongoDB.
It supports operations like creating, updating, reading and deleting maps. Also it allows editing maps' walls, areas and markers.
The core implementation is located in src/mapdesc_persistence/mapdesc_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 '/mapdesc/create'(send mapdesc_msgs/srv/MapCreate request with Map)
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 MapCreate response (success: true/false)
deactivate Server
note right of Server: on_create ends
Services
The node provides the following services For managing maps, you can use the following services:
-
/mapdesc/create
: Create a new map. -
/mapdesc/update
: Update an existing map. -
/mapdesc/read
: Read a map by its name. -
/mapdesc/delete
: Delete a map by its name. -
/mapdesc/list
: List all maps.
And for managing map elements, you can use the following services (you should change <attribute name>
to the actual attribute you want to edit like wall
, area
or marker
):
-
/mapdesc/<attribute name>/create
: Create a new attribute in the map. -
/mapdesc/<attribute name>/update
: Update an existing attribute in the map. -
/mapdesc/<attribute name>/delete
: Delete an attribute by its ID. -
/mapdesc/<attribute name>/list
: List all elements in the specified attribute.
Format of the service requests and responses is defined in the mapdesc_msgs package.
Testing
To test the system:
1. Ensure the MongoDB container is running from the mongodb_server
- In the project root, run
- Then you can try to send a request. You can use the new terminal for this purpose:
If everything is working, you should see something like this in the terminal (if you have no maps yet):
requester: making request: mapdesc_msgs.srv.MapList_Request()
response:
mapdesc_msgs.srv.MapList_Response(map=[])
You can also add some dummy map
ros2 service call /mapdesc/create mapdesc_msgs/srv/MapCreate "{
map: {
name: 'test_map',
description: 'Dummy map for testing',
size: {width: 10.0, height: 5.0, length: 3.0},
resolution: 0.05,
origin: {x: 0.0, y: 0.0, z: 0.0},
marker: [],
area: [],
wall: [],
path: [],
ext: [],
lane_graph: {
nodes: [],
edges: []
}
}
}"
Then if you call service /mapdesc/list
again, you should see the map in the response:
requester: making request: mapdesc_msgs.srv.MapList_Request()
response:
mapdesc_msgs.srv.MapList_Response(map=[mapdesc_msgs.msg.Map(name='test_map', description='Dummy map for testing', size=mapdesc_msgs.msg.Dimension(width=0.0, height=0.0, length=0.0), resolution=0.05, origin=geometry_msgs.msg.Vector3(x=0.0, y=0.0, z=0.0), marker=[], area=[], wall=[], path=[], ext=[], lane_graph=mapdesc_msgs.msg.LaneGraph(nodes=[], edges=[]))])