> For the complete documentation index, see [llms.txt](https://docs.hello-robot.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hello-robot.com/stretch4_docs/working-with-stretch/sensor_basics/accessing-the-lidars.md).

# Accessing the Lidars

Stretch 4 has two hemispherical lidars in the head. Each lidar yields 115,200 points per frame at 10 Hz (1,152,000 points/second).

This document will cover:

* [Visualizing the lidars with ROS2](#visualizing-the-lidars-with-ros2)
  * [Using the lidars in your code with ROS2](#using-the-lidars-in-your-code-with-ros2)
* [Visualizing the lidars with Python](#visualizing-the-lidars-with-python)
  * [Using the lidars in your code with python](#using-the-lidars-in-your-code-with-python)

## Visualizing The Lidars With ROS2

In your terminal, start these launch files:

Terminal 1:

```
ros2 launch stretch_core stretch_driver.launch.py
```

Terminal 2:

```
ros2 launch stretch_core dual_hesai.launch.py use_rviz:=true
```

The latter command will start rviz2, with a live visualization of the lidars aligned using the urdf.

<img src="https://github.com/user-attachments/assets/64842ee2-3337-4a3b-a17e-27a6a56193cf" alt="image" height="2052" width="3726">

`dual_hesai.launch.py` is a launch file that lives on the robot at `~/ament_ws/src/stretch4_ros2/stretch_core/launch`. A preview of the file can be found [here](https://github.com/hello-robot/stretch4_ros2/blob/jazzy/stretch_core/launch/dual_hesai.launch.py).

### Using The Lidars In Your Code With ROS2

The `dual_hesai.launch.py` launch file will publish two PointCloud2 topics:

* `/lidar_points_left`
* `/lidar_points_right`

You can subscribe to these topics in your ROS2 node to receive point cloud points.

## Visualizing The Lidars With Python

To access the lidars using python, use [`stretch4_pyhesai_wrapper`](https://github.com/hello-robot/stretch4_pyhesai_wrapper).

In your terminal, launch:

```
stretch_lidar_show
```

This will start a [Rerun](https://rerun.io/) window with the raw, untransformed points from each lidar.

<img src="https://github.com/user-attachments/assets/f68d7caa-8a5c-4076-8acc-939860b761cd" alt="image" width="800">

### Using The Lidars In Your Code With Python

Similar to the Camera API, `stretch4_pyhesai_wrapper` offers a Stream API that allows you to access lidar points using a python Generator:

```
from pyhesai_wrapper import stream_lidar_left

# Continually yields LidarPointCloudFrame objects as long as it's running
for frame in stream_lidar_left():
    if frame is not None:
        print(f"Points shape: {frame.points.shape}, timestamp: {frame.timestamp}")
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hello-robot.com/stretch4_docs/working-with-stretch/sensor_basics/accessing-the-lidars.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
