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-420 & DATA-421] Octree Implementation of Basic Functionality Set, At, MetaData and Size #1596

Merged
23 commits merged into from Nov 29, 2022

Conversation

ghost
Copy link

@ghost ghost commented Nov 15, 2022

Summary: This PR is the initial push for the octree data structure that will be used by SLAM to store generated maps and ease the ingestion of them by other teams. It implements a basic octree data struct which abides by the Octree interface (which includes the Pointcloud functions as well as a marshaling function although it is not included in this PR).

The focus of this PR is the New(), At(), Set(), Metadata() and Size() functions although several additional helper functions can be found in basic_utils.go

Associated JIRA Tickets: DATA-420 DATA-421

Open Questions:

  • Do we need checks for validity of nodes and if so where? Currently the only way to create new nodes is via newLeafNodeEmpty, newLeafNodeFilled, newInternalNode functions. Editing the data struct or accessing helper function to create improper nodes is not possible due to them not being exposed.
  • Do we care about children overlap? Currently the children have co-linear bounds that are INCLUSIVE meaning multiple nodes may cover the same infinitesimally small region. The order one traverses nodes is controlled/consistent and so no issues will occur during iteration or set/at but a non-standard access may result in data not being found where expected.
  • Should OctreeMetaData exist, and if so should it be included in the Octree interface (see comment below for more details)

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Nov 15, 2022
@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 Nov 15, 2022
test.That(t, checkPointPlacement(center, side, r3.Vector{X: -1000, Y: 0, Z: 0}), test.ShouldBeFalse)
}

// Helper functions for visualizing octree during testing
Copy link
Author

Choose a reason for hiding this comment

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

Functions here are used for test creation/debugging in the future they may be fully integrated into testing but for now they were made unused once test creation was complete

}

// Checks that point should be inside octree based on octree center and defined side length.
func checkPointPlacement(center r3.Vector, sideLength float64, p r3.Vector) bool {
Copy link
Author

Choose a reason for hiding this comment

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

See second open question regarding check

}

// OctreeMetaData returns the octree metadata.
func (octree *basicOctree) OctreeMetaData() MetaData {
Copy link
Author

Choose a reason for hiding this comment

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

Octree Metadata is a superset of Pointcloud metadata. The interface for pointcloud requires the return of pointcloud metadata. To return the full Octree metadata a new function OctreeMetaData is introduced.

Note alternatives include:

  • Only storing pc.MetaData and doing calculations of the additional necessary octree metadata before serialization (calls to Size, center... etc)


// At traverses the octree to see in a point exists at the specified location. If a point does exist, its data is
// returned along with true, if one is not then no data is returned and the boolean is returned false.
func (octree *basicOctree) At(x, y, z float64) (pc.Data, bool) {
Copy link
Author

Choose a reason for hiding this comment

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

As discussed, current implementation is for exact match to return true and the point data. nearest neighbor has not been implemented

@ghost ghost requested review from bhaney, JohnN193 and kkufieta November 15, 2022 22:12
@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 Nov 15, 2022
@ghost ghost marked this pull request as ready for review November 15, 2022 22:36
@kkufieta
Copy link
Contributor

kkufieta commented Nov 16, 2022

Can you make the title for the PR title more descriptive and remove the date from it?

The date is already recorded inherently in the commits & PR and is not helpful in a PR title.

It might be helpful to add more to the title than "Octree Implementation" because I suspect there will be more PRs following that implement Octrees. If not then ignore this last point.

Copy link
Member

@JohnN193 JohnN193 left a comment

Choose a reason for hiding this comment

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

pretty much looks good to me, only real question is if this should live in pointcloud. In the tech spec we have it at go.viam.com/rdk/octree, but I also see why it could live in pointcloud since its a variation of that

pointcloud/octree/basic.go Outdated Show resolved Hide resolved
@ghost ghost changed the title [DATA-420 & DATA-421] Octree Implementation 11_14_2022 [DATA-420 & DATA-421] Octree Implementation of Basic Functionality Set, At, MetaData and Size Nov 16, 2022
@ghost
Copy link
Author

ghost commented Nov 16, 2022

pretty much looks good to me, only real question is if this should live in pointcloud. In the tech spec we have it at go.viam.com/rdk/octree, but I also see why it could live in pointcloud since its a variation of that

I spoke to Bijan about that and he recommended it live in pointcloud. Happy to move it if we feel it is better suited to primary level in rdk

@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 Nov 16, 2022
@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 Nov 17, 2022
@kkufieta
Copy link
Contributor

I spoke to Bijan about that and he recommended it live in pointcloud. Happy to move it if we feel it is better suited to primary level in rdk

What are the arguments for this recommendation? I think we should stick to the tech spec unless there are good reasons not to

Copy link
Contributor

@kkufieta kkufieta left a comment

Choose a reason for hiding this comment

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

First pass. Still learning about it, more tomorrow.

pointcloud/octree/basic.go Outdated Show resolved Hide resolved
pointcloud/octree/basic.go Outdated Show resolved Hide resolved
pointcloud/octree/basic.go Outdated Show resolved Hide resolved
pointcloud/octree/basic.go Outdated Show resolved Hide resolved
pointcloud/octree/basic.go Outdated Show resolved Hide resolved
pointcloud/octree/basic_utils.go Outdated Show resolved Hide resolved
pointcloud/octree/basic_utils.go Outdated Show resolved Hide resolved
pointcloud/octree/basic_utils.go Outdated Show resolved Hide resolved
pointcloud/octree/octree.go Outdated Show resolved Hide resolved
pointcloud/octree/octree.go Outdated Show resolved Hide resolved
@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 Nov 18, 2022
@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 Nov 21, 2022
@JohnN193
Copy link
Member

I spoke to Bijan about that and he recommended it live in pointcloud. Happy to move it if we feel it is better suited to primary level in rdk

What are the arguments for this recommendation? I think we should stick to the tech spec unless there are good reasons not to

@bhaney any reasoning for this other than the pointcloud folder being a bit unwieldy

Just that since every go file in octtree will inherit pointcloud, it seems like it made sense to put it as a subpackage of the pointcloud package. But you can def just follow the tech spec, I have no strong preference about that

makes sense, I think once the rest of octtree is setup we can bring this question back up, and for now we can just follow the spec

@ghost ghost requested a review from bhaney November 22, 2022 05:45
Copy link
Contributor

@kkufieta kkufieta left a comment

Choose a reason for hiding this comment

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

Great work so far! A major concern is that the octree assumes a fixed size and does not accept points outside its current bounds. Instead of doing that, we can grow the octree in size so it can be more adaptive, and we don't have to worry about predicting the size of the space it'll map out.

octree/basic_test.go Outdated Show resolved Hide resolved
octree/basic_test.go Outdated Show resolved Hide resolved
octree/basic_utils.go Outdated Show resolved Hide resolved
octree/basic_utils.go Outdated Show resolved Hide resolved
octree/basic_utils_test.go Outdated Show resolved Hide resolved
octree/basic_utils_test.go Outdated Show resolved Hide resolved
octree/basic_utils_test.go Outdated Show resolved Hide resolved
octree/basic_utils_test.go Show resolved Hide resolved
octree/basic_utils_test.go Outdated Show resolved Hide resolved
octree/basic_utils_test.go Outdated Show resolved Hide resolved
@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 Nov 28, 2022
@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 Nov 28, 2022
@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 Nov 28, 2022
@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 Nov 28, 2022
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.

Looking good! Thanks for doing all the changes

@ghost ghost requested a review from kkufieta November 28, 2022 20:40
Copy link
Contributor

@kkufieta kkufieta left a comment

Choose a reason for hiding this comment

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

LGTM - I think this looks great. Thanks for incorporating my feedback!

}

// Helper function that recursively checks a basic octree's structure and metadata.
func validateBasicOctree(t *testing.T, bOct *basicOctree, center r3.Vector, sideLength float64) int32 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@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 Nov 29, 2022
@github-actions
Copy link
Contributor

Code Coverage

Package Line Rate Delta Health
go.viam.com/rdk/components/arm 59% 0.00%
go.viam.com/rdk/components/arm/universalrobots 13% 0.00%
go.viam.com/rdk/components/arm/xarm 2% 0.00%
go.viam.com/rdk/components/arm/yahboom 7% 0.00%
go.viam.com/rdk/components/audioinput 55% -0.34%
go.viam.com/rdk/components/base 67% 0.00%
go.viam.com/rdk/components/base/agilex 62% 0.00%
go.viam.com/rdk/components/base/boat 41% 0.00%
go.viam.com/rdk/components/base/wheeled 76% 0.00%
go.viam.com/rdk/components/board 68% 0.00%
go.viam.com/rdk/components/board/arduino 10% 0.00%
go.viam.com/rdk/components/board/commonsysfs 47% 0.00%
go.viam.com/rdk/components/board/fake 38% 0.00%
go.viam.com/rdk/components/board/numato 19% 0.00%
go.viam.com/rdk/components/board/pi 50% 0.00%
go.viam.com/rdk/components/camera 65% +0.27%
go.viam.com/rdk/components/camera/fake 67% 0.00%
go.viam.com/rdk/components/camera/ffmpeg 77% +1.43%
go.viam.com/rdk/components/camera/transformpipeline 78% +1.00%
go.viam.com/rdk/components/camera/videosource 55% -0.68%
go.viam.com/rdk/components/encoder/fake 77% 0.00%
go.viam.com/rdk/components/gantry 68% 0.00%
go.viam.com/rdk/components/gantry/multiaxis 84% 0.00%
go.viam.com/rdk/components/gantry/oneaxis 86% 0.00%
go.viam.com/rdk/components/generic 83% 0.00%
go.viam.com/rdk/components/gripper 80% 0.00%
go.viam.com/rdk/components/input 87% 0.00%
go.viam.com/rdk/components/input/gpio 83% 0.00%
go.viam.com/rdk/components/motor 81% 0.00%
go.viam.com/rdk/components/motor/dimensionengineering 63% 0.00%
go.viam.com/rdk/components/motor/dmc4000 69% 0.00%
go.viam.com/rdk/components/motor/fake 57% 0.00%
go.viam.com/rdk/components/motor/gpio 64% 0.00%
go.viam.com/rdk/components/motor/gpiostepper 57% 0.00%
go.viam.com/rdk/components/motor/tmcstepper 62% 0.00%
go.viam.com/rdk/components/movementsensor 75% 0.00%
go.viam.com/rdk/components/movementsensor/cameramono 40% 0.00%
go.viam.com/rdk/components/movementsensor/gpsnmea 37% 0.00%
go.viam.com/rdk/components/movementsensor/gpsrtk 28% 0.00%
go.viam.com/rdk/components/posetracker 86% 0.00%
go.viam.com/rdk/components/sensor 86% 0.00%
go.viam.com/rdk/components/sensor/ultrasonic 34% 0.00%
go.viam.com/rdk/components/servo 78% 0.00%
go.viam.com/rdk/components/servo/gpio 71% 0.00%
go.viam.com/rdk/config 76% 0.00%
go.viam.com/rdk/control 57% 0.00%
go.viam.com/rdk/data 77% 0.00%
go.viam.com/rdk/grpc 25% 0.00%
go.viam.com/rdk/ml 67% 0.00%
go.viam.com/rdk/ml/inference 70% 0.00%
go.viam.com/rdk/motionplan 68% 0.00%
go.viam.com/rdk/octree 93% N/A
go.viam.com/rdk/operation 82% 0.00%
go.viam.com/rdk/pointcloud 71% -0.09%
go.viam.com/rdk/protoutils 62% 0.00%
go.viam.com/rdk/referenceframe 78% 0.00%
go.viam.com/rdk/registry 88% 0.00%
go.viam.com/rdk/resource 83% 0.00%
go.viam.com/rdk/rimage 78% 0.00%
go.viam.com/rdk/rimage/depthadapter 94% 0.00%
go.viam.com/rdk/rimage/transform 73% 0.00%
go.viam.com/rdk/rimage/transform/cmd/extrinsic_calibration 67% 0.00%
go.viam.com/rdk/robot 93% 0.00%
go.viam.com/rdk/robot/client 80% 0.00%
go.viam.com/rdk/robot/framesystem 68% 0.00%
go.viam.com/rdk/robot/impl 80% -0.24%
go.viam.com/rdk/robot/server 58% -0.97%
go.viam.com/rdk/robot/web 60% 0.00%
go.viam.com/rdk/robot/web/stream 87% 0.00%
go.viam.com/rdk/services/armremotecontrol 71% 0.00%
go.viam.com/rdk/services/armremotecontrol/builtin 25% 0.00%
go.viam.com/rdk/services/baseremotecontrol 71% 0.00%
go.viam.com/rdk/services/baseremotecontrol/builtin 66% 0.00%
go.viam.com/rdk/services/datamanager 65% 0.00%
go.viam.com/rdk/services/datamanager/builtin 80% 0.00%
go.viam.com/rdk/services/datamanager/datacapture 21% 0.00%
go.viam.com/rdk/services/datamanager/datasync 72% 0.00%
go.viam.com/rdk/services/motion 67% 0.00%
go.viam.com/rdk/services/motion/builtin 88% 0.00%
go.viam.com/rdk/services/navigation 54% 0.00%
go.viam.com/rdk/services/sensors 77% 0.00%
go.viam.com/rdk/services/sensors/builtin 97% 0.00%
go.viam.com/rdk/services/shell 14% 0.00%
go.viam.com/rdk/services/slam 84% 0.00%
go.viam.com/rdk/services/slam/builtin 72% 0.00%
go.viam.com/rdk/services/vision 80% 0.00%
go.viam.com/rdk/services/vision/builtin 74% 0.00%
go.viam.com/rdk/spatialmath 85% 0.00%
go.viam.com/rdk/subtype 96% 0.00%
go.viam.com/rdk/utils 71% 0.00%
go.viam.com/rdk/vision 26% 0.00%
go.viam.com/rdk/vision/chess 80% 0.00%
go.viam.com/rdk/vision/delaunay 87% 0.00%
go.viam.com/rdk/vision/keypoints 92% 0.00%
go.viam.com/rdk/vision/objectdetection 82% 0.00%
go.viam.com/rdk/vision/odometry 60% 0.00%
go.viam.com/rdk/vision/odometry/cmd 0% 0.00%
go.viam.com/rdk/vision/segmentation 49% 0.00%
go.viam.com/rdk/web/server 26% 0.00%
Summary 66% (19662 / 29785) +0.05%

@ghost ghost merged commit 547e1da into viamrobotics:main Nov 29, 2022
@ghost ghost deleted the DATA-420_OctreeSetAndNew_11142022 branch December 29, 2022 20:33
This pull request was closed.
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.

4 participants