README
pyhesai_wrapper
This repository holds code that is intended to provide a Python interface to the Hesai JT128 hemispherical LiDAR.
How to Build and Run
Prerequisites:
A C++17 compiler (like g++).
cmake (version 3.14 or higher, e.g.,
sudo apt install cmake).Python 3.12+ and pip (or uv).
Git (for cloning the Hesai SDK).
The Hesai SDK's system dependencies:
libpcap-dev,libssl-dev(e.g.,sudo apt install libpcap-dev libssl-dev).
Setup:
python3 -m venv .venv
source .venv/bin/activateThe build process is now fully automated. Simply run:
pip install .This will:
Read pyproject.toml
Use scikit-build to run CMakeLists.txt.
CMake will find pybind11, the SDK headers, and the SDK libraries.
It will compile pybind_hesai_sdk.cpp and link it against all the .a and .so files.
It will create a Python module file (e.g., pyhesai_wrapper_cpp.cpython-310-x86_64-linux-gnu.so) and install it into your Python environment.
If the build is successful, the pyhesai_wrapper module is now installed and available to all Python scripts in your environment.
Use in your python code
The LidarPointCloudFrame Dataclass
When you fetch points using lidar.get_next() or via the streaming generators, the system returns a LidarPointCloudFrame object (or None if no new data is available yet). The properties of this object are:
points: A NumPy array of shape(N, 3)containing the X, Y, and Z Cartesian coordinates of the captured points (dtype=float32).intensity: A NumPy 1D array of shape(N,)containing the return intensity values (dtype=uint8).timestamp: A NumPy 1D array of shape(N,)containing the microsecond tick timestamps for each point (dtype=float64).confidence: A NumPy 1D array of shape(N,)containing the confidence values (dtype=uint8).ring: A NumPy 1D array of shape(N,)containing the laser ring IDs (dtype=uint16).
Tools:
Live Lidar test (tools/stretch_lidar_show.py):
Edit
pyhesai_wrapper/config.yamlto configure your lidar settings:Update
device_ip_addressto match your lidar's IP (default:192.168.1.201)Update
correction_file_pathto point to your lidar's correction fileOptionally update other parameters like
udp_port,ptc_port, etc.
Make sure your machine is on the same network as the lidar.
Run the script:
or
You should see point cloud data streaming from the lidar. Press Ctrl-C to stop.
Download calibration (tools/REx_hesai_download_calibration.py):
Edit
pyhesai_wrapper/config.yamlto configure your lidar settings:Update
device_ip_addressto match your lidar's IP (default:192.168.1.201)Update
ptc_portto match your lidar's PTC port (default:9347)
Make sure your machine is on the same network as the lidar.
Run the script:
or
You should see calibration data being downloaded from the lidar to the
$HELLO_FLEET_PATH/$HELLO_FLEET_ID/calibration_hesaisdirectory.
PTC getters/setters (pyhesai_wrapper/ptc_client.py):
SDK-backed JT128 PTC client for return mode, point-cloud filter, PTP lock offset, diagnostics, and reachability checks.
Wrapper PTC bench test (stretch_ptc_test):
Interactive GET/SET test using only pyhesai_wrapper.ptc_client:
For each SET item: GET baseline → SET via wrapper → GET again (wrapper raises on readback mismatch).
Last updated
Was this helpful?
