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

DATA 498 add labels to geometries in RDK #1438

Conversation

bazile-clyde
Copy link
Contributor

@bazile-clyde bazile-clyde commented Oct 5, 2022

This commit is the first part of DATA-498. The next part will focus on the client and server interface. This seemed like a good stopping point since it's pretty large and self-contained.

@@ -218,7 +218,7 @@ func (jpcs *joinPointCloudSource) NextPointCloudNaive(ctx context.Context) (poin
savedDualQuat := spatialmath.NewZeroPose()
pcSrc.Iterate(numLoops, loop, func(p r3.Vector, d pointcloud.Data) bool {
if jpcs.sourceNames[iCopy] != jpcs.targetName {
spatialmath.ResetPoseDQTransalation(savedDualQuat, p)
spatialmath.ResetPoseDQTranslation(savedDualQuat, p)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: typo in "Transalation"

@@ -62,7 +62,7 @@ type Data interface {
// Note(erd): we should try to remove this in favor of immutability.
SetValue(v int) Data

// Value returns the intesity value, or 0 if it doesn't exist
// Intensity returns the intensity value, or 0 if it doesn't exist
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: The function name is "Intensity" not "Value".

test.That(t, err, test.ShouldBeNil)
box, err := BoundingBoxFromPointCloud(c.pc)
box, err := BoundingBoxFromPointCloudWithLabel(c.pc, "box")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated this test to test the new BoundingBoxFromPointCloudWithLabel function, which is actually the old function's logic with a new function signature (it takes in a label now). It seemed liked the simplest way to cover the new function, BoundingBoxFromPointCloudWithLabel. See GitHub comment above this function for more info.

}

// ToProto converts the box to a Geometry proto message.
// ToProtobuf converts the box to a Geometry proto message.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: Function name is "ToProtobuf" not "ToProto"

@@ -118,7 +126,6 @@ func (b *box) CollidesWith(g Geometry) (bool, error) {
return true, newCollisionTypeUnsupportedError(b, g)
}

// CollidesWith checks if the given box collides with the given geometry and returns true if it does.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: This comment is a duplicate of the comment above and isn't actually for the DistanceFrom function; it's for the CollidesWith function.

return creator, nil
}
// never try to infer point geometry if nothing is specified
}
return nil, fmt.Errorf("%w %s", ErrGeometryTypeUnsupported, string(config.Type))
}

// NewGeometryFromProto instatiates a new Geometry from a protobuf Geometry message.
// NewGeometryFromProto instantiates a new Geometry from a protobuf Geometry message.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: typo

@@ -51,6 +51,7 @@ func TestGeometrySerialization(t *testing.T) {
newVc, err := config.ParseConfig()
test.That(t, err, test.ShouldBeNil)
test.That(t, gc.NewGeometry(pose).AlmostEqual(newVc.NewGeometry(pose)), test.ShouldBeTrue)
test.That(t, config.Label, test.ShouldEqual, testCase.name)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To simply test the label was set correctly I made it the same name as the testCase's name iff the testCase can be parsed, i.e., success == true.

@@ -15,7 +15,7 @@ type Orientation interface {
RotationMatrix() *RotationMatrix
}

// NewZeroOrientation returns an orientatation which signifies no rotation.
// NewZeroOrientation returns an orientation which signifies no rotation.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: typo

@@ -15,7 +15,7 @@ import (
)

// Epsilon represents the acceptable discrepancy between two floats
// representing spatial coordinates wherin the coordinates should be
// representing spatial coordinates wherein the coordinates should be
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: typo

// ResetPoseDQTransalation takes a Pose that must be a dualQuaternion and reset's it's translation.
func ResetPoseDQTransalation(p Pose, v r3.Vector) {
// ResetPoseDQTranslation takes a Pose that must be a dualQuaternion and reset's it's translation.
func ResetPoseDQTranslation(p Pose, v r3.Vector) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: typo in "Transalation"

@bazile-clyde bazile-clyde requested a review from bhaney October 5, 2022 14:57
@bhaney bhaney requested a review from raybjork October 5, 2022 15:45
@bhaney
Copy link
Member

bhaney commented Oct 5, 2022

@raybjork Hey Ray, since you worked on geometries, we are adding a label field to Geometries, so that people can select on Geometries by user-defined names as well.

Comment on lines +29 to 37
func NewBoxCreator(dims r3.Vector, offset Pose, label string) (GeometryCreator, error) {
if dims.X <= 0 || dims.Y <= 0 || dims.Z <= 0 {
return nil, newBadGeometryDimensionsError(&box{})
}
return &boxCreator{dims.Mul(0.5), pointCreator{offset}}, nil
return &boxCreator{dims.Mul(0.5), pointCreator{offset, label}, label}, nil
}

// NewGeometry instantiates a new box from a BoxCreator class.
func (bc *boxCreator) NewGeometry(pose Pose) Geometry {
Copy link
Member

@bhaney bhaney Oct 5, 2022

Choose a reason for hiding this comment

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

@raybjork Do you think the new label argument should go in the signature of BoxCreator, or in the signature of NewGeometry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As of now it's in both, sort of. For NewGeometry it just grabs it from the *boxCreator. We could add it to NewGeometry too. We'd just have to be wary of tiebreaks in case it's passed in as an argument and *boxCreator already has one. In that case we'd probably want to the argument to take precedence. Right now users would have to update the label before calling NewGeometry, either in the call to NewBoxCreator or box.label.

Copy link
Member

@bhaney bhaney Oct 5, 2022

Choose a reason for hiding this comment

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

Yea, I wondering if it's only NewGeometry() that should pass the label to the box{}/sphere{}/etc struct, or if it should be xCreator as you currently have it. I'll want to wait to hear from @raybjork to see how they use these creators, and if it makes sense to set the label at the creator level.

Copy link
Member

Choose a reason for hiding this comment

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

The GeometryCreator is the one that should have the label and provide it.

The way this information is used, is that any individual geometry is intended to be ephemeral and only valid at that location. The GeometryCreator persists the information about things like the dimensions of the geometry, and instantiates new versions of that geometry at various poses as requested.

There shouldn't be a situation where people are calling NewGeometry on a GeometryCreator and wanting it to have a different label, that should be an entirely new GeometryCreator.

Copy link
Member

Choose a reason for hiding this comment

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

Excellent, then all the open questions are resolved on my end- LGTM @bazile-clyde

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.

I say this LGTM, but wait for Ray to comment on whether if boxCreator et al. should have the label field, or if labels shouldn't apply to xCreator structs and only should be within the Geometry structs themselves.

@bhaney bhaney requested review from biotinker and removed request for raybjork October 6, 2022 15:45
@bhaney
Copy link
Member

bhaney commented Oct 6, 2022

Oops, Ray isn't here this week, @biotinker, could you comment on where labels should be set: Whether when the Creator is made, or when NewGeometry is called?

@bazile-clyde bazile-clyde force-pushed the DATA-498-add-labels-to-geometries-in-rdk branch from 541f27c to de47540 Compare October 6, 2022 21:21
@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2022

Code Coverage

Package Line Rate Health
go.viam.com/rdk/components/arm 59%
go.viam.com/rdk/components/arm/universalrobots 12%
go.viam.com/rdk/components/arm/xarm 2%
go.viam.com/rdk/components/arm/yahboom 7%
go.viam.com/rdk/components/audioinput 55%
go.viam.com/rdk/components/base 68%
go.viam.com/rdk/components/base/agilex 62%
go.viam.com/rdk/components/base/boat 41%
go.viam.com/rdk/components/base/wheeled 76%
go.viam.com/rdk/components/board 69%
go.viam.com/rdk/components/board/arduino 10%
go.viam.com/rdk/components/board/commonsysfs 47%
go.viam.com/rdk/components/board/fake 38%
go.viam.com/rdk/components/board/numato 19%
go.viam.com/rdk/components/board/pi 50%
go.viam.com/rdk/components/camera 66%
go.viam.com/rdk/components/camera/fake 67%
go.viam.com/rdk/components/camera/ffmpeg 72%
go.viam.com/rdk/components/camera/transformpipeline 74%
go.viam.com/rdk/components/camera/videosource 58%
go.viam.com/rdk/components/encoder/fake 77%
go.viam.com/rdk/components/gantry 68%
go.viam.com/rdk/components/gantry/multiaxis 84%
go.viam.com/rdk/components/gantry/oneaxis 86%
go.viam.com/rdk/components/generic 85%
go.viam.com/rdk/components/gripper 82%
go.viam.com/rdk/components/input 86%
go.viam.com/rdk/components/input/gpio 87%
go.viam.com/rdk/components/motor 82%
go.viam.com/rdk/components/motor/dmc4000 69%
go.viam.com/rdk/components/motor/fake 59%
go.viam.com/rdk/components/motor/gpio 62%
go.viam.com/rdk/components/motor/gpiostepper 53%
go.viam.com/rdk/components/motor/tmcstepper 65%
go.viam.com/rdk/components/movementsensor 68%
go.viam.com/rdk/components/movementsensor/cameramono 39%
go.viam.com/rdk/components/movementsensor/gpsnmea 37%
go.viam.com/rdk/components/movementsensor/gpsrtk 28%
go.viam.com/rdk/components/posetracker 88%
go.viam.com/rdk/components/sensor 88%
go.viam.com/rdk/components/sensor/ultrasonic 31%
go.viam.com/rdk/components/servo 86%
go.viam.com/rdk/config 77%
go.viam.com/rdk/control 57%
go.viam.com/rdk/data 78%
go.viam.com/rdk/grpc 25%
go.viam.com/rdk/ml 67%
go.viam.com/rdk/ml/inference 70%
go.viam.com/rdk/motionplan 71%
go.viam.com/rdk/operation 93%
go.viam.com/rdk/pointcloud 70%
go.viam.com/rdk/protoutils 74%
go.viam.com/rdk/referenceframe 78%
go.viam.com/rdk/registry 88%
go.viam.com/rdk/resource 85%
go.viam.com/rdk/rimage 78%
go.viam.com/rdk/rimage/depthadapter 94%
go.viam.com/rdk/rimage/transform 73%
go.viam.com/rdk/rimage/transform/cmd/extrinsic_calibration 67%
go.viam.com/rdk/robot 93%
go.viam.com/rdk/robot/client 79%
go.viam.com/rdk/robot/framesystem 68%
go.viam.com/rdk/robot/impl 80%
go.viam.com/rdk/robot/server 59%
go.viam.com/rdk/robot/web 61%
go.viam.com/rdk/robot/web/stream 87%
go.viam.com/rdk/services/armremotecontrol 75%
go.viam.com/rdk/services/armremotecontrol/builtin 25%
go.viam.com/rdk/services/baseremotecontrol 75%
go.viam.com/rdk/services/baseremotecontrol/builtin 71%
go.viam.com/rdk/services/datamanager 62%
go.viam.com/rdk/services/datamanager/builtin 80%
go.viam.com/rdk/services/datamanager/datacapture 34%
go.viam.com/rdk/services/datamanager/datasync 70%
go.viam.com/rdk/services/motion 68%
go.viam.com/rdk/services/motion/builtin 89%
go.viam.com/rdk/services/navigation 54%
go.viam.com/rdk/services/sensors 78%
go.viam.com/rdk/services/sensors/builtin 97%
go.viam.com/rdk/services/shell 15%
go.viam.com/rdk/services/slam 86%
go.viam.com/rdk/services/slam/builtin 75%
go.viam.com/rdk/services/vision 82%
go.viam.com/rdk/services/vision/builtin 74%
go.viam.com/rdk/spatialmath 85%
go.viam.com/rdk/subtype 96%
go.viam.com/rdk/utils 71%
go.viam.com/rdk/vision 25%
go.viam.com/rdk/vision/chess 80%
go.viam.com/rdk/vision/delaunay 87%
go.viam.com/rdk/vision/keypoints 92%
go.viam.com/rdk/vision/objectdetection 83%
go.viam.com/rdk/vision/odometry 60%
go.viam.com/rdk/vision/odometry/cmd 0%
go.viam.com/rdk/vision/segmentation 48%
go.viam.com/rdk/web/server 26%
Summary 66% (18976 / 28626)

@bazile-clyde bazile-clyde merged commit 9b4b831 into viamrobotics:main Oct 6, 2022
@bazile-clyde bazile-clyde deleted the DATA-498-add-labels-to-geometries-in-rdk branch October 6, 2022 21:36
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