encoder

package
v0.2.35 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package encoder implements the encoder component

Package encoder contains an enum representing optional encoder features

Index

Constants

View Source
const SubtypeName = resource.SubtypeName("encoder")

SubtypeName is a constant that identifies the component resource subtype string "encoder".

Variables

Subtype is a constant that identifies the component resource subtype.

Functions

func FeatureMapToProtoResponse added in v0.2.34

func FeatureMapToProtoResponse(
	featureMap map[Feature]bool,
) (*pb.GetPropertiesResponse, error)

FeatureMapToProtoResponse takes a map of features to booleans (indicating whether the feature is supported) and converts it to a GetPropertiesResponse.

func Named

func Named(name string) resource.Name

Named is a helper for getting the named Encoder's typed resource name.

func NamesFromRobot

func NamesFromRobot(r robot.Robot) []string

NamesFromRobot is a helper for getting all encoder names from the given Robot.

func NewEncodedMotorTypeUnsupportedError added in v0.2.34

func NewEncodedMotorTypeUnsupportedError(props map[Feature]bool) error

NewEncodedMotorTypeUnsupportedError returns a standard error for when an encoded motor tries to use an encoder that doesn't support Ticks.

func NewEncoderTypeUnsupportedError added in v0.2.34

func NewEncoderTypeUnsupportedError(positionType PositionType) error

NewEncoderTypeUnsupportedError returns a standard error for when an encoder does not support the given PositionType.

func NewServer added in v0.2.34

NewServer constructs an Encoder gRPC service subtypeServer.

func NewUnimplementedInterfaceError

func NewUnimplementedInterfaceError(actual interface{}) error

NewUnimplementedInterfaceError is used when there is a failed interface check.

func ProtoFeaturesToMap added in v0.2.34

func ProtoFeaturesToMap(resp *pb.GetPropertiesResponse) map[Feature]bool

ProtoFeaturesToMap takes a GetPropertiesResponse and returns an equivalent Feature-to-boolean map.

func ToProtoPositionType added in v0.2.34

func ToProtoPositionType(positionType *PositionType) pb.PositionType

ToProtoPositionType takes a map of PositionType-to-int (indicating the PositionType) and converts it to a GetPositionResponse.

func WrapWithReconfigurable

func WrapWithReconfigurable(r interface{}, name resource.Name) (resource.Reconfigurable, error)

WrapWithReconfigurable converts a regular Encoder implementation to a reconfigurableEncoder. If encoder is already a reconfigurableEncoder, then nothing is done.

Types

type Encoder

type Encoder interface {
	// GetPosition returns the current position in terms of ticks or degrees, and whether it is a relative or absolute position.
	GetPosition(ctx context.Context, positionType *PositionType, extra map[string]interface{}) (float64, PositionType, error)

	// ResetPosition sets the current position of the motor to be its new zero position.
	ResetPosition(ctx context.Context, extra map[string]interface{}) error

	// GetProperties returns a list of all the position types that are supported by a given encoder
	GetProperties(ctx context.Context, extra map[string]interface{}) (map[Feature]bool, error)

	generic.Generic
}

A Encoder turns a position into a signal.

func FromDependencies

func FromDependencies(deps registry.Dependencies, name string) (Encoder, error)

FromDependencies is a helper for getting the named encoder from a collection of dependencies.

func FromRobot

func FromRobot(r robot.Robot, name string) (Encoder, error)

FromRobot is a helper for getting the named encoder from the given Robot.

func NewClientFromConn added in v0.2.34

func NewClientFromConn(ctx context.Context, conn rpc.ClientConn, name string, logger golog.Logger) Encoder

NewClientFromConn constructs a new Client from connection passed in.

type Feature added in v0.2.34

type Feature string

Feature is an enum representing an optional encoder feature.

const (
	TicksCountSupported   Feature = "Ticks"
	AngleDegreesSupported Feature = "Degrees"
)

TicksCountSupported and AngleDegreesSupported represesnts the feature of an encoder being able to report ticks and/or degrees, respectively.

type PositionType added in v0.2.34

type PositionType int32

PositionType is an enum representing the encoders position type.

const (
	// PositionTypeUNSPECIFIED is the return type for
	// when the user has not specified a PositionType.
	PositionTypeUNSPECIFIED PositionType = 0
	// PositionTypeTICKS is the return type for relative encoders
	// that report how far they've gone from a start position.
	PositionTypeTICKS PositionType = 1
	// PositionTypeDEGREES is the return type for absolute encoders
	// that report their position in degrees along the radial axis.
	PositionTypeDEGREES PositionType = 2
)

func ToEncoderPositionType added in v0.2.34

func ToEncoderPositionType(positionType *pb.PositionType) PositionType

ToEncoderPositionType takes a GetPositionResponse and returns an equivalent PositionType-to-int map.

func (PositionType) Enum added in v0.2.34

func (x PositionType) Enum() *PositionType

Enum reveals the value of PositionType.

type Ticks added in v0.1.2

type Ticks struct {
	Ticks int64
}

Ticks wraps the returned ticks value.

Directories

Path Synopsis
Package ams implements the AMS_AS5048 encoder
Package ams implements the AMS_AS5048 encoder
Package fake implements a fake encoder.
Package fake implements a fake encoder.
Package incremental implements an incremental encoder
Package incremental implements an incremental encoder
Package register registers all relevant MovementSensors
Package register registers all relevant MovementSensors
Package single implements a single-wire odometer, such as LM393, as an encoder.
Package single implements a single-wire odometer, such as LM393, as an encoder.

Jump to

Keyboard shortcuts

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