Skip to main content

AddPOI

Service type: map_manager/srv/AddPOI

Service name: ${MM}/add_poi

Description

Add a new POI.

Request

FieldTypeDescription
poimap_manager/msg/POIPOI data.

Response

FieldTypeDescription
successboolWhether the operation succeeded.
messagestringResult details or an error message.

Examples

Example 1

Bash
# Add a charging-station POI
ros2 service call ${MM}/add_poi map_manager/srv/AddPOI \
"{poi: {id: 'charger_01', name: 'Main Charger', type: 'charging_station', floor_id: '1F', pose: {x: 5.0, y: 3.0, theta: 1.57}}}"

# Add a door POI
ros2 service call ${MM}/add_poi map_manager/srv/AddPOI \
"{poi: {id: 'door_101', name: 'Room 101 Door', type: 'door', floor_id: '1F', pose: {x: 10.0, y: 5.0, theta: 0.0}}}"

# Add a POI with custom properties
ros2 service call ${MM}/add_poi map_manager/srv/AddPOI \
"{poi: {id: 'station_01', name: 'Work Station 1', type: 'workstation', floor_id: '1F', pose: {x: 8.0, y: 6.0, theta: 3.14}, properties: '{\"capacity\": 2, \"equipment\": [\"computer\", \"printer\"]}'}}"

Example 2

Python
from map_manager.srv import AddPOI
from map_manager.msg import POI
from geometry_msgs.msg import Pose2D
import rclpy
from rclpy.node import Node
import json

class POIManager(Node):
def __init__(self):
super().__init__('poi_manager')
self.client = self.create_client(AddPOI, '/add_poi')
self.client.wait_for_service()

def add_poi(self, poi_id: str, name: str, poi_type: str, floor_id: str,
x: float, y: float, theta: float, properties: dict = None):
request = AddPOI.Request()
request.poi = POI(
id=poi_id,
name=name,
type=poi_type,
floor_id=floor_id,
pose=Pose2D(x=x, y=y, theta=theta),
properties=json.dumps(properties) if properties else ''
)

future = self.client.call_async(request)
rclpy.spin_until_future_complete(self, future)
result = future.result()

if result.success:
print(f"POI Added successfully: {poi_id}")
else:
print(f"Failed to add: {result.message}")
return result

rclpy.init()
manager = POIManager()

# Add a charging station
manager.add_poi(
poi_id='charger_01',
name='Main Charger',
poi_type='charging_station',
floor_id='1F',
x=5.0, y=3.0, theta=1.57,
properties={'voltage': 24, 'max_current': 10}
)

# Add a navigation waypoint
manager.add_poi(
poi_id='waypoint_01',
name='Patrol Point 1',
poi_type='waypoint',
floor_id='1F',
x=10.0, y=8.0, theta=0.0
)

rclpy.shutdown()

Example 3

C++
#include <rclcpp/rclcpp.hpp>
#include <map_manager/srv/add_poi.hpp>
#include <map_manager/msg/poi.hpp>

class POIManager : public rclcpp::Node {
public:
POIManager() : Node("poi_manager") {
client_ = create_client<map_manager::srv::AddPOI>("/add_poi");
client_->wait_for_service();
}

bool add_poi(const std::string& id, const std::string& name,
const std::string& type, const std::string& floor_id,
double x, double y, double theta) {
auto request = std::make_shared<map_manager::srv::AddPOI::Request>();
request->poi.id = id;
request->poi.name = name;
request->poi.type = type;
request->poi.floor_id = floor_id;
request->poi.pose.x = x;
request->poi.pose.y = y;
request->poi.pose.theta = theta;

auto future = client_->async_send_request(request);
if (rclcpp::spin_until_future_complete(shared_from_this(), future) ==
rclcpp::FutureReturnCode::SUCCESS) {
return future.get()->success;
}
return false;
}

private:
rclcpp::Client<map_manager::srv::AddPOI>::SharedPtr client_;
};

Common POI Types

TypeMeaningTypical Use
charging_stationCharging stationAutomatic charging
doorDoorDoor-aware navigation
elevatorElevator entranceMulti-floor navigation
waypointWaypointInspection routes
workstationWorkstationMaterial delivery
rest_areaRest areaWaiting location