Skip to main content

add_virtual_wall

Service type: map_manager/srv/AddVirtualWall

Service name: /wall/add

Description​

Adds a virtual wall defined by its start and end points. GRW ignores request floor_id and wall.floor_id, assigns a numeric ID, and returns it as wall_id for later update or removal.

Request (Request)​

FieldTypeDescription
floor_idstringIDL compatibility field; ignored.
wallmap_manager/msg/VirtualWallUses x and y from start and end.

Response (Response)​

FieldTypeDescription
successboolWhether the operation succeeded.
messagestringResult message.
wall_idint32Numeric ID assigned on success.

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/wall/add map_manager/srv/AddVirtualWall \
"{wall: {start: {x: 0.0, y: 5.0}, end: {x: 10.0, y: 5.0}}}"

Python example​

Python
import rclpy
from geometry_msgs.msg import Point
from map_manager.msg import VirtualWall
from map_manager.srv import AddVirtualWall

rclpy.init()
node = rclpy.create_node('add_virtual_wall_client')
client = node.create_client(AddVirtualWall, 'wall/add')
client.wait_for_service()

request = AddVirtualWall.Request()
request.wall = VirtualWall(start=Point(x=0.0, y=5.0),
end=Point(x=10.0, y=5.0))
future = client.call_async(request)
rclpy.spin_until_future_complete(node, future)
print(future.result().success, future.result().wall_id)
node.destroy_node()
rclpy.shutdown()

C++ example​

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

int main(int argc, char* argv[]) {
rclcpp::init(argc, argv);
auto node = std::make_shared<rclcpp::Node>("add_virtual_wall_client");
auto client = node->create_client<map_manager::srv::AddVirtualWall>("wall/add");
client->wait_for_service();
auto request = std::make_shared<map_manager::srv::AddVirtualWall::Request>();
request->wall.start.x = 0.0;
request->wall.start.y = 5.0;
request->wall.end.x = 10.0;
request->wall.end.y = 5.0;
auto future = client->async_send_request(request);
rclcpp::spin_until_future_complete(node, future);
RCLCPP_INFO(node->get_logger(), "wall_id=%d", future.get()->wall_id);
rclcpp::shutdown();
}

Related services: ListVirtualWalls, UpdateVirtualWall, RemoveVirtualWall.