Documentation ¶
Overview ¶
Package encoder implements the encoder component
Index ¶
- Constants
- Variables
- func Named(name string) resource.Name
- func NamesFromRobot(r robot.Robot) []string
- func NewEncodedMotorPositionTypeUnsupportedError(props Properties) error
- func NewPositionTypeUnsupportedError(positionType PositionType) error
- func NewRPCServiceServer(coll resource.APIResourceCollection[Encoder]) interface{}
- func NewTicksCountCollector(resource interface{}, params data.CollectorParams) (data.Collector, error)
- func PropertiesToProtoResponse(props Properties) (*pb.GetPropertiesResponse, error)
- func ToProtoPositionType(positionType PositionType) pb.PositionType
- type Encoder
- type PositionType
- type Properties
Constants ¶
const SubtypeName = "encoder"
SubtypeName is a constant that identifies the component resource API string "encoder".
Variables ¶
var API = resource.APINamespaceRDK.WithComponentType(SubtypeName)
API is a variable that identifies the component resource API.
Functions ¶
func NamesFromRobot ¶
NamesFromRobot is a helper for getting all encoder names from the given Robot.
func NewEncodedMotorPositionTypeUnsupportedError ¶ added in v0.2.36
func NewEncodedMotorPositionTypeUnsupportedError(props Properties) 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 NewTicksCountCollector ¶ added in v0.13.0
func NewTicksCountCollector(resource interface{}, params data.CollectorParams) (data.Collector, error)
NewTicksCountCollector returns a collector to register a ticks count method. If one is already registered with the same MethodMetadata it will panic.
func PropertiesToProtoResponse ¶ added in v0.6.0
func PropertiesToProtoResponse( props Properties, ) (*pb.GetPropertiesResponse, error)
PropertiesToProtoResponse takes a properties struct and converts it to a GetPropertiesResponse.
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 // Position returns the current position in terms of ticks or degrees, and whether it is a relative or absolute position. Position(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 // Properties returns a list of all the position types that are supported by a given encoder Properties(ctx context.Context, extra map[string]interface{}) (Properties, 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.
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 Properties ¶ added in v0.6.0
Properties holds the properties of the encoder.
func ProtoFeaturesToProperties ¶ added in v0.6.0
func ProtoFeaturesToProperties(resp *pb.GetPropertiesResponse) Properties
ProtoFeaturesToProperties takes a GetPropertiesResponse and returns an equivalent Properties struct.
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. |