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

[RSDK-7154] update analog reader interface to include range/accuracy #619

Merged
merged 6 commits into from
May 16, 2024

Conversation

penguinland
Copy link
Member

Surprisingly, the compiled protobufs in this repo already have the new data, and all I needed to do was start using it!

When reading an analog pin on a board, you now get the raw value, the minimum/maximum possible value the reader can output, and the minimum change the reader can notice.

@penguinland penguinland requested a review from a team as a code owner May 16, 2024 18:50
Copy link
Contributor

Warning your change may break code samples. If your change modifies any of the following functions please contact @viamrobotics/fleet-management. Thanks!

component function
base is_moving
board gpio_pin_by_name
camera get_image
encoder get_position
motor is_moving
sensor get_readings
servo get_position
arm get_end_position
gantry get_lengths
gripper is_moving
movement_sensor get_linear_acceleration
input_controller get_controls
audio get_properties
pose_tracker get_poses
power_sensor get_power
motion get_pose
vision get_classifications_from_camera

src/viam/components/board/board.py Outdated Show resolved Hide resolved
src/viam/components/board/board.py Outdated Show resolved Hide resolved
src/viam/components/board/client.py Outdated Show resolved Hide resolved
Copy link
Member

@njooma njooma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment, open for discussion

@@ -38,11 +39,28 @@ class Analog:
name: str
"""The name of the analog pin"""

@dataclass
class Value:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably make this a TypeAlias if all the attributes are the same

if sys.version_info >= (3, 10):
    from typing import TypeAlias
else:
    from typing_extensions import TypeAlias

class Board:
    class Analog:
        Value: "TypeAlias" = ReadAnalogReaderResponse

Similar to how it's done in Vision

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way, we don't have to keep Value in sync with the response type should any fields be added/removed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh dang, that's super clean! I had no idea that was a thing. Thanks!

Copy link
Member

@stuqdog stuqdog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, modulo @njooma's TypeAlias suggestion (which I agree with).

@penguinland penguinland requested a review from njooma May 16, 2024 20:17
src/viam/components/board/client.py Outdated Show resolved Hide resolved
src/viam/components/board/service.py Outdated Show resolved Hide resolved
Copy link
Member

@njooma njooma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@penguinland penguinland merged commit 6f891d1 into viamrobotics:main May 16, 2024
12 checks passed
@penguinland penguinland deleted the stream_ticks branch May 16, 2024 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants