encoder

package
v0.2.37 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: AGPL-3.0 Imports: 12 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 = "encoder"

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

Variables

View Source
var API = resource.APINamespaceRDK.WithComponentType(SubtypeName)

API is a variable that identifies the component resource API.

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 NewEncodedMotorPositionTypeUnsupportedError added in v0.2.36

func NewEncodedMotorPositionTypeUnsupportedError(props map[Feature]bool) error

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

func NewPositionTypeUnsupportedError added in v0.2.36

func NewPositionTypeUnsupportedError(positionType PositionType) error

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

func NewRPCServiceServer added in v0.2.36

func NewRPCServiceServer(coll resource.APIResourceCollection[Encoder]) interface{}

NewRPCServiceServer constructs an Encoder gRPC service serviceServer.

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.

Types

type Encoder

type Encoder interface {
	resource.Resource

	// 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)
}

A Encoder turns a position into a signal.

func FromDependencies

func FromDependencies(deps resource.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,
	remoteName string,
	name resource.Name,
	logger golog.Logger,
) (Encoder, error)

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 byte

PositionType is an enum representing the encoder's position.

const (
	PositionTypeUnspecified PositionType = iota
	// PositionTypeTicks is for relative encoders
	// that report how far they've gone from a start position.
	PositionTypeTicks
	// PositionTypeDegrees is for absolute encoders
	// that report their position in degrees along the radial axis.
	PositionTypeDegrees
)

Known encoder position types.

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) String added in v0.2.36

func (t PositionType) String() string

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