Skip to main content

Pelorus - High Efficient Lidar Inertial Odometry

Project description

Pelorus Python Bindings

Python bindings for Pelorus - a LiDAR-Inertial Odometry system.

Installation

From source (requires Rust toolchain)

cd pelorus_py
pip install maturin
maturin develop --release

Or build a wheel:

maturin build --release
pip install target/wheels/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/list 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]
# For numpy/list inputs, you must also provide the scan header timestamp:
# lio.add_pointcloud(points_np, timestamp_sec=..., timestamp_nanosec=...)

# Try to receive odometry (non-blocking)
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"Points: {len(odom['points'])}")

# Or block until odometry is available
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_odom(...): Add an odometry measurement
  • add_pointcloud(cloud_dict): Add a point cloud (PointCloud2 format)
  • add_pointcloud(cloud_np, timestamp_sec=..., timestamp_nanosec=...): Add a point cloud from numpy
  • 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).

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pelorus-0.0.3-cp38-abi3-musllinux_1_2_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ x86-64

pelorus-0.0.3-cp38-abi3-musllinux_1_2_armv7l.whl (1.5 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARMv7l

pelorus-0.0.3-cp38-abi3-musllinux_1_2_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARM64

pelorus-0.0.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

pelorus-0.0.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

pelorus-0.0.3-cp38-abi3-macosx_11_0_arm64.whl (4.2 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

pelorus-0.0.3-cp38-abi3-macosx_10_12_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file pelorus-0.0.3-cp38-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pelorus-0.0.3-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 82a7eb7aaa34dd072f2e52e6998bbf9a4a589e9c32fc11b86b4214e610e48af9
MD5 2985b805f47f7100a306f83ae36f6292
BLAKE2b-256 321423397a60298c7707b61d96ed2223028aaf63539f307e99f4ed3fe3c67025

See more details on using hashes here.

File details

Details for the file pelorus-0.0.3-cp38-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for pelorus-0.0.3-cp38-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 a640fa589b7e9daa55bee254e7557245890877594d12a8286247785eb29d0730
MD5 c70cf7c0a7cfd0bd0f524aa8643dc07e
BLAKE2b-256 b3cbe04a07335ba07eb94d26e92b0eb070b5bc39b36da8f6c8ba96d8d7dc102f

See more details on using hashes here.

File details

Details for the file pelorus-0.0.3-cp38-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pelorus-0.0.3-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 318f8980f4042e336907e2a5e45ae355bffeaa86f6347478c5242501471c5585
MD5 ec0ed000c2a2420b89d789c57fe3fdb1
BLAKE2b-256 968d757dc9de09d6d7a33c350fcb6749f914b13ac855c0b5daa40592cddb40d4

See more details on using hashes here.

File details

Details for the file pelorus-0.0.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pelorus-0.0.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 16ccfc3ce51c28be9ab85dad81b2f1e545a20d5e1570476daf4389fd6930f6c6
MD5 567a5ae5fafd7e4e3b6c46bc2b59074d
BLAKE2b-256 5c43f6e37d4e58dbd9a308f94133ae9e6f71dbeb9ff2e00ed942ea4da6dd7146

See more details on using hashes here.

File details

Details for the file pelorus-0.0.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pelorus-0.0.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 15e8c0ffaf43172a355b7f4e1ef547de0f7aeed3f82c0d6ffdc953370789bc35
MD5 a8a10ed5b0eaefc1119906cee5d65aaa
BLAKE2b-256 c7562bec24657dd81160c13a3b767a87385141d3ff37883fb73ef7a88f9c2316

See more details on using hashes here.

File details

Details for the file pelorus-0.0.3-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pelorus-0.0.3-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 70e8758aa551e2814e47e7323190c7a18484c231be29c10b29d7f89f0a08d137
MD5 749f0cc0c2c1159f338d1f5b3ca0d926
BLAKE2b-256 389b452edddf478b96ca0aa197e6309a95e5f847af2a3fd880f2acbb1f0e802f

See more details on using hashes here.

File details

Details for the file pelorus-0.0.3-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pelorus-0.0.3-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9fbbce24e87d8bac1146b49eb87d03ef367d42cf6ad52a75142a2d32daed54eb
MD5 82e5c593f5f151e9e3aac019e4039928
BLAKE2b-256 ca5b4b69aada3e2cdbc434364aa7cba728715c5c9b4c3c3b135efebbee1924af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page