Module ouster.sdk.examples
Copyright (c) 2021, Ouster, Inc. All rights reserved.
Code examples for using the Ouster SDK.
These modules are provided for documentation and testing purposes only, and should not be considered a stable public API.
Client Examples ouster.sdk.examples.client
Copyright (c) 2021, Ouster, Inc. All rights reserved.
Executable examples for using the sensor client APIs.
This module has a rudimentary command line interface. For usage, run:
$ python -m ouster.sdk.examples.client -h
- configure_dual_returns(hostname)[source]
Configure sensor to use dual returns profile given hostname
- Parameters:
hostname (
str
) – hostname of the sensor- Return type:
None
- configure_sensor_params(hostname)[source]
Configure sensor params given hostname
- Parameters:
hostname (
str
) – hostname of the sensor- Return type:
None
- fetch_metadata(hostname)[source]
Fetch metadata from a sensor and write it to disk.
Accurately reconstructing point clouds from a sensor data stream requires access to sensor calibration and per-run configuration like the operating mode and azimuth window.
The client API makes it easy to read metadata and write it to disk for use with recorded data streams.
- Parameters:
hostname (
str
) – hostname of the sensor- Return type:
None
- filter_3d_by_range_and_azimuth(hostname, lidar_port=7502, range_min=2)[source]
Easily filter 3D Point Cloud by Range and Azimuth Using the 2D Representation
- Parameters:
hostname (
str
) – hostname of sensorlidar_port (
int
) – UDP port to listen on for lidar datarange_min (
int
) – range minimum in meters
- Return type:
None
- live_plot_reflectivity(hostname, lidar_port=7502)[source]
Display reflectivity from live sensor
- Parameters:
hostname (
str
) – hostname of the sensorlidar_port (
int
) – UDP port to listen on for lidar data
- Return type:
None
- plot_xyz_points(hostname, lidar_port=7502)[source]
Display range from a single scan as 3D points
- Parameters:
hostname (
str
) – hostname of the sensorlidar_port (
int
) – UDP port to listen on for lidar data
- Return type:
None
- record_pcap(hostname, lidar_port=7502, imu_port=7503, n_seconds=10)[source]
Record data from live sensor to pcap file.
Note that pcap files recorded this way only preserve the UDP data stream and not networking information, unlike capturing packets directly from a network interface with tools like tcpdump or wireshark.
See the API docs of
pcap.record()
for additional options for writing pcap files.- Parameters:
hostname (
str
) – hostname of the sensorlidar_port (
int
) – UDP port to listen on for lidar dataimu_port (
int
) – UDP port to listen on for imu datan_seconds (
int
) – max seconds of time to record. (Ctrl-Z correctly closes streams)
- Return type:
None
PCAP Examples ouster.sdk.examples.pcap
Copyright (c) 2021, Ouster, Inc. All rights reserved.
Executable examples for using the pcap APIs.
This module has a rudimentary command line interface. For usage, run:
$ python -m ouster.sdk.examples.pcap -h
- pcap_3d_one_scan(source, metadata, num=0)[source]
Render one scan from a pcap file in the Open3D viewer.
- Parameters:
source (
PacketSource
) – PacketSource from pcapmetadata (
SensorInfo
) – associated SensorInfo for PacketSourcenum (
int
) – scan number in a given pcap file (satrs from 0)
- Return type:
None
- pcap_display_xyz_points(source, metadata, num=0)[source]
Plot point cloud using matplotlib.
- Return type:
None
- pcap_to_las(source, metadata, num=0, las_dir='.', las_base='las_out', las_ext='las')[source]
Write scans from a pcap to las files (one per lidar scan).
- Return type:
None
- pcap_to_pcd(source, metadata, num=0, pcd_dir='.', pcd_base='pcd_out', pcd_ext='pcd')[source]
Write scans from a pcap to pcd files (one per lidar scan).
- Return type:
None
- pcap_to_ply(source, metadata, num=0, ply_dir='.', ply_base='ply_out', ply_ext='ply')[source]
Write scans from a pcap to ply files (one per lidar scan).
- Return type:
None
- pcap_query_scan(source, metadata, num=0)[source]
Example: Query available fields in LidarScan
- Parameters:
source (
PacketSource
) – PacketSource from pcapmetadata (
SensorInfo
) – associated SensorInfo for PacketSourcenum (
int
) – scan number in a given pcap file (satrs from 0)
- Return type:
None
Open3D Examples ouster.sdk.examples.open3d
Examples PointViz
ouster.sdk.examples.viz
Copyright (c) 2021, Ouster, Inc. All rights reserved.
Example of custom visualizer use.
Intended to run with python -m ouster.sdk.examples.viz
Reference Code ouster.sdk.examples.reference
Copyright (c) 2021, Ouster, Inc. All rights reserved.
Reference implementations of common operations.
- xyz_proj_beam_to_sensor_transform(metadata, scan)[source]
Computes a point cloud from a scan as numpy array.
This is a reference implementation that follows the calculations from Section X of the Software User Manual exactly. Output is a point cloud in the sensor frame with points arranged in column-major order, with coordinates in meters.
- Parameters:
metadata (
SensorInfo
) – Sensor metadata associated with the scanscan (
LidarScan
) – A frame of lidar data
- Return type:
ndarray
- Returns:
A H x W x 3 array of point coordinates
- xyz_proj_origin_to_origin_mm(metadata, scan)[source]
Computes a point cloud from a scan as numpy array
This is the old reference implementation that follows the calculations from Section 3.1.2 of the FW 2.0 Software User Manual exactly for OS-0, OS-1, and OS-2 sensors. The output is a point cloud in the sensor frame with points arranged in column-major order, with coordinates in meters.
- Parameters:
metadata (
SensorInfo
) – Sensor metadata associated with the scanscan (
LidarScan
) – A frame of lidar data
- Return type:
ndarray
- Returns:
A H x W x 3 array of point coordinates
- destagger(pixel_shift_by_row, field)[source]
Reference implementation for destaggering a field of data.
In the default staggered representation, each column corresponds to a single timestamp. In the destaggered representation, each column corresponds to a single azimuth angle, compensating for the azimuth offset of each beam.
Destaggering is used for visualizing lidar data as an image or for algorithms that exploit the structure of the lidar data, such as beam_uniformity in ouster_viz, or computer vision algorithms.
- Parameters:
pixel_shift_by_row (
List
[int
]) – List of pixel shifts by row from sensor metadatafield (
ndarray
) – Staggered data as a H x W numpy array
- Return type:
ndarray
- Returns:
Destaggered data as a H x W numpy array