Skip to content

Commit 7b4d08d

Browse files
committed
standardize format
1 parent f8cd8c9 commit 7b4d08d

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

components/gripper/gripper.go

+10
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ func Named(name string) resource.Name {
3434
}
3535

3636
// A Gripper represents a physical robotic gripper.
37+
//
38+
// Open example:
39+
//
40+
// // Open the gripper.
41+
// err = myGripper.Open(context.Background(), nil)
42+
//
43+
// Grab example:
44+
//
45+
// // Grab with the gripper.
46+
// grabbed, err := myGripper.Grab(context.Background(), nil)
3747
type Gripper interface {
3848
resource.Resource
3949
resource.Shaped

components/input/input.go

+55
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,61 @@ func Named(name string) resource.Name {
3535

3636
// Controller is a logical "container" more than an actual device
3737
// Could be a single gamepad, or a collection of digitalInterrupts and analogReaders, a keyboard, etc.
38+
//
39+
// Controls example:
40+
//
41+
// // Get the list of Controls provided by the controller.
42+
// controls, err := myController.Controls(context.Background(), nil)
43+
//
44+
// Events example:
45+
//
46+
// // Get the most recent Event for each Control.
47+
// recent_events, err := myController.Events(context.Background(), nil)
48+
//
49+
// RegisterControlCallback example:
50+
//
51+
// // Define a function that handles the controller.
52+
// func handleController(ctx context.Context, logger logging.Logger, controller input.Controller) error {
53+
// // Define a function to handle pressing the Start Menu button, "ButtonStart", on your controller and logging the start time
54+
// printStartTime := func(ctx context.Context, event input.Event) {
55+
// logger.Info("Start Menu Button was pressed at this time: %v", event.Time)
56+
// }
57+
//
58+
// // Define the EventType "ButtonPress" to serve as the trigger for printStartTime.
59+
// triggers := []input.EventType{input.ButtonPress}
60+
//
61+
// // Get the controller's Controls.
62+
// controls, err := controller.Controls(ctx, nil)
63+
//
64+
// // If the "ButtonStart" Control is found, register the function printStartTime to fire when "ButtonStart" has the event "ButtonPress" occur.
65+
// if !slices.Contains(controls, input.ButtonStart) {
66+
// return errors.New("button `ButtonStart` not found; controller may be disconnected")
67+
// }
68+
// return controller.RegisterControlCallback(context.Background(), Control: input.ButtonStart, triggers, printStartTime, nil)
69+
// }
70+
//
71+
// func main() {
72+
// utils.ContextualMain(mainWithArgs, logging.NewLogger("client"))
73+
// }
74+
//
75+
// func mainWithArgs(ctx context.Context, args []string, logger logging.Logger) error {
76+
// // < Insert code sample from your machine's CONNECT tab >
77+
//
78+
// // Get the controller from the machine.
79+
// myController, err := input.FromRobot(machine, "my_controller")
80+
// if err != nil {
81+
// return err
82+
// }
83+
//
84+
// // Run the handleController function.
85+
// if err = handleController(myController) {
86+
// return err
87+
// }
88+
// // < Insert any other code for main function >
89+
//
90+
// <-ctx.Done()
91+
// return nil
92+
// }
3893
type Controller interface {
3994
resource.Resource
4095

0 commit comments

Comments
 (0)