Skip to main content

Pelorus Python Bindings

Python bindings for Pelorus, a resource-aware lidar-inertial odometry.

Installation

From source (requires Rust toolchain)

cd pelorus_py
pip install maturin
maturin develop --release

Select at most one GPU backend when building:

maturin develop --release --features cuda
maturin develop --release --features vulkan
maturin develop --release --features metal

Metal is available on macOS. CUDA requires a supported NVIDIA CUDA installation. Vulkan requires a compatible device and driver. The default features enable Rayon CPU parallelism and include processing_time_ns in odometry results. Additional features are no-imu-sync and large-processing-queue. The legacy downsample feature is retained for compatibility but does not control the current configuration-based downsampling.

Or build a wheel:

maturin build --release --out dist
pip install dist/pelorus-*.whl

Usage

Basic API

import pelorus
import numpy as np

# Create Pelorus instance
lio = pelorus.Handle() # Uses embedded default config

# Or with custom config:
# lio = pelorus.Handle("path/to/config.rl")
#
# If you want to control PointCloud2 parsing (like `pelorus_create_with_options` in C):
# - device_specific_pointcloud2=True  (default)
# - device_specific_pointcloud2=False (generic parsing path)
# lio = pelorus.Handle("path/to/config.rl", device_specific_pointcloud2=False)

# Add IMU data
lio.add_imu(
    timestamp_sec=1000,
    timestamp_nanosec=0,
    orientation=[1.0, 0.0, 0.0, 0.0],  # w, x, y, z
    orientation_covariance=[0.01] + [0.0]*8,
    angular_velocity=[0.0, 0.0, 0.0],
    angular_velocity_covariance=[0.001] + [0.0]*8,
    linear_acceleration=[0.0, 0.0, 9.81],
    linear_acceleration_covariance=[0.01] + [0.0]*8,
)

# Add point cloud (recommended):
# - If you already have ROS2 messages, pass them directly:
#   lio.add_pointcloud2_ros(cloud_msg)
#
# - For non-ROS point sources, use NumPy/sequence inputs:
# - Nx3: [x,y,z] (no per-point timing)
# - Nx4: [x,y,z,t] where t is uint32 nanosecond offset
# - Nx5: [x,y,z,intensity,t]
# NumPy arrays may use float32 or float64. Inputs must be non-empty. The t value
# must be finite and in the uint32 range; fractional values are rounded to the
# nearest nanosecond. The scan header timestamp is required:
points = np.array([[1.0, 2.0, 3.0, 0.0]], dtype=np.float32)
scan_id = lio.add_pointcloud(
    points,
    timestamp_sec=1000,
    timestamp_nanosec=0,
)

# After feeding enough synchronized IMU and lidar data, receive odometry:
odom = lio.try_recv()
if odom:
    print(f"Position: {odom['position']}")
    print(f"Orientation: {odom['orientation']}")
    print(f"Linear velocity: {odom['linear_velocity']}")
    print(f"Accelerometer bias: {odom['accel_bias']}")
    print(f"Gyroscope bias: {odom['gyro_bias']}")
    print(f"Points: {len(odom['points'])}")

# Or block until the next odometry result is available. Do this only while
# another producer is feeding data or when an output is expected.
# odom = lio.recv()


# Or receive odometry asynchronously via callback (like pelorus_c)
def on_odom(odom: dict) -> None:
    print("Odom:", odom["timestamp_sec"], odom["timestamp_nanosec"], odom["position"])

lio.set_callback(on_odom)
# ... feed IMU / pointclouds ...
lio.clear_callback()  # equivalent to lio.set_callback(None)

Using with MCAP Bagfiles

See examples/bagfile_example.py for a complete example using real sensor data from an MCAP bagfile.

python -m pip install mcap mcap-ros2-support

API Reference

Handle

Main interface to the Pelorus system.

Constructor

  • Handle(config_path: str | None = None, device_specific_pointcloud2: bool = True): Create a new Pelorus instance

    device_specific_pointcloud2=False selects the generic parsing path for PointCloud2 inputs.

Methods

  • add_imu(...): Add an IMU measurement
  • add_imu_ros(imu_msg): Add a ROS2 sensor_msgs/msg/Imu object directly
  • add_odom(...): Add an odometry measurement
  • add_odom_ros(odom_msg): Add a ROS2 nav_msgs/msg/Odometry object directly
  • add_pointcloud(cloud_dict): Add a point cloud (PointCloud2 format)
  • add_pointcloud(cloud_np, timestamp_sec=..., timestamp_nanosec=...): Add a point cloud from a non-empty float32/float64 NumPy array
  • add_pointcloud(cloud_sequence, timestamp_sec=..., timestamp_nanosec=...): Add a point cloud from lists, tuples, or other Python sequences
  • add_pointcloud2_ros(cloud_msg): Add a ROS2 sensor_msgs/msg/PointCloud2 message directly
  • try_recv(): Try to receive odometry (non-blocking), returns None if no data
  • recv(): Receive odometry (blocks until available)
  • set_callback(callback): Deliver odometry via callback from a background thread. Disables try_recv()/recv() queuing while enabled
  • clear_callback(): Disable callback delivery (equivalent to set_callback(None))
  • version(): Get library version (static method)

Timestamp semantics

Pelorus uses two timestamp levels:

  1. IMU/Odom timestamps (timestamp_sec + timestamp_nanosec)

    • Absolute timestamps (typically epoch / ROS time) used for synchronization.
  2. Lidar timestamps

    • Scan header timestamp: absolute (sec/nanosec)
    • Per-point t field (if provided): uint32 nanoseconds offset, non-negative and forward in time relative to the scan header time.

The effective point time is:

point_time_abs = header_time_abs + (t * 1e-9)

Odometry outputs include timestamp_sec/timestamp_nanosec (and timestamp as float for convenience), scan_id, pose/twist data and covariances, accel_bias and gyro_bias in the IMU frame, a points NumPy array, and frame_id. Builds using the default processing-time-export feature also include processing_time_ns.

Development

# Install development dependencies
pip install maturin pytest black ruff

# Build and test
maturin develop
pytest

# Format code
black .
ruff check .

License

Dual-licensed under MIT or Apache-2.0, consistent with the Pelorus project.

Metadata

Release files for pelorus 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pelorus 0.2.0
File Size Uploaded Provenance Actions
pelorus-0.2.0.tar.gz 461.7 kB Without provenance Details for pelorus-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pelorus 0.2.0
File Actions
pelorus-0.2.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details for pelorus-0.2.0-cp39-abi3-musllinux_1_2_x86_64.whl
pelorus-0.2.0-cp39-abi3-musllinux_1_2_armv7l.whl CPython 3.9 abi3 Linux musl 1.2+ ARMv7l Details for pelorus-0.2.0-cp39-abi3-musllinux_1_2_armv7l.whl
pelorus-0.2.0-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details for pelorus-0.2.0-cp39-abi3-musllinux_1_2_aarch64.whl
pelorus-0.2.0-cp39-abi3-manylinux_2_34_aarch64.whl CPython 3.9 abi3 Linux glibc 2.34+ ARM64 Details for pelorus-0.2.0-cp39-abi3-manylinux_2_34_aarch64.whl
pelorus-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for pelorus-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pelorus-0.2.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl CPython 3.9 abi3 Linux glibc 2.17+ ARMv7l Details for pelorus-0.2.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
pelorus-0.2.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for pelorus-0.2.0-cp39-abi3-macosx_11_0_arm64.whl

Total release size: 23.4 MB

Release files / pelorus-0.2.0.tar.gz

Download URL pelorus-0.2.0.tar.gz
Size 461.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9465234423262dfdd58e4f43b3b9f1a0771162ecf12319debab50e6c8b10651d
BLAKE2b-256 checksum
How to use checksums
4d8c561e248559a8e52dc15d1a8a4ea7e04687805067d4a4b557cf6d57900493
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / pelorus-0.2.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL pelorus-0.2.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 3.8 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
fc5202cb45b95d10741433d43d21aa5ec0145aea6b0134a09b15b8e5f0387b9b
BLAKE2b-256 checksum
How to use checksums
e99618ec3dee727781f90e74e14afaf92f05a5b16a3ae1c49236292c9d785ada
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / pelorus-0.2.0-cp39-abi3-musllinux_1_2_armv7l.whl

Download URL pelorus-0.2.0-cp39-abi3-musllinux_1_2_armv7l.whl
Size 2.9 MB
Tags CPython 3.9 Linux musl 1.2+ ARMv7l abi3
SHA-256 checksum
How to use checksums
86c58d1f73b86006ee704c6c6e301b089de13d3e6bef5900a4d3e925799a7892
BLAKE2b-256 checksum
How to use checksums
e3690c3c18bb4e94c9e93b150e35e7c9b45da83d50d4159c63bc8d68b6aaad97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / pelorus-0.2.0-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL pelorus-0.2.0-cp39-abi3-musllinux_1_2_aarch64.whl
Size 3.3 MB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
2579b6c1b897d48224f03e208ce742ed28f600694adc9f4f7275cd543b6c6a07
BLAKE2b-256 checksum
How to use checksums
74916846e4e904c0dd8a730f5964c07484ae437594614ec14e2fc13792e785ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / pelorus-0.2.0-cp39-abi3-manylinux_2_34_aarch64.whl

Download URL pelorus-0.2.0-cp39-abi3-manylinux_2_34_aarch64.whl
Size 3.2 MB
Tags CPython 3.9 Linux glibc 2.34+ ARM64 abi3
SHA-256 checksum
How to use checksums
a77e2a20a7f830b1ff58e7819a9f1cd8cb65ab38c1105aa430c69d66794f2cd0
BLAKE2b-256 checksum
How to use checksums
d627633b1f0d7536fb5b6d7190335d1c09d6bebf6142a7e434d941f424c3d2df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / pelorus-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pelorus-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.8 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
02ddb295e7803a8946628e5cd9a0e16a728a416209c0cafe3a6f9e514a411c4d
BLAKE2b-256 checksum
How to use checksums
8e6d76e686942c2f8f235e347b19b6907cdef778b32c9a6c20341164f74829a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / pelorus-0.2.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

Download URL pelorus-0.2.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 2.8 MB
Tags CPython 3.9 Linux glibc 2.17+ ARMv7l abi3
SHA-256 checksum
How to use checksums
e69144666ccfce236dc469a64aa3a9466476e7612c0f77aca2b6835c192f0dcc
BLAKE2b-256 checksum
How to use checksums
d8a4f5deb307fada16cb6950570e02f5f1324a2c4ec5426e32458f6278d561e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / pelorus-0.2.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL pelorus-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
Size 3.2 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
89145b0e08200387ff1a03d3813ab3475384ce168b0d119c5c43f701d4b5f030
BLAKE2b-256 checksum
How to use checksums
3266da2b71c396de012c0003283388fa4ac613cc6e307895c8e3d9aa2dad7a4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for pelorus 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page