Skip to main content

Decoder for raw Velodyne packet data

Project description

velodyne_decoder PyPI Build PyPI - Downloads

Python package and C++ library for Velodyne packet decoding. Point cloud extraction from PCAP and ROS bag files is supported out of the box.

The decoded point clouds are provided either as a structured NumPy array:

array([(2.6912806, 1.1651788 , -0.47706223,  9., -0.10085896,   0, 16, 1),
       (2.3603256, 1.021404  , -1.428755  , 85., -0.10085782,   0,  1, 1),
       (2.6994078, 1.1675802 , -0.4092741 ,  3., -0.10085666,   0, 17, 1),
       ...,
       (2.8952641, 0.80728334,  0.48905915,  2.,  0.00054029, 923, 30, 1),
       (2.8683424, 0.79923725, -0.5555609 ,  2.,  0.00054144, 923, 15, 1),
       (2.908243 , 0.80980825,  0.56333727,  1.,  0.00054259, 923, 31, 1)],
      dtype={'names': ['x', 'y', 'z', 'intensity', 'time', 'column', 'ring', 'return_type'], 
             'formats': ['<f4', '<f4', '<f4', '<f4', '<f4', '<u2', 'u1', 'u1'], 
             'offsets': [0, 4, 8, 12, 16, 20, 22, 23], 'itemsize': 32})

or as a contiguous array of floats (default):

array([[2.691281, 1.165179, -0.477062,  9., -0.100859,   0., 16., 1.],
       [2.360326, 1.021404, -1.428755, 85., -0.100858,   0.,  1., 1.],
       [2.699408, 1.16758 , -0.409274,  3., -0.100857,   0., 17., 1.],
       ...,
       [2.895264, 0.807283,  0.489059,  2.,  0.00054 , 923., 30., 1.],
       [2.868342, 0.799237, -0.555561,  2.,  0.000541, 923., 15., 1.],
       [2.908243, 0.809808,  0.563337,  1.,  0.000543, 923., 31., 1.]], dtype=float32)

Installation

Wheels are available from PyPI for Linux, MacOS and Windows. Python versions 3.7+ are supported.

pip install velodyne-decoder

Alternatively, you can build and install the development version from source.

sudo apt-get install cmake build-essential python3-dev
pip install git+https://github.com/valgur/velodyne_decoder.git

Usage

Decoding Velodyne data from a ROS bag

import velodyne_decoder as vd

bagfile = 'xyz.bag'
lidar_topics = ['/velodyne_packets']
cloud_arrays = []
for stamp, points, topic in vd.read_bag(bagfile, topics=lidar_topics):
    cloud_arrays.append(points)

The rosbag library must be installed. If needed, you can install it without setting up the entire ROS stack with

pip install rosbag --extra-index-url https://rospypi.github.io/simple/

To extract all VelodyneScan messages in the bag you can leave the list of topics unspecified.

The header timestamp from the scan messages will be returned by default. To use the message arrival time instead set use_header_time=False.

To return arrays of structs instead of the default contiguous arrays, set as_pcl_structs=True.

Decoding Velodyne data from a PCAP file

import velodyne_decoder as vd

pcap_file = 'vlp16.pcap'
cloud_arrays = []
for stamp, points in vd.read_pcap(pcap_file):
    cloud_arrays.append(points)

To return arrays of structs instead of the default contiguous arrays, set as_pcl_structs=True.

Configuration

You can pass a velodyne_decoder.Config object to all decoder functions. The following options are available:

  • min_range and max_range – only return points between these range values.
  • min_angle and max_angle – only return points between these azimuth angles.
  • timestamp_first_packet – whether the scan timestamps are set based on the first or last packet in the scan.
  • cut_angle – when working with a raw packet stream, if unset (by default), the stream is split into a "scan" every time at least 360 degrees have been covered. If set, the splitting always occurs at the specified azimuth angle instead. Note that the scan might cover less than 360 degrees in this case.

Only required for data from HDL-64E sensors:

  • model – the sensor model ID. See velodyne_decoder.Model.__entries for the possible values.
  • calibration_file – beam calibration parameters in a YAML format. You can either extract the calibration info from a PCAP file with packets using extract-hdl64e-calibration <pcap_file> or convert a db.xml provided with the sensor using gen_calibration.py from the ROS driver.

Authors

The core functionality has been adapted from the ROS velodyne driver.

License

BSD 3-Clause License

Project details


Download files

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

Source Distribution

velodyne_decoder-3.0.0.tar.gz (73.3 kB view hashes)

Uploaded Source

Built Distributions

velodyne_decoder-3.0.0-cp312-abi3-win_amd64.whl (296.8 kB view hashes)

Uploaded CPython 3.12+ Windows x86-64

velodyne_decoder-3.0.0-cp312-abi3-musllinux_1_1_x86_64.whl (965.1 kB view hashes)

Uploaded CPython 3.12+ musllinux: musl 1.1+ x86-64

velodyne_decoder-3.0.0-cp312-abi3-musllinux_1_1_aarch64.whl (918.4 kB view hashes)

Uploaded CPython 3.12+ musllinux: musl 1.1+ ARM64

velodyne_decoder-3.0.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (473.1 kB view hashes)

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

velodyne_decoder-3.0.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (438.0 kB view hashes)

Uploaded CPython 3.12+ manylinux: glibc 2.17+ ARM64

velodyne_decoder-3.0.0-cp312-abi3-macosx_11_0_arm64.whl (326.4 kB view hashes)

Uploaded CPython 3.12+ macOS 11.0+ ARM64

velodyne_decoder-3.0.0-cp312-abi3-macosx_10_15_x86_64.whl (351.8 kB view hashes)

Uploaded CPython 3.12+ macOS 10.15+ x86-64

velodyne_decoder-3.0.0-cp311-cp311-win_amd64.whl (296.4 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

velodyne_decoder-3.0.0-cp311-cp311-musllinux_1_1_x86_64.whl (966.8 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

velodyne_decoder-3.0.0-cp311-cp311-musllinux_1_1_aarch64.whl (920.2 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ ARM64

velodyne_decoder-3.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (472.8 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

velodyne_decoder-3.0.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (438.7 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

velodyne_decoder-3.0.0-cp311-cp311-macosx_11_0_arm64.whl (324.3 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

velodyne_decoder-3.0.0-cp311-cp311-macosx_10_15_x86_64.whl (347.2 kB view hashes)

Uploaded CPython 3.11 macOS 10.15+ x86-64

velodyne_decoder-3.0.0-cp310-cp310-win_amd64.whl (295.1 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

velodyne_decoder-3.0.0-cp310-cp310-musllinux_1_1_x86_64.whl (965.3 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

velodyne_decoder-3.0.0-cp310-cp310-musllinux_1_1_aarch64.whl (919.2 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ ARM64

velodyne_decoder-3.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (471.4 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

velodyne_decoder-3.0.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (437.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

velodyne_decoder-3.0.0-cp310-cp310-macosx_11_0_arm64.whl (322.9 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

velodyne_decoder-3.0.0-cp310-cp310-macosx_10_15_x86_64.whl (345.8 kB view hashes)

Uploaded CPython 3.10 macOS 10.15+ x86-64

velodyne_decoder-3.0.0-cp39-cp39-win_amd64.whl (290.2 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

velodyne_decoder-3.0.0-cp39-cp39-musllinux_1_1_x86_64.whl (965.6 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

velodyne_decoder-3.0.0-cp39-cp39-musllinux_1_1_aarch64.whl (919.5 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ ARM64

velodyne_decoder-3.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (471.5 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

velodyne_decoder-3.0.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (437.8 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

velodyne_decoder-3.0.0-cp39-cp39-macosx_11_0_arm64.whl (323.0 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

velodyne_decoder-3.0.0-cp39-cp39-macosx_10_15_x86_64.whl (345.9 kB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

velodyne_decoder-3.0.0-cp38-cp38-win_amd64.whl (295.2 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

velodyne_decoder-3.0.0-cp38-cp38-musllinux_1_1_x86_64.whl (965.2 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

velodyne_decoder-3.0.0-cp38-cp38-musllinux_1_1_aarch64.whl (919.1 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ ARM64

velodyne_decoder-3.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (471.0 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

velodyne_decoder-3.0.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (437.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

velodyne_decoder-3.0.0-cp38-cp38-macosx_11_0_arm64.whl (323.1 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

velodyne_decoder-3.0.0-cp38-cp38-macosx_10_15_x86_64.whl (346.0 kB view hashes)

Uploaded CPython 3.8 macOS 10.15+ x86-64

Supported by

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