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-7532 - Adding getProperties to vision service #3925

Merged
merged 7 commits into from
May 9, 2024

Conversation

kharijarrett
Copy link
Member

No description provided.

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label May 8, 2024
Copy link
Contributor

github-actions bot commented May 8, 2024

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 IsMoving
board GPIOPinByName
camera Properties
encoder Properties
motor IsMoving
sensor Readings
servo Position
arm EndPosition
audio MediaProperties
gantry Lengths
gripper IsMoving
input_controller Controls
movement_sensor LinearAcceleration
power_sensor Power
pose_tracker Poses
motion GetPose
vision ClassificationsFromCamera

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels May 9, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels May 9, 2024
@kharijarrett kharijarrett requested a review from bhaney May 9, 2024 15:49
Copy link
Member

@bhaney bhaney left a comment

Choose a reason for hiding this comment

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

The biggest change is to add an returned error to the properties, because if we are on purpose making the Properties struct something that could potentially grow in the future, you'll want to avoid the possibility of having to add an error return in the future

Also, add tests! Or rather, you can add GetProperties checks to our existing tests. You can check to see if some of our classifiers or detectors return the expected properties. Be sure to add tests to the client and server code as well


ext, err := protoutils.StructToStructPb(extra)
if err != nil {
return nil
Copy link
Member

Choose a reason for hiding this comment

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

You want to return the error

Extra: ext,
})
if err != nil {
return nil
Copy link
Member

Choose a reason for hiding this comment

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

Return the error

@@ -242,6 +242,26 @@ func protoToObjects(pco []*commonpb.PointCloudObject) ([]*vision.Object, error)
return objects, nil
}

func (c *client) GetProperties(ctx context.Context, extra map[string]interface{}) *Properties {
Copy link
Member

Choose a reason for hiding this comment

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

The method should also return an error

@@ -128,6 +128,8 @@ type Service interface {

// GetObjectPointClouds returns a list of 3D point cloud objects and metadata from the latest 3D camera image using a specified segmenter.
GetObjectPointClouds(ctx context.Context, cameraName string, extra map[string]interface{}) ([]*viz.Object, error)
// properties
GetProperties(ctx context.Context, extra map[string]interface{}) *Properties
Copy link
Member

Choose a reason for hiding this comment

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

I think you'll want to return an error as well -- in the interest of future proofing, what if you add something to the properties that can easily return an error? You would then have to introduce a breaking change to add the error output

Comment on lines 311 to 315
func (vm *vizModel) GetProperties(ctx context.Context, extra map[string]interface{}) *Properties {
_, span := trace.StartSpan(ctx, "service::vision::GetProperties::"+vm.Named.Name().String())
defer span.End()

return &vm.properties
Copy link
Member

Choose a reason for hiding this comment

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

change to return an error

@@ -28,6 +28,7 @@ type VisionService struct {
n int, extra map[string]interface{}) (classification.Classifications, error)
// segmentation functions
GetObjectPointCloudsFunc func(ctx context.Context, cameraName string, extra map[string]interface{}) ([]*viz.Object, error)
GetPropertiesFunc func(ctx context.Context, extra map[string]interface{}) *vision.Properties
Copy link
Member

Choose a reason for hiding this comment

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

change to return an error

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels May 9, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels May 9, 2024
@kharijarrett kharijarrett requested a review from bhaney May 9, 2024 19:05
Copy link
Member

@bhaney bhaney left a comment

Choose a reason for hiding this comment

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

Thanks for adding error and some tests, but you'll still want to add tests for GetProperties to client_test.go and server_test.go. You'll want to see that the properties are transferred over GRPC successfully

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels May 9, 2024
Copy link
Member

@bhaney bhaney left a comment

Choose a reason for hiding this comment

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

Nice! LGTM

@kharijarrett kharijarrett merged commit 41a9d47 into viamrobotics:main May 9, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants