-
Notifications
You must be signed in to change notification settings - Fork 111
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-1072 Read PCD to Octree #1768
Conversation
|
||
basicOct, err := ReadPCDToBasicOctree(strings.NewReader(gotPCD)) | ||
test.That(t, err, test.ShouldBeNil) | ||
test.That(t, basicOct.Size(), test.ShouldEqual, 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, do we want to have any more comprehensive testing that the conversion from PCD
to Octree
is lossless?
Would it be possible to write a test that confirms that (at a high level):
ToPCD(ToOctree(PCD)) == PCD
ToPointcloud(PCD)
's methods behave in the exact same way asToOctree(PCD)
? for a givenPCD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a note on line 174 in basic_octree_utils.go
to do so once we decide which way to go (one way doesnt require this function to exist)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I were implementing this, I'd like to have tests that prove 1 & 2 in the PR that adds the functionality to go between PCD & Octree to ensure they are correct.
Could we add them before merging this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please get tests for the behavior of https://github.com/viamrobotics/rdk/pull/1768/files#diff-e01dea69a2aaa9209cb5deeb1c4569f99ef8c51262c69799a0cec3a79d7434ebR543 ?
PCDAscii
and PCDCompressed
and an unexpected type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, I now see that these cases are covered in testASCIIRoundTrip
& testBinaryRoundTrip
bOct.logger.Infof("%v %e %e %e - %v | Children: %v Side: %v Size: %v\n", s, | ||
func printBasicOctree(bOct *BasicOctree, s string) { | ||
//nolint:forbidigo | ||
fmt.Printf("%v %e %e %e - %v | Children: %v Side: %v Size: %v\n", s, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this Printf needed, is there no global logger? also, why the//nolint:unsued
there?
pointcloud/basic_octree_utils.go
Outdated
} | ||
|
||
return ok | ||
} | ||
|
||
// ConvertPointCloudToBasicOctree converts a pointcloud into a octree pointcloud representation. | ||
func ConvertPointCloudToBasicOctree(cloud PointCloud) (PointCloud, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if we end up having multiple octree types, we could just create another function which returns a that octree type. If the caller has opinions on which octree representation to use, they can call the function which gives them that flavor of octree.
Returning a PointCloud
implies to me that returning anything that implements the PointCloud
interface would be equally valid, which I don't think is the case for this function.
|
||
basicOct, err := ReadPCDToBasicOctree(strings.NewReader(gotPCD)) | ||
test.That(t, err, test.ShouldBeNil) | ||
test.That(t, basicOct.Size(), test.ShouldEqual, 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I were implementing this, I'd like to have tests that prove 1 & 2 in the PR that adds the functionality to go between PCD & Octree to ensure they are correct.
Could we add them before merging this PR?
only blocking feedback remaining is test cases for all the different PCD formats ReadPCDToOctree supports & doesn't support, so we can have at least high level tests of all the new code paths which are being added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Things are looking good, just some optional cosmetic changes
pointcloud/basic_octree_utils.go
Outdated
X: meta.MinX + (meta.MaxX-meta.MinX)/2, | ||
Y: meta.MinY + (meta.MaxY-meta.MinY)/2, | ||
Z: meta.MinZ + (meta.MaxZ-meta.MinZ)/2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[opt] This can also be expressed as (meta.MinX + meta.MaxX)/2
but it's not like an extra operation makes a big difference.
pointcloud/pointcloud_file.go
Outdated
switch header.data { | ||
case PCDAscii: | ||
meta, err = getPCDMetaDataASCII(*in, header) | ||
case PCDBinary: | ||
meta, err = getPCDMetaDataBinary(*in, header) | ||
case PCDCompressed: | ||
// return readPCDCompressed(in, header) | ||
return nil, errors.New("compressed pcd not yet supported") | ||
default: | ||
return nil, fmt.Errorf("unsupported pcd data type %v", header.data) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like this switch statement could be within the function more general called getPCDMetaData
pointcloud/pointcloud_file.go
Outdated
func getPCDMetaDataBinary(in bufio.Reader, header pcdHeader) (MetaData, error) { | ||
meta := NewMetaData() | ||
for i := 0; i < int(header.points); i++ { | ||
pd, err := extractPCDPointBinary(&in, header) | ||
if err != nil { | ||
return MetaData{}, err | ||
} | ||
|
||
meta.Merge(pd.P, pd.D) | ||
} | ||
return meta, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I think combining the getPCDMetaData functions into one will make all right sense
|
This PR implements the
ReadPCDToOctree
function which allows the creation of an octree from a pcd file/buffer. It also adds octrees to thepointcloud
package, as the rescoping of map representation removed the formerly requiredMarshaler
function allowing octrees to implement thepointcloud
interface exactly. This change over also allows us to take advantage of the pcd reader functions where are unexposed.The
ReadPCDToBasicOctree
current is implemented by creating a basic pointcloud which allows us to obtain the requried metadata for an octree (center and sideLength from the max and min X,Y and Z values and then converting this pointcloud to a basicOctree. This results in a call toReadPCD
as well as a call to the newConvertPointCloudToOctree
function. The ConvertPointCloudToOctree returns a Pointcloud interface that can be cast into aBasicOctree
and any other implementation of octree that should be created in the future, whileReadPCDToBasicOctree
returns the specificBasicOctree
structSeveral changes were made, including but not limited to:
BasicOctrees
New
toNewBasicOctree
to reduce confusion asNew
already exists in the pointcloud packageBasicOctree
(basicOctree
->BasicOctree
)Additional information can be found in the comment below
JIRA Ticket: RSDK-1072