Skip to content

Commit

Permalink
Add method links to examples arm through camera (#4696)
Browse files Browse the repository at this point in the history
  • Loading branch information
sguequierre authored Jan 13, 2025
1 parent b559adf commit 22d97c6
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 2 deletions.
15 changes: 15 additions & 0 deletions components/arm/arm.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func Named(name string) resource.Name {
// // Get the end position of the arm as a Pose.
// pos, err := myArm.EndPosition(context.Background(), nil)
//
// For more information, see the [EndPosition method docs].
//
// MoveToPosition example:
//
// myArm, err := arm.FromRobot(machine, "my_arm")
Expand All @@ -71,6 +73,8 @@ func Named(name string) resource.Name {
// // Move your arm to the Pose.
// err = myArm.MoveToPosition(context.Background(), examplePose, nil)
//
// For more information, see the [MoveToPosition method docs].
//
// MoveToJointPositions example:
//
// myArm, err := arm.FromRobot(machine, "my_arm")
Expand All @@ -81,6 +85,8 @@ func Named(name string) resource.Name {
// // Move each joint of the arm to the positions specified in the above slice
// err = myArm.MoveToJointPositions(context.Background(), inputs, nil)
//
// For more information, see the [MoveToJointPositions method docs].
//
// MoveThroughJointPositions example:
//
// myArm, err := arm.FromRobot(machine, "my_arm")
Expand All @@ -94,14 +100,23 @@ func Named(name string) resource.Name {
// // Move each joint of the arm through the positions in the slice defined above
// err = myArm.MoveThroughJointPositions(context.Background(), inputs, nil, nil)
//
// For more information, see the [MoveThroughJointPositions method docs].
//
// JointPositions example:
//
// myArm , err := arm.FromRobot(machine, "my_arm")
//
// // Get the current position of each joint on the arm as JointPositions.
// pos, err := myArm.JointPositions(context.Background(), nil)
//
// For more information, see the [JointPositions method docs].
//
// [arm component docs]: https://docs.viam.com/components/arm/
// [EndPosition method docs]: https://docs.viam.com/dev/reference/apis/components/arm/#getendposition
// [MoveToPosition method docs]: https://docs.viam.com/dev/reference/apis/components/arm/#movetoposition
// [MoveToJointPositions method docs]: https://docs.viam.com/dev/reference/apis/components/arm/#movetojointpositions
// [MoveThroughJointPositions method docs]: https://docs.viam.com/dev/reference/apis/components/arm/#movethroughjointpositions
// [JointPositions method docs]: https://docs.viam.com/dev/reference/apis/components/arm/#getjointpositions
type Arm interface {
resource.Resource
referenceframe.ModelFramer
Expand Down
15 changes: 15 additions & 0 deletions components/base/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,17 @@ func Named(name string) resource.Name {
// // Move the base backward 40 mm at a velocity of -90 mm/s.
// myBase.MoveStraight(context.Background(), 40, -90, nil)
//
// For more information, see the [MoveStraight method docs].
//
// Spin example:
//
// myBase, err := base.FromRobot(machine, "my_base")
//
// // Spin the base 10 degrees at an angular velocity of 15 deg/sec.
// myBase.Spin(context.Background(), 10, 15, nil)
//
// For more information, see the [Spin method docs].
//
// SetPower example:
//
// myBase, err := base.FromRobot(machine, "my_base")
Expand All @@ -73,13 +77,17 @@ func Named(name string) resource.Name {
// logger.Info("spin right")
// err = myBase.SetPower(context.Background(), r3.Vector{}, r3.Vector{Z: -.75}, nil)
//
// For more information, see the [SetPower method docs].
//
// SetVelocity example:
//
// myBase, err := base.FromRobot(machine, "my_base")
//
// // Set the linear velocity to 50 mm/sec and the angular velocity to 15 deg/sec.
// myBase.SetVelocity(context.Background(), r3.Vector{Y: 50}, r3.Vector{Z: 15}, nil)
//
// For more information, see the [SetVelocity method docs].
//
// Properties example:
//
// myBase, err := base.FromRobot(machine, "my_base")
Expand All @@ -96,7 +104,14 @@ func Named(name string) resource.Name {
// // Get the wheel circumference
// myBaseWheelCircumference := properties.WheelCircumferenceMeters
//
// For more information, see the [Properties method docs].
//
// [base component docs]: https://docs.viam.com/components/base/
// [Properties method docs]: https://docs.viam.com/dev/reference/apis/components/base/#getproperties
// [SetVelocity method docs]: https://docs.viam.com/dev/reference/apis/components/base/#setvelocity
// [SetPower method docs]: https://docs.viam.com/dev/reference/apis/components/base/#setpower
// [Spin method docs]: https://docs.viam.com/dev/reference/apis/components/base/#spin
// [MoveStraight method docs]: https://docs.viam.com/dev/reference/apis/components/base/#movestraight
type Base interface {
resource.Resource
resource.Actuator
Expand Down
24 changes: 23 additions & 1 deletion components/board/board.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,35 @@ func Named(name string) resource.Name {
// // Get the Analog pin "my_example_analog".
// analog, err := myBoard.AnalogByName("my_example_analog")
//
// For more information, see the [AnalogByName method docs].
//
// DigitalInterruptByName example:
//
// myBoard, err := board.FromRobot(robot, "my_board")
//
// // Get the DigitalInterrupt "my_example_digital_interrupt".
// interrupt, err := myBoard.DigitalInterruptByName("my_example_digital_interrupt")
//
// For more information, see the [DigitalInterruptByName method docs].
//
// GPIOPinByName example:
//
// myBoard, err := board.FromRobot(robot, "my_board")
//
// // Get the GPIOPin with pin number 15.
// pin, err := myBoard.GPIOPinByName("15")
//
// For more information, see the [GPIOPinByName method docs].
//
// SetPowerMode example:
//
// myBoard, err := board.FromRobot(robot, "my_board")
//
// Set the power mode of the board to OFFLINE_DEEP.
// myBoard.SetPowerMode(context.Background(), boardpb.PowerMode_POWER_MODE_OFFLINE_DEEP, nil)
//
// For more information, see the [SetPowerMode method docs].
//
// StreamTicks example:
//
// myBoard, err := board.FromRobot(robot, "my_board")
Expand All @@ -97,7 +105,14 @@ func Named(name string) resource.Name {
//
// err = myBoard.StreamTicks(context.Background(), interrupts, ticksChan, nil)
//
// [board component docs]: https://docs.viam.com/components/board/
// For more information, see the [StreamTicks method docs].
//
// [board component docs]: https://docs.viam.com/operate/reference/components/board/
// [AnalogByName method docs]: https://docs.viam.com/dev/reference/apis/components/board/#analogbyname
// [DigitalInterruptByName method docs]: https://docs.viam.com/dev/reference/apis/components/board/#digitalinterruptbyname
// [GPIOPinByName method docs]: https://docs.viam.com/dev/reference/apis/components/board/#gpiopinbyname
// [SetPowerMode method docs]: https://docs.viam.com/dev/reference/apis/components/board/#setpowermode
// [StreamTicks method docs]: https://docs.viam.com/dev/reference/apis/components/board/#streamticks
type Board interface {
resource.Resource

Expand Down Expand Up @@ -134,6 +149,8 @@ type Board interface {
// readingValue := reading.Value
// stepSize := reading.StepSize
//
// For more information, see the [Read method docs].
//
// Write example:
//
// myBoard, err := board.FromRobot(robot, "my_board")
Expand All @@ -143,6 +160,11 @@ type Board interface {
//
// // Set the pin to value 48.
// err = analog.Write(context.Background(), 48, nil)
//
// For more information, see the [Write method docs].
//
// [Read method docs]: https://docs.viam.com/dev/reference/apis/components/board/#readanalogreader
// [Write method docs]: https://docs.viam.com/dev/reference/apis/components/board/#writeanalog
type Analog interface {
// Read reads off the current value.
Read(ctx context.Context, extra map[string]interface{}) (AnalogValue, error)
Expand Down
4 changes: 4 additions & 0 deletions components/board/digital_interrupts.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ type Tick struct {
//
// // Get the amount of times this DigitalInterrupt has ticked.
// count, err := interrupt.Value(context.Background(), nil)
//
// For more information, see the [Value method docs].
//
// [Value method docs]: https://docs.viam.com/dev/reference/apis/components/board/#getdigitalinterruptvalue
type DigitalInterrupt interface {
// Name returns the name of the interrupt.
Name() string
Expand Down
19 changes: 19 additions & 0 deletions components/board/gpio_pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
// // Set the pin to high.
// err = pin.Set(context.Background(), true, nil)
//
// For more information, see the [Set method docs].
//
// Get example:
//
// myBoard, err := board.FromRobot(robot, "my_board")
Expand All @@ -29,6 +31,8 @@ import (
// // Get if it is true or false that the state of the pin is high.
// high, err := pin.Get(context.Background(), nil)
//
// For more information, see the [Get method docs].
//
// PWM example:
//
// myBoard, err := board.FromRobot(robot, "my_board")
Expand All @@ -39,6 +43,8 @@ import (
// // Returns the duty cycle.
// duty_cycle, err := pin.PWM(context.Background(), nil)
//
// For more information, see the [PWM method docs].
//
// SetPWM example:
//
// myBoard, err := board.FromRobot(robot, "my_board")
Expand All @@ -49,6 +55,8 @@ import (
// // Set the duty cycle to .6, meaning that this pin will be in the high state for 60% of the duration of the PWM interval period.
// err = pin.SetPWM(context.Background(), .6, nil)
//
// For more information, see the [SetPWM method docs].
//
// PWMFreq example:
//
// myBoard, err := board.FromRobot(robot, "my_board")
Expand All @@ -59,6 +67,8 @@ import (
// // Get the PWM frequency of this pin.
// freqHz, err := pin.PWMFreq(context.Background(), nil)
//
// For more information, see the [PWMFreq method docs].
//
// SetPWMFreq example:
//
// myBoard, err := board.FromRobot(robot, "my_board")
Expand All @@ -68,6 +78,15 @@ import (
//
// // Set the PWM frequency of this pin to 1600 Hz.
// err = pin.SetPWMFreq(context.Background(), 1600, nil)
//
// For more information, see the [SetPWMFreq method docs].
//
// [Set method docs]: https://docs.viam.com/dev/reference/apis/components/board/#setgpio
// [Get method docs]: https://docs.viam.com/dev/reference/apis/components/board/#getgpio
// [PWM method docs]: https://docs.viam.com/dev/reference/apis/components/board/#getpwm
// [SetPWM method docs]: https://docs.viam.com/dev/reference/apis/components/board/#setpwm
// [PWMFreq method docs]: https://docs.viam.com/dev/reference/apis/components/board/#pwmfrequency
// [SetPWMFreq method docs]: https://docs.viam.com/dev/reference/apis/components/board/#setpwmfrequency
type GPIOPin interface {
// Set sets the pin to either low or high.
Set(ctx context.Context, high bool, extra map[string]interface{}) error
Expand Down
14 changes: 13 additions & 1 deletion components/camera/camera.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,16 @@ type Camera interface {
// myCamera, err := camera.FromRobot(machine, "my_camera")
// img, err = camera.DecodeImageFromCamera(context.Background(), utils.MimeTypeJPEG, nil, myCamera)
//
// For more information, see the [Image method docs].
//
// Images example:
//
// myCamera, err := camera.FromRobot(machine, "my_camera")
//
// images, metadata, err := myCamera.Images(context.Background())
//
// For more information, see the [Images method docs].
//
// Stream example:
//
// myCamera, err := camera.FromRobot(machine, "my_camera")
Expand All @@ -121,13 +125,21 @@ type Camera interface {
// // gets the next point cloud from a camera
// pointCloud, err := myCamera.NextPointCloud(context.Background())
//
// For more information, see the [NextPointCloud method docs].
//
// Close example:
//
// myCamera, err := camera.FromRobot(machine, "my_camera")
//
// err = myCamera.Close(context.Background())
//
// [camera component docs]: https://docs.viam.com/components/camera/
// For more information, see the [Close method docs].
//
// [camera component docs]: https://docs.viam.com/dev/reference/apis/components/camera/
// [Image method docs]: https://docs.viam.com/dev/reference/apis/components/camera/#getimage
// [Images method docs]: https://docs.viam.com/dev/reference/apis/components/camera/#getimages
// [NextPointCloud method docs]: https://docs.viam.com/dev/reference/apis/components/camera/#getpointcloud
// [Close method docs]: https://docs.viam.com/dev/reference/apis/components/camera/#close
type VideoSource interface {
// Image returns a byte slice representing an image that tries to adhere to the MIME type hint.
// Image also may return metadata about the frame.
Expand Down

0 comments on commit 22d97c6

Please sign in to comment.