Documentation
¶
Overview ¶
Package servo contains a gRPC bases servo client
Package servo contains a gRPC based servo service server ¶
Package servo supports “RC” or “hobby” servo motors. For more information, see the servo component docs.
Index ¶
Constants ¶
const SubtypeName = "servo"
SubtypeName is a constant that identifies the component resource API string "servo".
Variables ¶
var API = resource.APINamespaceRDK.WithComponentType(SubtypeName)
API is a variable that identifies the component resource API.
Functions ¶
func Named ¶
func Named(name string) resource.Name
Named is a helper for getting the named Servo's typed resource name.
func NamesFromRobot ¶
func NamesFromRobot(r robot.Robot) []string
NamesFromRobot is a helper for getting all servo names from the given Robot.
func NewRPCServiceServer ¶ added in v0.2.36
func NewRPCServiceServer(coll resource.APIResourceCollection[Servo]) interface{}
NewRPCServiceServer constructs a servo gRPC service server. It is intentionally untyped to prevent use outside of tests.
Types ¶
type Servo ¶
type Servo interface {
resource.Resource
resource.Actuator
// Move moves the servo to the given angle (0-180 degrees).
// This will block until done or a new operation cancels this one.
Move(ctx context.Context, angleDeg uint32, extra map[string]interface{}) error
// Position returns the current set angle (degrees) of the servo.
Position(ctx context.Context, extra map[string]interface{}) (uint32, error)
}
A Servo represents a physical servo connected to a board. For more information, see the servo component docs.
Move example:
// Move the servo from its origin to the desired angle of 30 degrees.
myServoComponent.Move(context.Background(), 30, nil)
For more information, see the Move method docs.
Position example:
// Get the current set angle of the servo.
pos1, err := myServoComponent.Position(context.Background(), nil)
// Move the servo from its origin to the desired angle of 20 degrees.
myServoComponent.Move(context.Background(), 20, nil)
// Get the current set angle of the servo.
pos2, err := myServoComponent.Position(context.Background(), nil)
logger.Info("Position 1: ", pos1)
logger.Info("Position 2: ", pos2)
For more information, see the Position method docs.
func FromRobot ¶
func FromRobot(r robot.Robot, name string) (Servo, error)
FromRobot is a helper for getting the named servo from the given Robot.
func NewClientFromConn ¶
func NewClientFromConn(
ctx context.Context,
conn rpc.ClientConn,
remoteName string,
name resource.Name,
logger logging.Logger,
) (Servo, error)
NewClientFromConn constructs a new Client from connection passed in.
Directories
¶
Path | Synopsis |
---|---|
Package fake implements a fake servo.
|
Package fake implements a fake servo. |
Package gpio implements a pin based servo
|
Package gpio implements a pin based servo |
Package register registers all relevant servos
|
Package register registers all relevant servos |