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.4-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.4-cp38-abi3-musllinux_1_2_armv7l.whl (1.5 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARMv7l

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

Uploaded CPython 3.8+musllinux: musl 1.2+ ARM64

pelorus-0.0.4-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.4-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.4-cp38-abi3-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

pelorus-0.0.4-cp38-abi3-macosx_10_12_x86_64.whl (5.1 MB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for pelorus-0.0.4-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c11aac7bc5e39b5bb78ff3e9cb924e064a335afdcba3cda2702c1ffca9c321d6
MD5 ecf01e1a3274d29c46af4d6feac44d68
BLAKE2b-256 15e5c6dd0445a53a538117476abbfc6ec9b5bdcb157701ed0aac898bd83d8356

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pelorus-0.0.4-cp38-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 cd944e9368332a8539d5fed2e6ba3aca6b5b826023c7c73e2e05a28ca496e292
MD5 5c01da6a8ddb6f12faef9aa9b4fee154
BLAKE2b-256 8b956588d7d76a25766220ddc7a51010aad2f31e15404760951960d2d9fd3587

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pelorus-0.0.4-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 83898c0040f75c120036a1c4e2b72ddf0b5f33f0098510d0e63755db9cbc5896
MD5 fd90c8f100fa47925accbd87e4539c38
BLAKE2b-256 18509efe45043f6c2d46b2f627862d533306d937b2db24fe04a7c50cad3d9560

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pelorus-0.0.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f52a9efaf348d7e8f7f8a8734643d488d3d9618b0889596944512badba590fb9
MD5 e26228e9174ab4190cc75905dc6547a5
BLAKE2b-256 727367b40670ca07ac5c1ad99e64a0029d250753e4247df28dfa0e967344eb9a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pelorus-0.0.4-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b8b13199939d445ca8f3625b5fea9ceee1d25a459a788da3e959b459a291ea52
MD5 8fbb977f2abfe4c0e55be023846be85a
BLAKE2b-256 459dc6f6e27cfe909f8e17250c63814dce46c8740bf862f9727612b3ecfc685e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pelorus-0.0.4-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 55626955142957216930d4da7df26cb3df6954f1c3f3031e8c87931b43ca31cc
MD5 1e2eabfed4d5706c34029033ac2cccd3
BLAKE2b-256 6e1151cf75411bb682cdfc73e1f13979fd602bb02a164f5cb8950482639f0956

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pelorus-0.0.4-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 49fa5ae3e93a980b6576e9f8b19928a5bf4c2f195535f0d196c9f35ad2410844
MD5 7283a3c79e049d005c2d5ffb7a65dc8a
BLAKE2b-256 2381622b4daa6a8307b647150f1f0b50b615d5e767b5b5aaeccfd7f8055d2b60

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