Documentation ¶
Overview ¶
Package encoder implements the encoder component
Package encoder contains an enum representing optional encoder features
Index ¶
- Constants
- Variables
- func FeatureMapToProtoResponse(featureMap map[Feature]bool) (*pb.GetPropertiesResponse, error)
- func Named(name string) resource.Name
- func NamesFromRobot(r robot.Robot) []string
- func NewEncodedMotorTypeUnsupportedError(props map[Feature]bool) error
- func NewEncoderTypeUnsupportedError(positionType PositionType) error
- func NewServer(s subtype.Service) pb.EncoderServiceServer
- func NewUnimplementedInterfaceError(actual interface{}) error
- func ProtoFeaturesToMap(resp *pb.GetPropertiesResponse) map[Feature]bool
- func ToProtoPositionType(positionType *PositionType) pb.PositionType
- func WrapWithReconfigurable(r interface{}, name resource.Name) (resource.Reconfigurable, error)
- type Encoder
- type Feature
- type PositionType
- type Ticks
Constants ¶
const SubtypeName = resource.SubtypeName("encoder")
SubtypeName is a constant that identifies the component resource subtype string "encoder".
Variables ¶
var Subtype = resource.NewSubtype( resource.ResourceNamespaceRDK, resource.ResourceTypeComponent, SubtypeName, )
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 NamesFromRobot ¶
NamesFromRobot is a helper for getting all encoder names from the given Robot.
func NewEncodedMotorTypeUnsupportedError ¶ added in v0.2.34
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
func NewServer(s subtype.Service) pb.EncoderServiceServer
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 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.
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.
Source Files ¶
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. |