vlp16

package module
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2022 License: MIT Imports: 8 Imported by: 1

README

VLP-16 Go

PkgGoDev GoReportCard Codecov

Go SDK for reading and parsing data from Velodyne VLP-16 (a.k.a. Puck) sensors.

Documentation

See the VLP-16 product page and the VLP-16 packet structure specification.

Installing

$ go get -u go.einride.tech/vlp16

Examples

Listen for VLP-16 packets
package main

import (
	"context"
	"fmt"
	"os"

	"go.einride.tech/vlp16"
)

func main() {
	if len(os.Args) < 2 {
		fmt.Println("usage: vlp16-listen <port>")
		os.Exit(1)
	}
	// Bind UDP packet listener.
	listener, err := vlp16.ListenUDP(context.Background(), fmt.Sprintf("0.0.0.0:%s", os.Args[1]))
	if err != nil {
		panic(err)
	}
	// Listen for and print packets.
	for {
		if err := listener.ReadPacket(); err != nil {
			panic(err)
		}
		fmt.Println(listener.SourceIP(), listener.Packet().ProductID)
		fmt.Println(listener.RawPacket())
		fmt.Println()
	}
}

Documentation

Overview

Package vlp16 provides primitives for reading and parsing data from Velodyne VLP-16 LiDAR sensors.

Index

Constants

View Source
const (
	// BlocksPerPacket is the number of blocks in a packet.
	BlocksPerPacket = 12
	// ChannelsPerBlock is the number of channels in a block.
	ChannelsPerBlock = 32
)
View Source
const (
	// ColumnsPerPacket is the number of columns in point cloud matrix.
	ColumnsPerPacket = BlocksPerPacket * 2
	// RowsPerColumnSingleReturn is the number of rows in point cloud in single return mode.
	RowsPerColumnSingleReturn = 16
	// FullFiringTime is the total time for laser firings plus recharge (55.296 µs).
	FullFiringTime = 55296 * time.Nanosecond
	// SingleFiringTime is the time for one laser firing (2.304 µs).
	SingleFiringTime = 2304 * time.Nanosecond
	// RechargeTime is the recharge time between laser firings (18.432 µs).
	RechargeTime = 18432 * time.Nanosecond
	// LowestElevation is the elevation angle of first row of measurements.
	LowestElevationDegrees = -15
	// DeltaElevation is the angle difference between two rows.
	DeltaElevationDegrees = 2
)
View Source
const SizeOfPacket = 1206

SizeOfPacket is the size of a single VLP-16 packet in bytes.

Variables

This section is empty.

Functions

func ScanPackets

func ScanPackets(data []byte, atEOF bool) (int, []byte, error)

ScanPackets is a bufio.Scanner SplitFunc that splits a stream into VLP-16 packets.

Types

type Block

type Block struct {
	Flag     uint16
	Azimuth  uint16
	Channels [ChannelsPerBlock]Channel
}

Block is a VLP-16 block.

type Channel

type Channel struct {
	Distance     uint16
	Reflectivity uint8
}

Channel is a VLP-16 channel.

type ListenOption

type ListenOption func(*listenOptions)

ListenOption configures a VLP-16 listener.

func WithReadBatchSize

func WithReadBatchSize(n int) ListenOption

WithReadBatchSize configures the max number of messages to read from the kernel in a single batch.

func WithReadBufferSize

func WithReadBufferSize(n int) ListenOption

WithReadBufferSize configures the kernel read buffer size (in bytes).

type Packet

type Packet struct {
	Blocks     [BlocksPerPacket]Block
	Timestamp  uint32
	ReturnMode ReturnMode
	ProductID  ProductID
}

Packet is a VLP-16 packet.

func (*Packet) UnmarshalRawPacket

func (p *Packet) UnmarshalRawPacket(raw *RawPacket)

func (*Packet) Validate

func (p *Packet) Validate() error

Validate the packet.

type PacketListener

type PacketListener struct {
	// contains filtered or unexported fields
}

PacketListener listens for VLP-16 packets.

func ListenUDP

func ListenUDP(ctx context.Context, addr string, listenOpts ...ListenOption) (_ *PacketListener, err error)

ListenUDP listens for VLP-16 UDP packets on the specified address.

func (*PacketListener) Close

func (c *PacketListener) Close() error

Close the client's underlying UDP connection.

func (*PacketListener) Packet

func (c *PacketListener) Packet() *Packet

Packet returns the last received VLP-16 packet.

func (*PacketListener) RawPacket

func (c *PacketListener) RawPacket() *RawPacket

RawPacket returns the raw, unprocessed last received VLP-16 packet.

func (*PacketListener) ReadPacket

func (c *PacketListener) ReadPacket() error

ReadPacket reads a VLP-16 packet.

func (*PacketListener) SetReadDeadline

func (c *PacketListener) SetReadDeadline(deadline time.Time) error

SetReadDeadline sets the read deadline associated with the listener's underlying UDP connection.

func (*PacketListener) SourceIP

func (c *PacketListener) SourceIP() net.IP

SourceIP returns the source IP of the last received VLP-16 packet.

type ProductID

type ProductID uint8

ProductID represents a Velodyne product ID.

const (
	ProductIDHDL32E    ProductID = 0x21
	ProductIDVLP16     ProductID = 0x22
	ProductIDPuckLITE  ProductID = 0x22
	ProductIDPuckHiRes ProductID = 0x24
	ProductIDVLP32C    ProductID = 0x28
	ProductIDVelarray  ProductID = 0x31
	ProductIDVLS128    ProductID = 0x63
)

func (ProductID) String

func (i ProductID) String() string

type RawPacket

type RawPacket [SizeOfPacket]byte

RawPacket is a raw, binary VLP-16 packet.

func (*RawPacket) String

func (r *RawPacket) String() string

String implements Stringer for raw packets.

type ReturnMode

type ReturnMode uint8

ReturnMode represents a VLP-16 return mode.

const (
	ReturnModeStrongest  ReturnMode = 0x37
	ReturnModeLastReturn ReturnMode = 0x38
	ReturnModeDualReturn ReturnMode = 0x39
)

func (ReturnMode) String

func (i ReturnMode) String() string

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL