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

Port point cloud transformation to numpy #507

Merged
merged 38 commits into from
Apr 27, 2022
Merged

Port point cloud transformation to numpy #507

merged 38 commits into from
Apr 27, 2022

Conversation

Flova
Copy link
Contributor

@Flova Flova commented Mar 5, 2022

Implements the point cloud transformation in NumPy. This speeds up the transformation operation by 20000% for large point clouds (excluding the serialization and deserialization). The code needs some further testing but should work as it is. I also try to improve the performance of the serialization and deserialization as seen in ros2/common_interfaces#175.

This adds NumPy as a dependency and drops the dependency on PyKDL which should solve #471.

The API is also improved by adding proper interface descriptions.

Cheers

@aprotyas
Copy link
Member

aprotyas commented Mar 6, 2022

CI is failing here because it couldn't resolve the python-numpy rosdep key for Ubuntu Jammy. I believe the dependency needs to be on python3-numpy instead.

Copy link
Member

@aprotyas aprotyas left a comment

Choose a reason for hiding this comment

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

This looks like a great contribution. I don't know about adding numpy as a dependency, specially since upstream efforts for PyKDL are underway, but the maintainers can decide on that. I've left some suggestions inline.

Also, it looks like your commits aren't signed-off. Do you mind signing them off?
https://docs.ros.org/en/rolling/Contributing/Developer-Guide.html#change-control-process

tf2_sensor_msgs/src/tf2_sensor_msgs/tf2_sensor_msgs.py Outdated Show resolved Hide resolved
tf2_sensor_msgs/package.xml Outdated Show resolved Hide resolved
tf2_sensor_msgs/src/tf2_sensor_msgs/tf2_sensor_msgs.py Outdated Show resolved Hide resolved
tf2_sensor_msgs/src/tf2_sensor_msgs/tf2_sensor_msgs.py Outdated Show resolved Hide resolved
tf2_sensor_msgs/src/tf2_sensor_msgs/tf2_sensor_msgs.py Outdated Show resolved Hide resolved
tf2_sensor_msgs/src/tf2_sensor_msgs/tf2_sensor_msgs.py Outdated Show resolved Hide resolved
@aprotyas
Copy link
Member

aprotyas commented Mar 6, 2022

Also, is the DCO bot not configured on this repo for some reason? @clalancette

@Flova
Copy link
Contributor Author

Flova commented Mar 6, 2022

CI is failing here because it couldn't resolve the python-numpy rosdep key for Ubuntu Jammy. I believe the dependency needs to be on python3-numpy instead.

Done

@Flova
Copy link
Contributor Author

Flova commented Mar 6, 2022

There seems to be an issue with /usr/lib/x86_64-linux-gnu/libpython3.9.so on jammy.
I get the following error while building:

No rule to make target '/usr/lib/x86_64-linux-gnu/libpython3.9.so', needed by 'libstd_msgs__rosidl_generator_c.so'.  Stop.

And the CI fails with a similar one.

@Flova Flova force-pushed the ros2 branch 3 times, most recently from fdece22 to adac985 Compare March 6, 2022 17:10
@Flova
Copy link
Contributor Author

Flova commented Mar 6, 2022

Sorry I needed to force push the new commit with signature.

@Flova Flova force-pushed the ros2 branch 2 times, most recently from e36337a to 14b378d Compare March 10, 2022 01:07
@Flova
Copy link
Contributor Author

Flova commented Mar 10, 2022

All tests are passing. But I would want to wait for the serialization pull request, which would open some possibilities for improvements in this pr.

Any further suggestions regarding this implementation?

Copy link
Member

@aprotyas aprotyas left a comment

Choose a reason for hiding this comment

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

The PR looks good mostly. I've left some small comments in-line.

It might make sense to import the API in the scope of tf2_sensor_msgs/__init__.py with:

from .tf2_sensor_msgs import do_transform_cloud, transform_points  # noqa

tf2_sensor_msgs/CMakeLists.txt Outdated Show resolved Hide resolved
tf2_sensor_msgs/test/test_tf2_sensor_msgs.py Outdated Show resolved Hide resolved
tf2_sensor_msgs/tf2_sensor_msgs/tf2_sensor_msgs.py Outdated Show resolved Hide resolved
@aprotyas
Copy link
Member

@ros-pull-request-builder retest this please

@aprotyas
Copy link
Member

CI:
Build args: --packages-above-and-dependencies tf2_sensor_msgs
Test args: --packages-above tf2_sensor_msgs
Repos file: https://gist.githubusercontent.com/aprotyas/a62e4da45b1ec3f5d52838ff94617e94/raw/a61329ea9bfded0ef42a4d5ccae47b321d6dd937/ros2.repos
Job: https://ci.ros2.org/job/ci_launcher/10079

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@aprotyas
Copy link
Member

@Flova looks like there are some linter errors in CI: can you address that?
Also, one of the tests fail because sensor_msgs_py can't be imported. I believe updating the list of dependencies (#507 (comment)) should sort that out.

@clalancette
Copy link
Contributor

Also, it looks like some of the numpy changes from ros2/common_interfaces#175 caused regressions on RHEL: https://ci.ros2.org/view/nightly/job/nightly_linux-rhel_release/1091/ . I would suggest holding off on this PR until we figure out what is going on there and how to mitigate it (as we may need to do the same thing here).

@aprotyas
Copy link
Member

Also, it looks like some of the numpy changes from ros2/common_interfaces#175 caused regressions on RHEL: https://ci.ros2.org/view/nightly/job/nightly_linux-rhel_release/1091/ . I would suggest holding off on this PR until we figure out what is going on there and how to mitigate it (as we may need to do the same thing here).

Related to ros2/common_interfaces#185, the numpy.typing module is introduced in numpy 1.20, and so will also cause regressions on RHEL.

@Flova
Copy link
Contributor Author

Flova commented Mar 30, 2022

Also, it looks like some of the numpy changes from ros2/common_interfaces#175 caused regressions on RHEL: https://ci.ros2.org/view/nightly/job/nightly_linux-rhel_release/1091/ . I would suggest holding off on this PR until we figure out what is going on there and how to mitigate it (as we may need to do the same thing here).

Related to ros2/common_interfaces#185, the numpy.typing module is introduced in numpy 1.20, and so will also cause regressions on RHEL.

Not only for RHEL. Afaik Ubuntu has a recent version that doesn't support it too. So i will remove the npt typing.

@Flova
Copy link
Contributor Author

Flova commented Apr 4, 2022

All TODOs should be resolved now. I added

  • the RHEL fix
  • optimizations if the cloud only includes coordinates
  • more tests for clouds that contain not only coordinates
  • more tests regarding the expected header as well as the registration in tf2

The rolling CI also passes, so we should be fine to rerun the tests for all architectures. @aprotyas
Maybe also have a look at my additions to the as it changed a bit.

@Flova Flova requested a review from aprotyas April 4, 2022 10:53
@Flova
Copy link
Contributor Author

Flova commented Apr 19, 2022

Friendly ping @aprotyas :)

Copy link
Member

@aprotyas aprotyas left a comment

Choose a reason for hiding this comment

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

Apparently this was left as a pending review and I just never submitted - thank you for the ping @Flova.

This PR looks good. I've left a bunch of nits inline, but feel free to ignore them if they don't make sense.

Consider what constitutes the public API of tf2_sensor_msgs though, i.e. my comments in the __init__.py file.

tf2_sensor_msgs/tf2_sensor_msgs/__init__.py Outdated Show resolved Hide resolved
tf2_sensor_msgs/tf2_sensor_msgs/tf2_sensor_msgs.py Outdated Show resolved Hide resolved
tf2_sensor_msgs/test/test_tf2_sensor_msgs.py Outdated Show resolved Hide resolved
tf2_sensor_msgs/test/test_tf2_sensor_msgs.py Outdated Show resolved Hide resolved
tf2_sensor_msgs/test/test_tf2_sensor_msgs.py Outdated Show resolved Hide resolved
tf2_sensor_msgs/test/test_tf2_sensor_msgs.py Outdated Show resolved Hide resolved
tf2_sensor_msgs/test/test_tf2_sensor_msgs.py Outdated Show resolved Hide resolved
tf2_sensor_msgs/test/test_tf2_sensor_msgs.py Outdated Show resolved Hide resolved
@Flova
Copy link
Contributor Author

Flova commented Apr 21, 2022

@aprotyas everything should be resolved now

Copy link
Member

@aprotyas aprotyas 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 iterating @Flova. I've left a couple of stray, minor nits that you can consider, but I'll approve regardless.

tf2_sensor_msgs/test/test_tf2_sensor_msgs.py Outdated Show resolved Hide resolved
tf2_sensor_msgs/test/test_tf2_sensor_msgs.py Outdated Show resolved Hide resolved
tf2_sensor_msgs/test/test_tf2_sensor_msgs.py Outdated Show resolved Hide resolved
@aprotyas
Copy link
Member

@Flova can you rebase your branch on the upstream HEAD? I can run CI for you once that's done.

Flova and others added 11 commits April 21, 2022 23:38
Co-authored-by: Abrar Rahman Protyasha <aprotyas@u.rochester.edu>
Co-authored-by: Abrar Rahman Protyasha <aprotyas@u.rochester.edu>
Co-authored-by: Abrar Rahman Protyasha <aprotyas@u.rochester.edu>
Signed-off-by: Florian Vahl <florian@flova.de>
Signed-off-by: Florian Vahl <florian@flova.de>
Co-authored-by: Abrar Rahman Protyasha <aprotyas@u.rochester.edu>
Signed-off-by: Florian Vahl <florian@flova.de>
Co-authored-by: Abrar Rahman Protyasha <aprotyas@u.rochester.edu>
Co-authored-by: Abrar Rahman Protyasha <aprotyas@u.rochester.edu>
Co-authored-by: Abrar Rahman Protyasha <aprotyas@u.rochester.edu>
Signed-off-by: Florian Vahl <florian@flova.de>
@aprotyas
Copy link
Member

Thanks for rebasing @Flova. Running CI now.

Repos file: https://gist.githubusercontent.com/aprotyas/25ed5c597ccf7fd55a64975b4a5c0abe/raw/0eb6fb2688926456e2944b39c07492898e9a8078/ros2.repos
Build args: --packages-above-and-dependencies tf2_sensor_msgs
Test args: --packages-above tf2_sensor_msgs
Job: https://ci.ros2.org/job/ci_launcher/10193/

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@aprotyas
Copy link
Member

@Flova looks like there are some flake8 linter warnings, can you address them please? For the set comprehension warning, going from set(...) to {...} should suffice.

Signed-off-by: Florian Vahl <florian@flova.de>
@Flova
Copy link
Contributor Author

Flova commented Apr 22, 2022

@aprotyas I fixed the flake8 errors. Do you know why they only occur in this CI and not in the Jammy Build that is done automatically or my local installation?

@aprotyas
Copy link
Member

@Flova it looks like the CI job installs these flake8 extensions which aren't present in the PR job. Same could apply for your local environment?

flake8==4.0.1
flake8-blind-except==0.1.1
flake8-builtins==1.5.3
flake8-class-newline==1.6.0
flake8-comprehensions==3.8.0
flake8-deprecated==1.3
flake8-docstrings==1.6.0
flake8-import-order==0.18.1
flake8-quotes==3.3.1

Re-running CI after 2cdf774.
Repos file: https://gist.githubusercontent.com/aprotyas/25ed5c597ccf7fd55a64975b4a5c0abe/raw/0eb6fb2688926456e2944b39c07492898e9a8078/ros2.repos
Build args: --packages-above-and-dependencies tf2_sensor_msgs
Test args: --packages-above tf2_sensor_msgs
Job: https://ci.ros2.org/job/ci_launcher/10194/

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@aprotyas
Copy link
Member

@clalancette feature PRs can now be merged into Rolling again right? If so, this PR is ready to go.

Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

One more small thing to fix, then I think this is good.

tf2_sensor_msgs/package.xml Outdated Show resolved Hide resolved
Signed-off-by: Florian Vahl <florian@flova.de>
@Flova
Copy link
Contributor Author

Flova commented Apr 26, 2022

The fix is applied. @clalancette

Copy link
Member

@aprotyas aprotyas left a comment

Choose a reason for hiding this comment

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

LGTM. Running CI again:

Repos file: https://gist.githubusercontent.com/aprotyas/25ed5c597ccf7fd55a64975b4a5c0abe/raw/0eb6fb2688926456e2944b39c07492898e9a8078/ros2.repos
Build args: --packages-above-and-dependencies tf2_sensor_msgs
Test args: --packages-above tf2_sensor_msgs
Job: https://ci.ros2.org/job/ci_launcher/10208/

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@aprotyas
Copy link
Member

Green CI + two approvals, so I'll merge this. Thanks for your contribution @Flova!

@aprotyas aprotyas merged commit 6242f01 into ros2:ros2 Apr 27, 2022
@Blast545
Copy link
Contributor

👨‍🌾 Looks like this PR introduced a build regression in the cyclonedds jobs of the buildfarm, see:

Rci__nightly-cyclonedds_ubuntu_jammy_amd64#57
Rci__nightly-cyclonedds_ubuntu_jammy_amd64#58

01:33:42.101 -- Found ament_lint_auto: 0.12.3 (/tmp/ws/install_isolated/ament_lint_auto/share/ament_lint_auto/cmake)
01:33:42.101 CMake Error at CMakeLists.txt:41 (find_package):
01:33:42.101   By not providing "Findament_cmake_pytest.cmake" in CMAKE_MODULE_PATH this
01:33:42.101   project has asked CMake to find a package configuration file provided by
01:33:42.101   "ament_cmake_pytest", but CMake did not find one.
01:33:42.101 
01:33:42.101   Could not find a package configuration file provided by
01:33:42.101   "ament_cmake_pytest" with any of the following names:
01:33:42.101 
01:33:42.101     ament_cmake_pytestConfig.cmake
01:33:42.101     ament_cmake_pytest-config.cmake
01:33:42.101 
01:33:42.101   Add the installation prefix of "ament_cmake_pytest" to CMAKE_PREFIX_PATH or
01:33:42.101   set "ament_cmake_pytest_DIR" to a directory containing one of the above
01:33:42.101   files.  If "ament_cmake_pytest" provides a separate development package or
01:33:42.101   SDK, be sure it has been installed.
01:33:42.101 

Can you take a look @Flova ?

@Blast545
Copy link
Contributor

Mmm I think it only requires adding ament_cmake_pytest to the package.xml file, I'll test this out and open a PR, we can discuss there.

@aprotyas
Copy link
Member

Mmm I think it only requires adding ament_cmake_pytest to the package.xml file, I'll test this out and open a PR, we can discuss there.

@Blast545 #520 should fix it.

@Blast545
Copy link
Contributor

Just saw it, thanks! @aprotyas

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.

None yet

5 participants