API Reference

Module ouster.client

Python sensor client.


Core

exception ClientError[source]

Base class for client errors.

exception ClientTimeout[source]

Raised when data does not arrive within the expected time.

exception ClientOverflow[source]

Raised when data loss is possible due to internal buffers filling up.

class PacketSource[source]

Bases: typing_extensions.Protocol

Represents a single-sensor data stream.

__iter__()[source]

A PacketSource supports Iterable[Packet].

Currently defined explicitly due to: https://github.com/python/typing/issues/561

Return type

Iterator[Union[ImuPacket, LidarPacket]]

property metadata: ouster.client._client.SensorInfo

Metadata associated with the packet stream.

Return type

SensorInfo

close()[source]

Release the underlying resource, if any.

Return type

None

class Packets(it, metadata)[source]

Create a PacketSource from an existing iterator.

Parameters
property metadata: ouster.client._client.SensorInfo

Metadata associated with the packet stream.

Return type

SensorInfo

__iter__()[source]

Return the underlying iterator.

Return type

Iterator[Union[ImuPacket, LidarPacket]]

close()[source]

Release the underlying resource, if any.

Return type

None

class Sensor(hostname='localhost', lidar_port=7502, imu_port=7503, *, metadata=None, buf_size=128, timeout=1.0, _overflow_err=False, _flush_before_read=True)[source]

A packet source listening on local UDP ports.

Uses a separate thread that fills internal buffers without holding the GIL.

Note

Make sure close() will be called on all instances before Python attempts to exit, or the interpreter will hang waiting to join the thread (like any other non-daemonized Python thread).

Neither the ports nor udp destination configuration on the sensor will be updated. The metadata will be fetched over the network from the sensor unless explicitly provided using the metadata parameter.

Parameters
  • hostname (str) – hostname of the sensor

  • lidar_port (int) – UDP port to listen on for lidar data

  • imu_port (int) – UDP port to listen on for imu data

  • metadata (Optional[SensorInfo]) – explicitly provide metadata for the stream

  • buf_size (int) – number of packets to buffer before dropping data

  • timeout (Optional[float]) – seconds to wait for packets before signaling error or None

  • _overflow_err (bool) – if True, raise ClientOverflow

  • _flush_before_read (bool) – if True, try to clear buffers before reading

Raises

ClientError – If initializing the client fails.

write_metadata(path)[source]

Save metadata to disk.

Parameters

path (str) – path to write

Return type

None

property metadata: ouster.client._client.SensorInfo

Metadata associated with the packet stream.

Return type

SensorInfo

__iter__()[source]

Access the UDP data stream as an iterator.

Reading may block waiting for network data for up to the specified timeout. Failing to consume this iterator faster than the data rate of the sensor may cause packets to be dropped.

Raises
  • ClientTimeout – if no packets are received within the configured timeout.

  • ClientError – if the client enters an unspecified error state.

  • ValueError – if the packet source has already been closed

Return type

Iterator[Union[ImuPacket, LidarPacket]]

flush(n_frames=3, *, full=False)[source]

Drop some data to clear internal buffers.

Parameters
  • n_frames (int) – number of frames to drop

  • full – clear internal buffers first, so data is read from the OS receive buffers (or the network) directly

Raises

ClientTimeout – if a lidar packet is not received within the configured timeout.

Return type

int

close()[source]

Shut down producer thread and close network connection.

Attributes may be unset if constructor throws an exception.

Return type

None

class Scans(source, *, complete=False, timeout=None, _max_latency=0)[source]

An iterable stream of scans batched from a PacketSource.

Batching will emit a scan every time the frame_id increments (i.e. on receiving first packet in the next scan). Reordered packets will be handled, except across frame boundaries: packets from the previous scan will be dropped.

Optionally filters out incomplete frames and enforces a timeout. A batching timeout can be useful to detect when we’re only receiving incomplete frames or only imu packets. Can also be configured to manage internal buffers for soft real-time applications.

Parameters
  • source (PacketSource) – any source of packets

  • complete (bool) – if True, only return full scans

  • timeout (Optional[float]) – seconds to wait for a scan before error or None

  • _max_latency (int) – (experimental) approximate max number of frames to buffer

__iter__()[source]

Get an iterator.

Return type

Iterator[LidarScan]

close()[source]

Close the underlying PacketSource.

Return type

None

property metadata: ouster.client._client.SensorInfo

Return metadata from the underlying PacketSource.

Return type

SensorInfo

classmethod sample(hostname='localhost', n=1, lidar_port=7502, *, metadata=None)[source]

Conveniently sample n consecutive scans from a sensor.

Does not leave UDP ports open. Suitable for interactive use.

Parameters
  • hostname (str) – hostname of the sensor

  • n (int) – number of consecutive frames in each sample

  • lidar_port (int) – UDP port to listen on for lidar data

  • metadata (Optional[SensorInfo]) – explicitly provide metadata for the stream

Return type

Tuple[SensorInfo, Iterator[List[LidarScan]]]

Returns

A tuple of metadata queried from the sensor and an iterator that samples n consecutive scans

classmethod stream(hostname='localhost', lidar_port=7502, *, buf_size=640, timeout=1.0, complete=True, metadata=None)[source]

Stream scans from a sensor.

Will drop frames preemptively to avoid filling up internal buffers and to avoid returning frames older than the scanning period of the sensor.

Parameters
  • hostname (str) – hostname of the sensor

  • lidar_port (int) – UDP port to listen on for lidar data

  • timeout (float) – seconds to wait for scans before signaling error

  • complete (bool) – if True, only return full scans

  • metadata (Optional[SensorInfo]) – explicitly provide metadata for the stream

Return type

Scans


Metadata

class SensorInfo

Sensor metadata required to interpret UDP data streams. Please see sensor documentaiton for the meaning of each property.

Parameters

raw (str) – json string to parse

property beam_altitude_angles

Beam altitude angles, useful for XYZ projection.

property beam_azimuth_angles

Beam azimuth angles, useful for XYZ projection.

property extrinsic

Extrinsic Matrix.

property format

Describes the structure of a lidar packet.

from_default()

Create gen-1 OS-1-64 metadata populated with design values.

property fw_rev

Sensor firmware revision.

property hostname

Sensor hostname.

property imu_to_sensor_transform

Homogenous transformation matrix representing IMU offset to Sensor Coordinate Frame.

property lidar_origin_to_beam_origin_mm

Distance between lidar origin and beam origin in millimeters.

property lidar_to_sensor_transform

Homogeneous transformation matrix from Lidar Coordinate Frame to Sensor Coordinate Frame.

property mode

Lidar mode, e.g., 1024x10.

property prod_line

Product line, e.g., ‘OS-1-128’.

property sn

Sensor serial number.

class SensorConfig

Corresponds to sensor config parameters. Please see sensor documentaiton for the meaning of each property.

Parameters

raw (str) – json string to parse

property azimuth_window

Tuple representing the visible region of interest of the sensor in millidegrees, .e.g., (0, 360000) for full visibility.

property lidar_mode

Horizontal and Vertical Resolution rate of sensor as mode, e.g., 1024x10. See class LidarMode.

property multipurpose_io_mode

Mode of MULTIPURPOSE_IO pin. See class MultipurposeIOMode.

property nmea_baud_rate

Expected baud rate sensor attempts to decode for NMEA UART input $GPRMC messages.

property nmea_ignore_valid_char

NMEA Ignore Valid Char. True corresponds to 1 and False to 0 for property; see sensor documentaiton for details.

property nmea_in_polarity

Polarity of NMEA UART input $GPRMC messages. See sensor documentaiton for details.

property nmea_leap_seconds

Integer number of leap seconds that will be added to the UDP timetsamp when calculating seconds since Unix Epoch time. See sensor documentaiton for details.

property operating_mode

Operating Mode of sensor. See class OperatingMode.

property phase_lock_enable

Enable phase lock. See sensor documentaiton for more details.

property phase_lock_offset

Angle in Lidar Coordinate Frame that sensors are locked to, in millidegrees. See sensor documentaiton for details.

property signal_multiplier

Multiplier for signal strength of sensor, corresponding to maximum allowable azimuth_window. Gen 2 Only.

property sync_pulse_in_polarity

Polarity of SYNC_PULSE_IN pin. See sensor documentaiton for details.

property sync_pulse_out_angle

Polarity of SYNC_PULSE_OUT output. See sensor documentaiton for details.

property sync_pulse_out_frequency

SYNC_PULSE_OUT rate. See sensor documentaiton for details.

property sync_pulse_out_polarity

Polarity of SYNC_PULSE_OUT output. See sensor documentaiton for details.

property sync_pulse_out_pulse_width

SYNC_PULSE_OUT pulse width in ms. See sensor documentaiton for details.

property timestamp_mode

Timestamp mode of sensor. See class TimestampMode.

property udp_dest

Destination to which sensor sends UDP traffic.

property udp_port_imu

Port on UDP destination to which IMU data will be sent.

property udp_port_lidar

Port on UDP destination to which lidar data will be sent.

get_config()

Returns sensor config parameters as SensorConfig .

Parameters
  • hostname (str) – hostname of the sensor

  • active (bool) – return active or staged sensor configuration

set_config()

Set sensor config parameters on sensor.

Parameters
  • hostname (str) – hostname of the sensor

  • config (SensorConfig) – config to set sensor parameters to

  • persist (bool) – persist parameters after sensor disconnection (default = False)

  • udp_dest_auto – automatically determine sender’s IP at the time command was sent and set it as destination of UDP traffic. Function will error out if config has udp_dest member. (default = False)

class LidarMode

Possible Lidar Modes of sensor, corresponding to horizontal and vertical resolution rates of sensor. See sensor documentaiton for details.

MODE_1024x10 = LidarMode.MODE_1024x10
MODE_1024x20 = LidarMode.MODE_1024x20
MODE_2048x10 = LidarMode.MODE_2048x10
MODE_512x10 = LidarMode.MODE_512x10
MODE_512x20 = LidarMode.MODE_512x20
MODE_UNSPEC = LidarMode.MODE_UNSPEC
property cols

Returns columns of lidar mode, e.g., 1024 for LidarMode 1024x10.

property frequency

Returns frequency of lidar mode, e.g. 10 for LidarMode 512x10.

from_string()

Create LidarMode from string.

class TimestampMode

Possible Timestamp modes of sensor. See sensor documentaiton for details.

TIME_FROM_INTERNAL_OSC = TimestampMode.TIME_FROM_INTERNAL_OSC
TIME_FROM_PTP_1588 = TimestampMode.TIME_FROM_PTP_1588
TIME_FROM_SYNC_PULSE_IN = TimestampMode.TIME_FROM_SYNC_PULSE_IN
TIME_FROM_UNSPEC = TimestampMode.TIME_FROM_UNSPEC
from_string()
class OperatingMode

Possible Operating modes of sensor. See sensor documentaiton for details.

OPERATING_NORMAL = OperatingMode.OPERATING_NORMAL
OPERATING_STANDBY = OperatingMode.OPERATING_STANDBY
from_string()
class MultipurposeIOMode

Mode of MULTIPURPOSE_IO pin. See sensor documentaiton for details.

MULTIPURPOSE_INPUT_NMEA_UART = MultipurposeIOMode.MULTIPURPOSE_INPUT_NMEA_UART
MULTIPURPOSE_OFF = MultipurposeIOMode.MULTIPURPOSE_OFF
MULTIPURPOSE_OUTPUT_FROM_ENCODER_ANGLE = MultipurposeIOMode.MULTIPURPOSE_OUTPUT_FROM_ENCODER_ANGLE
MULTIPURPOSE_OUTPUT_FROM_INTERNAL_OSC = MultipurposeIOMode.MULTIPURPOSE_OUTPUT_FROM_INTERNAL_OSC
MULTIPURPOSE_OUTPUT_FROM_PTP_1588 = MultipurposeIOMode.MULTIPURPOSE_OUTPUT_FROM_PTP_1588
MULTIPURPOSE_OUTPUT_FROM_SYNC_PULSE_IN = MultipurposeIOMode.MULTIPURPOSE_OUTPUT_FROM_SYNC_PULSE_IN
from_string()
class Polarity

Pulse Polarity. Applicable to several Polarity settings on sensor.

POLARITY_ACTIVE_HIGH = Polarity.POLARITY_ACTIVE_HIGH
POLARITY_ACTIVE_LOW = Polarity.POLARITY_ACTIVE_LOW
from_string()
class NMEABaudRate

Expected baud rate sensor attempts to decode for NMEA UART input $GPRMC messages.

BAUD_115200 = NMEABaudRate.BAUD_115200
BAUD_9600 = NMEABaudRate.BAUD_9600
from_string()

Data

BufferT

Types that support the buffer protocol.

alias of Union[bytes, bytearray, memoryview, numpy.ndarray]

Packet

Packets emitted by a sensor.

alias of Union[ImuPacket, LidarPacket]

class ImuPacket(data, info, timestamp=None)[source]

Read IMU Packet data from a bufer.

Parameters
  • data (Union[bytes, bytearray, memoryview, ndarray]) – Buffer containing the packet payload

  • pf – Format determining how to interpret the buffer

Raises

ValueError – If the buffer is smaller than the size specified by the packet format.

property sys_ts: int

System timestamp in nanoseconds.

Return type

int

property accel_ts: int

Accelerometer read time in nanoseconds.

Return type

int

property gyro_ts: int

Gyro read time in nanoseconds.

Return type

int

property accel: numpy.ndarray

Acceleration as a 3-D vector in G.

Return type

ndarray

property angular_vel: numpy.ndarray

Angular velocity as a 3-D vector in deg/second.

Return type

ndarray

class LidarPacket(data, info, timestamp=None)[source]

Read lidar packet data using numpy views.

This will always alias the supplied buffer-like object. Pass in a copy to avoid unintentional aliasing.

Parameters
  • data (Union[bytes, bytearray, memoryview, ndarray]) – Buffer containing the packet payload

  • pf – Format determining how to interpret the buffer

Raises

ValueError – If the buffer is smaller than the size specified by the packet format.

field(field)[source]

Create a view of the specified channel field.

Parameters

field (ChanField) – The channel field to view

Return type

ndarray

Returns

A view of the specified field as a numpy array

header(header)[source]

Create a view of the specified column header.

Parameters

header (ColHeader) – The column header to view

Return type

ndarray

Returns

A view of the specified header as a numpy array

class ChanField(ind, offset, dtype, mask)[source]

Channel fields available in lidar data.

RANGE = (0, 0, <class 'numpy.uint32'>, 1048575)
REFLECTIVITY = (3, 4, <class 'numpy.uint16'>, None)
SIGNAL = (1, 6, <class 'numpy.uint16'>, None)
NEAR_IR = (2, 8, <class 'numpy.uint16'>, None)
class ColHeader(offset, dtype)[source]

Column headers available in lidar data.

TIMESTAMP = (0, <class 'numpy.uint64'>)
FRAME_ID = (10, <class 'numpy.uint16'>)
MEASUREMENT_ID = (8, <class 'numpy.uint16'>)
ENCODER_COUNT = (12, <class 'numpy.uint32'>)
STATUS = (-4, <class 'numpy.uint32'>)
class LidarScan(h, w)[source]

Represents a single “scan” or “frame” of lidar data.

Internally, shares the same memory representation as the C++ LidarScan type and should allow passing data without unnecessary copying.

Parameters
  • h (int) – Vertical resolution of the scan

  • w (int) – Horizontal resolution of the scan

field(field)[source]

Return a view of the specified channel field.

Return type

ndarray

header(header)[source]

Return the specified column header as a numpy array.

Note that only TIMESTAMP, ENCODER_COUNT, and STATUS are currently supported.

Return type

ndarray

XYZLut(info)[source]

Return a function that can project scans into cartesian coordinates.

Internally, this will pre-compute a lookup table using the supplied intrinsic parameters. XYZ points are returned as a H x W x 3 array of doubles, where H is the number of beams and W is the horizontal resolution of the scan.

The coordinates are reported in meters in the sensor frame as defined in the sensor documentation.

Parameters

info (SensorInfo) – sensor metadata

Return type

Callable[[LidarScan], ndarray]

Returns

A function that computes a numpy array of a scan’s point coordinates

destagger(info, fields, inverse=False)[source]

Return a destaggered copy of the provided fields.

In the default staggered representation, each column corresponds to a single timestamp. A destaggered representation compensates for the azimuth offset of each beam, returning columns that correspond to a single azimuth angle.

Parameters
  • info (SensorInfo) – Sensor metadata associated with the provided data

  • fields (ndarray) – A numpy array of shape H X W or H X W X N

  • inverse – perform inverse “staggering” operation

Return type

ndarray

Returns

A destaggered numpy array of the same shape


Module ouster.pcap

Pcap tools to record/read/write Ouster sensor data.

info(pcap_path, n_packets=1024)[source]

Return some stats info from sampling data in a pcap file.

Parameters
  • pcap_path (str) – File path of recorded pcap

  • n_packets (int) – Number of ip packets / fragments to sample

Return type

PcapInfo

Returns

A dictionary mapping destination ports to sizes and packet counts.

class PcapInfo(ipv6_packets=0, ipv4_packets=0, packets_processed=0, packets_reassembled=0, non_udp_packets=0, guessed_lidar_port=None, guessed_imu_port=None, ports=<factory>)[source]

Information queried about a packet capture from an Ouster sensor.

Type of the output of pcap.info().

ipv6_packets

Number of ipv6 packets processed

Type

int

ipv4_packets

Number of ipv4 packets processed

Type

int

packets_processed

Total number of all packets processed

Type

int

packets_reassembled

Total number of IPv4 UDP packets reassembled

Type

int

non_udp_packets

Number of non UDP packets processed

Type

int

guessed_lidar_port

Best guess for port with Ouster lidar packets

Type

Optional[int]

guessed_imu_port

Best guess for port with Ouster imu packets

Type

Optional[int]

ports

A mapping from port numbers to the size (in bytes) and number of packets receved on that port.

Type

Dict[int, Tuple[int, int]]

record(packets, pcap_path, *, src_ip='127.0.0.1', dst_ip='127.0.0.1', lidar_port=7502, imu_port=7503)[source]

Record a sequence of sensor packets to a pcap file.

Parameters
  • packets (Iterable[Union[ImuPacket, LidarPacket]]) – A (finite!) sequence of packets

  • pcap_path (str) – Path of the output pcap file

  • src_ip (str) – Source IP to use for all packets

  • dst_ip (str) – Destination IP to use for all packets

  • lidar_port (int) – Src/dst port to use for lidar packets

  • imu_port (int) – Src/dst port to use for imu packets

Return type

int

Returns

Number of packets captured

class Pcap(pcap_path, info, *, rate=0.0, lidar_port=0, imu_port=0)[source]

Read a sensor packet stream out of a pcap file as an iterator.

Read a single-sensor data stream from a packet capture.

This assumes a pcap contains the packet stream of a single sensor and attempts to guess which destination ports were associated with lidar vs. imu data based on packet sizes, unless explicitly specified.

When a rate is specified, output packets in (a multiple of) real time using the pcap packet capture timestamps.

Parameters
  • info (SensorInfo) – Sensor metadata

  • pcap_path (str) – File path of recorded pcap

  • rate (float) – Output packets in real time, if non-zero

  • lidar_port (int) – Specify the destination port of lidar packets

  • imu_port (int) – Specify the destination port of imu packets

Returns

An iterator of lidar and IMU packets.

property metadata: ouster.client._client.SensorInfo

Metadata associated with the packet stream.

Return type

SensorInfo

reset()[source]

Restart playback from beginning. Thread-safe.

Return type

None

closed()[source]

Check if source is closed. Thread-safe.

Return type

bool

close()[source]

Release resources. Thread-safe.

Return type

None


Module ouster.sdk.examples

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

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_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 sensor

  • lidar_port (int) – UDP port to listen on for lidar data

  • range_min (int) – range minimum in meters

Return type

None

live_plot_signal(hostname, lidar_port=7502)[source]

Display signal from live sensor

Parameters
  • hostname (str) – hostname of the sensor

  • lidar_port (int) – UDP port to listen on for lidar data

Return type

None

plot_range_image(hostname, lidar_port=7502)[source]

Display range data taken live from sensor as an image

Parameters
  • hostname (str) – hostname of the sensor

  • lidar_port (int) – UDP port to listen on for lidar data

Return type

None

plot_all_channels(hostname, lidar_port=7502, n_scans=5)[source]

Display all channels of n consecutive lidar scans taken live from sensor

Parameters
  • hostname (str) – hostname of the sensor

  • lidar_port (int) – UDP port to listen on for lidar data

  • n_scans (int) – number of scans to show

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 sensor

  • lidar_port (int) – UDP port to listen on for lidar data

Return type

None

write_xyz_to_csv(hostname, lidar_port=7502, cloud_prefix='xyz', n_scans=5)[source]

Write xyz sample from live sensor to csv

Parameters
  • hostname (str) – hostname of the sensor

  • lidar_port (int) – UDP port to listen on for lidar data

  • cloud_prefix (str) – filename prefix for written csvs

  • n_scans (int) – number of scans to write

Return type

None

plot_imu_z_accel(hostname, lidar_port=7502, imu_port=7503, n_seconds=5)[source]

Plot the z acceleration from the IMU over time

Parameters
  • hostname (str) – hostname of the sensor

  • imu_port (int) – UDP port to listen on for imu data

  • n_seconds (int) – seconds of time to take a sample over

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 sensor

  • lidar_port (int) – UDP port to listen on for lidar data

  • imu_port (int) – UDP port to listen on for imu data

  • n_seconds (int) – max seconds of time to record. (Ctrl-Z correctly closes streams)

Return type

None


PCAP Examples ouster.sdk.examples.pcap

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_display_xyz_points(source, metadata, num=0)[source]

Plot point cloud using matplotlib.

Return type

None

pcap_2d_viewer(source, metadata, num=0)[source]

Visualize channel fields in 2D using opencv.

Return type

None

pcap_read_packets(source, metadata, num=0)[source]

Basic read packets example from pcap file.

Return type

None

pcap_show_one_scan(source, metadata, num=0, destagger=True)[source]

Plot all channels of one scan in 2D using matplotlib.

Return type

None

pcap_to_csv(source, metadata, num=0, csv_dir='.', csv_base='pcap_out', csv_ext='csv')[source]

Write scans from a pcap to csv files (one per lidar scan).

The number of saved lines per csv file is always H x W, which corresponds to a full 2D image representation of a lidar scan.

Each line in a csv file is:

TIMESTAMP, RANGE (mm), SIGNAL, NEAR_IR, REFLECTIVITY, X (mm), Y (mm), Z (mm)

If csv_ext ends in .gz, the file is automatically saved in compressed gzip format. numpy.loadtxt() can be used to read gzipped files transparently back to numpy.ndarray.

Parameters
  • pcap_path – path to the pcap file

  • metadata_path – path to the .json with metadata (aka SensorInfo)

  • num (int) – number of scans to save from pcap to csv files

  • csv_dir (str) – path to the directory where csv files will be saved

  • csv_base (str) – string to use as the base of the filename for pcap output

  • csv_ext (str) – file extension to use, “csv” by default

Return type

None

pcap_3d_one_scan(source, metadata, num=0)[source]

Render one scan from a pcap file in the Open3D viewer.

Parameters
  • pcap_path – path to the pcap file

  • metadata_path – path to the .json with metadata (aka SensorInfo)

  • num (int) – scan number in a given pcap file (satrs from 0)

Return type

None

main()[source]

Pcap examples runner.


Open3D Examples ouster.sdk.examples.open3d

Ouster Open3D visualizations examples.

view_from(vis, from_point, to_point=array([0, 0, 0]))[source]

Helper to setup view direction for Open3D Visualiser.

Parameters
  • from_point (ndarray) – camera location in 3d space as [x,y,z]

  • to_point (ndarray) – camera view direction in 3d space as [x,y,z]

create_canvas(w, h)[source]

Create canvas for 2D image.

Parameters
  • w (int) – width of the 2D image in screen coords (pixels)

  • h (int) – height of the 2D image in screen coords (pixels)

Return type

TriangleMesh

canvas_set_viewport(pic, camera_params)[source]

Set the position of the 2D image in space so it seems as static.

The method should be called on every animation update (animation callback) before rendering so the 2D mesh with texture always appear in the position that would seem “static” for the observer of the scene through the current camera parameters.

Parameters
  • pic (TriangleMesh) – canvas with 2D image, created with create_canvas()

  • camera_params (PinholeCameraParameters) – current open3d camera parameters

Return type

None

canvas_set_image_data(pic, img_data)[source]

Set 2D image data to 2D canvas.

Parameters
  • pic (TriangleMesh) – 2D canvas creates with create_canvas()

  • img_data (ndarray) – image data RGB (i.e. shape [h, w, 3])

Return type

None

viewer_3d(scans, paused=False)[source]

Render one scan in Open3D viewer from pcap file with 2d image.

Parameters
  • pcap_path – path to the pcap file

  • metadata_path – path to the .json with metadata (aka SensorInfo)

  • num – scan number in a given pcap file (satrs from 0)

Return type

None


Reference Code ouster.sdk.examples.reference

Reference implementations of common operations.

xyz_proj(metadata, scan)[source]

Computes a point cloud from a scan as numpy array.

This is a reference implementation that follows the calculations from Section 3.1.2 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 scan

  • scan (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 dsetaggering 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 metadata

  • field (ndarray) – Staggered data as a H x W numpy array

Return type

ndarray

Returns

Destaggered data as a H x W numpy array