Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCS-2231-Add-Gripper-Input-Controller-snippets #3919

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions components/gripper/gripper.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ func Named(name string) resource.Name {
}

// A Gripper represents a physical robotic gripper.
//
// Open example:
//
// // Open the gripper.
// err := myGripper.Open(context.Background(), nil)
skyleilani marked this conversation as resolved.
Show resolved Hide resolved
//
// Grab example:
//
// // Grab with the gripper.
// grabbed, err := myGripper.Grab(context.Background(), nil)
type Gripper interface {
resource.Resource
resource.Shaped
Expand Down
29 changes: 29 additions & 0 deletions components/input/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,35 @@ func Named(name string) resource.Name {

// Controller is a logical "container" more than an actual device
// Could be a single gamepad, or a collection of digitalInterrupts and analogReaders, a keyboard, etc.
//
// Controls example:
//
// // Get the list of Controls provided by the controller.
// controls, err := myController.Controls(context.Background(), nil)
//
// Events example:
//
// // Get the most recent Event for each Control.
// recent_events, err := myController.Events(context.Background(), nil)
//
// RegisterControlCallback example:
//
// // Define a function to handle pressing the Start Menu button, "ButtonStart", on your controller and logging the start time
// printStartTime := func(ctx context.Context, event input.Event) {
// logger.Info("Start Menu Button was pressed at this time: %v", event.Time)
// }
//
// // Define the EventType "ButtonPress" to serve as the trigger for printStartTime.
// triggers := []input.EventType{input.ButtonPress}
//
// // Get the controller's Controls.
// controls, err := controller.Controls(ctx, nil)
//
// // If the "ButtonStart" Control is found, trigger printStartTime when "ButtonStart" the event "ButtonPress" occurs.
// if !slices.Contains(controls, input.ButtonStart) {
// return errors.New("button `ButtonStart` not found; controller may be disconnected")
// }
// Mycontroller.RegisterControlCallback(context.Background(), input.ButtonStart, triggers, printStartTime, nil)
type Controller interface {
resource.Resource

Expand Down
Loading