> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.stereolabs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.stereolabs.com/_mcp/server.

# Using Plane Detection with ROS 2

In this tutorial, you will learn how to exploit the Plane Detection capabilities of the ZED SDK to detect the planes in the environment where a ZED camera is operating.

## Start a plane detection task

The ZED ROS 2 node subscribes to the topic `/clicked_point` of type [geometry\_msgs/PointStamped](https://docs.ros2.org/latest/api/geometry_msgs/msg/PointStamped.html), usually published by RViz 2.

When a message on the topic `/clicked_point` is received, the node searches for the first plane hit by a virtual ray starting from the camera optical center and virtually passing through the received 3D point.

If a plane is found, its position and orientation are calculated, the 3D mesh is extracted and all the useful plane information is published as a custom [zed\_msgs/PlaneStamped](#detected-plane-message) message on the topic `/<camera_name>/<node_name>/plane`.

A second message of type `visualization_msgs/Marker` with information useful for visualization is published on the topic `/<camera_name>/<node_name>/plane_marker` in order to display the plane using a [Marker display plugin](https://docs.ros.org/en/humble/Tutorials/Intermediate/RViz/Marker-Display-types/Marker-Display-types.html) in RViz 2.

![Planes](/_fern-img/919bdc4eab7e6567289012e4a231dbcecaf6e7291abedd7fd90a0041321ea1f3.webp)

![Planes no clouds](/_fern-img/b258b50316f98c872ed42cfe8b2f5085a907ae45528237e13eba87326766da26.webp)

### Logging

When a plane detection is started, the log of the ZED ROS 2 Wrapper shows the following information:

```bash
[zed_wrapper-2] 1651505097.533702002 [zed2i.zed_node] [INFO] Clicked 3D point [X FW, Y LF, Z UP]: [2.04603,-0.016467,0.32191]
[zed_wrapper-2] 1651505097.533748287 [zed2i.zed_node] [INFO] 'map' -> 'zed2i_left_camera_optical': {0.061,0.010,0.011} {0.495,-0.534,0.466,0.503}
[zed_wrapper-2] 1651505097.533775284 [zed2i.zed_node] [INFO] Point in camera coordinates [Z FW, X RG, Y DW]: {0.044,-0.436,2.034}
[zed_wrapper-2] 1651505097.533812591 [zed2i.zed_node] [INFO] Clicked point image coordinates: [655.536,231.765]
[zed_wrapper-2] 1651505097.592107647 [zed2i.zed_node] [INFO] Found plane at point [2.046,-0.016,0.322] -> Center: [1.909,-0.760,-0.007], Dims: 1.681x2.519
```

## RViz 2

The RViz 2 GUI lets you easily start a plane detection task and displays the results of the detection.

### Start a plane detection

To publish a `/clicked_point` message and start a plane detection, the `Publish Point` button must be enabled and a point in the 3D view or the camera view must be clicked.

![Publish Point](/_fern-img/6a493eb7a05c0cbcdb1e935470159586918be7ea7888dbefd576f9444dd5d4d8.webp)

### Configure RViz to display the results

The Marker plugin allows you to visualize the information of the detected planes.

![Marker](/_fern-img/d80baa4de27bc8f9363612f5039d7c41836172d8d8065f878ef1c5c169eafdd5.webp)

Key parameters:

* `Topic`: The topic that contains the information relative to the detected planes: e.g. `/zed/zed_node/plane_marker`
* `Depth`: The size of the message queue. Use at least a value of `2` to not lose messages.
* `History policy`: Set the QoS history policy. `Keep Last` is suggested for performance and compatibility.
* `Reliability Policy`: Set the QoS reliability policy. `Best Effort` is suggested for performance and compatibility.
* `Durability Policy`: Set the QoS durability policy. `Volatile` is suggested for compatibility.
* `Namespaces`: The list of available information:
  * `plane_hit_points`: Select to display a sphere where the click has been received.
  * `plane_meshes`: Select to display all the meshes of the detected planes.

## Detected Plane message

The custom `zed_msgs/PlaneStamped` message is defined in the [zed-ros2-interfaces](https://github.com/stereolabs/zed-ros2-interfaces) repository. See the [Custom Message Types](/docs/integrations/ros-2/custom-msgs/#plane-detection-result) page for its definition.