Documentation ¶
Overview ¶
Package motor contains a gRPC bases motor client
Package motor contains a struct representing optional motor properties ¶
Package motor contains a gRPC based motor service server
Index ¶
- Constants
- Variables
- func CreateStatus(ctx context.Context, m Motor) (*pb.Status, error)
- func Named(name string) resource.Name
- func NamesFromRobot(r robot.Robot) []string
- func NewGoToUnsupportedError(motorName string) error
- func NewIsPoweredCollector(resource interface{}, params data.CollectorParams) (data.Collector, error)
- func NewPositionCollector(resource interface{}, params data.CollectorParams) (data.Collector, error)
- func NewPropertyUnsupportedError(prop Properties, motorName string) error
- func NewRPCServiceServer(coll resource.APIResourceCollection[Motor]) interface{}
- func NewResetZeroPositionUnsupportedError(motorName string) error
- func NewZeroRPMError() error
- func PropertiesToProtoResponse(props Properties) (*pb.GetPropertiesResponse, error)
- type Motor
- type Properties
Constants ¶
const SubtypeName = "motor"
SubtypeName is a constant that identifies the component resource API string "motor".
Variables ¶
var API = resource.APINamespaceRDK.WithComponentType(SubtypeName)
API is a variable that identifies the component resource API.
Functions ¶
func CreateStatus ¶
CreateStatus creates a status from the motor.
func NamesFromRobot ¶
NamesFromRobot is a helper for getting all motor names from the given Robot.
func NewGoToUnsupportedError ¶ added in v0.2.8
NewGoToUnsupportedError returns error when a motor is required to support GoTo feature.
func NewIsPoweredCollector ¶ added in v0.13.0
func NewIsPoweredCollector(resource interface{}, params data.CollectorParams) (data.Collector, error)
NewIsPoweredCollector returns a collector to register an is powered method. If one is already registered with the same MethodMetadata it will panic.
func NewPositionCollector ¶ added in v0.13.0
func NewPositionCollector(resource interface{}, params data.CollectorParams) (data.Collector, error)
NewPositionCollector returns a collector to register a position method. If one is already registered with the same MethodMetadata it will panic.
func NewPropertyUnsupportedError ¶ added in v0.6.0
func NewPropertyUnsupportedError(prop Properties, motorName string) error
NewPropertyUnsupportedError returns an error representing the need for a motor to support a particular property.
func NewRPCServiceServer ¶ added in v0.2.36
func NewRPCServiceServer(coll resource.APIResourceCollection[Motor]) interface{}
NewRPCServiceServer constructs a motor gRPC service server. It is intentionally untyped to prevent use outside of tests.
func NewResetZeroPositionUnsupportedError ¶
NewResetZeroPositionUnsupportedError returns a standard error for when a motor is required to support reseting the zero position.
func NewZeroRPMError ¶ added in v0.1.4
func NewZeroRPMError() error
NewZeroRPMError returns an error representing a request to move a motor at zero speed (i.e., moving the motor without moving the motor).
func PropertiesToProtoResponse ¶ added in v0.6.0
func PropertiesToProtoResponse( props Properties, ) (*pb.GetPropertiesResponse, error)
PropertiesToProtoResponse takes a Properties struct (indicating whether the property is supported) and converts it to a GetPropertiesResponse.
Types ¶
type Motor ¶
type Motor interface { resource.Resource resource.Actuator // SetPower sets the percentage of power the motor should employ between -1 and 1. // Negative power implies a backward directional rotational SetPower(ctx context.Context, powerPct float64, extra map[string]interface{}) error // GoFor instructs the motor to go in a specific direction for a specific amount of // revolutions at a given speed in revolutions per minute. Both the RPM and the revolutions // can be assigned negative values to move in a backwards direction. Note: if both are // negative the motor will spin in the forward direction. // If revolutions is 0, this will run the motor at rpm indefinitely // If revolutions != 0, this will block until the number of revolutions has been completed or another operation comes in. GoFor(ctx context.Context, rpm, revolutions float64, extra map[string]interface{}) error // GoTo instructs the motor to go to a specific position (provided in revolutions from home/zero), // at a specific speed. Regardless of the directionality of the RPM this function will move the motor // towards the specified target/position // This will block until the position has been reached GoTo(ctx context.Context, rpm, positionRevolutions float64, extra map[string]interface{}) error // Set the current position (+/- offset) to be the new zero (home) position. ResetZeroPosition(ctx context.Context, offset float64, extra map[string]interface{}) error // Position reports the position of the motor based on its encoder. If it's not supported, the returned // data is undefined. The unit returned is the number of revolutions which is intended to be fed // back into calls of GoFor. Position(ctx context.Context, extra map[string]interface{}) (float64, error) // Properties returns whether or not the motor supports certain optional properties. Properties(ctx context.Context, extra map[string]interface{}) (Properties, error) // IsPowered returns whether or not the motor is currently on, and the percent power (between 0 // and 1, if the motor is off then the percent power will be 0). IsPowered(ctx context.Context, extra map[string]interface{}) (bool, float64, error) }
A Motor represents a physical motor connected to a board.
func FromDependencies ¶
func FromDependencies(deps resource.Dependencies, name string) (Motor, error)
FromDependencies is a helper for getting the named motor from a collection of dependencies.
type Properties ¶ added in v0.6.0
type Properties struct {
PositionReporting bool
}
Properties is struct contaning the motor properties.
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 dimensionengineering contains implementations of the dimensionengineering motor controls
|
Package dimensionengineering contains implementations of the dimensionengineering motor controls |
Package dmc4000 implements stepper motors behind a Galil DMC4000 series motor controller
|
Package dmc4000 implements stepper motors behind a Galil DMC4000 series motor controller |
Package fake implements a fake motor.
|
Package fake implements a fake motor. |
Package gpio implements a GPIO based motor.
|
Package gpio implements a GPIO based motor. |
Package gpiostepper implements a GPIO based stepper motor
|
Package gpiostepper implements a GPIO based stepper motor |
Package ezopmp is a motor driver for the hydrogarden pump
|
Package ezopmp is a motor driver for the hydrogarden pump |
Package register registers all relevant motors
|
Package register registers all relevant motors |
Package roboclaw is the driver for the roboclaw motor drivers NOTE: This implementation is experimental and incomplete.
|
Package roboclaw is the driver for the roboclaw motor drivers NOTE: This implementation is experimental and incomplete. |
Package tmcstepper implements a TMC stepper motor.
|
Package tmcstepper implements a TMC stepper motor. |
Package uln28byj implements a GPIO based stepper motor (model: 28byj-48) with uln2003 controler.
|
Package uln28byj implements a GPIO based stepper motor (model: 28byj-48) with uln2003 controler. |