Skip to main content

add_poi

Service type: map_manager/srv/AddPOI

Service name: /poi/add

Description​

Adds a POI to the current GRW map. The request poi.id is passed through unchanged as the final id of the POI, so /poi/list and /poi/remove use that same id; supply a non-empty id that is unique within the current map. Only poi.id, poi.name, and poi.pose.x, y, and theta are read. Do not rely on type, floor_id, height, or properties.

Request (Request)​

FieldTypeDescription
poimap_manager/msg/POIid is passed through as the final id (use a non-empty, unique value); uses id, name, pose.x, pose.y, and pose.theta.

Response (Response)​

FieldTypeDescription
successboolWhether the operation succeeded.
messagestringResult message.

Example​

Complete Environment Preparation first: the CLI examples require ROBOT_NAMESPACE to be set; the Python and C++ examples use relative service names, so append --ros-args -r __ns:=$ROBOT_NAMESPACE when running them.

CLI call​

Bash
ros2 service call $ROBOT_NAMESPACE/poi/add map_manager/srv/AddPOI \
"{poi: {id: 'gr_charger_01', name: 'Main Charger', pose: {x: 5.0, y: 3.0, theta: 1.57}}}"

Python example​

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

rclpy.init()
node = rclpy.create_node('add_poi_client')
client = node.create_client(AddPOI, 'poi/add')
client.wait_for_service()

request = AddPOI.Request()
request.poi = POI(id='gr_charger_01', name='Main Charger',
pose=Pose2D(x=5.0, y=3.0, theta=1.57))
future = client.call_async(request)
rclpy.spin_until_future_complete(node, future)
print(future.result().success, future.result().message)
# poi.id is the final id; list/remove use that same id
node.destroy_node()
rclpy.shutdown()

C++ example​

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

int main(int argc, char* argv[]) {
rclcpp::init(argc, argv);
auto node = std::make_shared<rclcpp::Node>("add_poi_client");
auto client = node->create_client<map_manager::srv::AddPOI>("poi/add");
client->wait_for_service();
auto request = std::make_shared<map_manager::srv::AddPOI::Request>();
request->poi.id = "gr_charger_01";
request->poi.name = "Main Charger";
request->poi.pose.x = 5.0;
request->poi.pose.y = 3.0;
request->poi.pose.theta = 1.57;
auto future = client->async_send_request(request);
rclcpp::spin_until_future_complete(node, future);
RCLCPP_INFO(node->get_logger(), "%s", future.get()->message.c_str());
rclcpp::shutdown();
}