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_transport to ROS2 #1

Merged
merged 28 commits into from
Aug 24, 2023
Merged

Port point_cloud_transport to ROS2 #1

merged 28 commits into from
Aug 24, 2023

Conversation

john-maidbot
Copy link
Collaborator

@john-maidbot john-maidbot commented Jun 19, 2023

This is a VERY rough draft of my attempts to port point_cloud_transport from ROS to ROS2. Comments/feedback are very welcome but just be aware that it is a very early port and is not yet reflective of the final form I have in mind.

Some key notes on the current status of the port:

  1. The C++ code and python bindings build without errors 🎉 and we have passing CI
  2. Plugins (raw + draco + zlib) load properly
  3. There are a variety of places where I just directly ported the ROS functionality to ROS2 but where I want to refactor it further to better make use of recent ROS2 functionality (e.g. latched topics, components, type adaptation, etc...). My reasoning for doing this is to first sanity check the implementation in ros2 and verify Draco is working as expected before diving into these optimizations.

TODO (Not necessarily in sequential order):

Ideas that should be their own PR's:

@john-maidbot
Copy link
Collaborator Author

jdang@jjdang:~/Desktop/experiment_ws$ ros2 run point_cloud_transport list_transports 
Lookup name: point_cloud_transport/draco_pub
Transport name: point_cloud_transport/draco
Lookup name: point_cloud_transport/raw_pub
Transport name: point_cloud_transport/raw
Declared transports:
point_cloud_transport/draco
point_cloud_transport/raw

Details:
----------
"point_cloud_transport/draco"
 - Provided by package: draco_point_cloud_transport
 - Publisher: 
            This plugin publishes a CompressedPointCloud2 using KD tree compression.
        
 - Subscriber: 
            This plugin decompresses a CompressedPointCloud2 topic.
        
----------
"point_cloud_transport/raw"
 - Provided by package: point_cloud_transport
 - Publisher: 
            This is the default publisher. It publishes the PointCloud2 as-is on the base topic.
        
 - Subscriber: 
            This is the default pass-through subscriber for topics of type sensor_msgs/PointCloud2.
        

@ahcorde
Copy link
Collaborator

ahcorde commented Jun 22, 2023

Hi @john-maidbot,

I'm also interested in contributing to this port. You have done a very nice initial work. Where do you plan to centralize this work ? Is this the main meta-ticket ?

Let me know how I can help and how we can distribute tasks and reviews

@john-maidbot
Copy link
Collaborator Author

Hello @ahcorde ,

Thanks for your interest! Yes, my plan was to start making PR's into the ros2 branches of this repo and the point_cloud_transport_plugin repo to address the TODO's I listed above.

I have not yet given a lot of thought to how I could distribute tasks and reviews (if you have ideas please lmk 🙂 ). But in the meantime, we could update the above TODO list to reflect what is being worked on and by whom?

These were the next things I wanted to make progress on. If you have interest in one of these (or any of the other TODO's above), please let me know and I can mark them appropriately above (we could probably break these up):

  • Cleanup the configuration of the publishers and subscribers. Users should be able to pass qos and options like with a normal rclcpp pub/sub
  • Fix the point_cloud_codec.hpp/.cpp files so that the ability to encode/decode pointclouds using the transport plugins is exposed without having to republish topics.

Also, are you familiar with type adaptation by any chance?

@ahcorde
Copy link
Collaborator

ahcorde commented Jun 22, 2023

I read long time ago about the type adaptation but I'm not familiar. I need to read documentation as well ;)

Let me know if you are already working in some of these two things, otherwise, I will start with the first bullet point

@john-maidbot
Copy link
Collaborator Author

awesome! I will take the second bullet point then. I have updated the TODO list above to reflect this.
thanks again for the help!

Signed-off-by: Alejandro Hernández Cordero <[email protected]>
@john-maidbot
Copy link
Collaborator Author

@ahcorde just wanted to say thank you so much for all your recent PR's! 🚀 I sadly havent had much time to put into this project the past two weeks, but I should have a lot of time this week to put into this.
I reviewed all your current PR's, and I should have the pointcloud_codec and python bindings PR ready for review in the next couple of days.

Signed-off-by: Alejandro Hernández Cordero <[email protected]>
@peci1
Copy link
Contributor

peci1 commented Jul 10, 2023

Hi. I'm also subscribed to this PR, so if you have any questions to me, just ask. But I won't be able to help with much ROS 2 specifics...

Signed-off-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
@ahcorde
Copy link
Collaborator

ahcorde commented Jul 10, 2023

Thank for your support @peci1

I started to migrate point_cloud_transport_tutorial too
ahcorde/point_cloud_transport_tutorial#1

@ahcorde
Copy link
Collaborator

ahcorde commented Jul 11, 2023

Draft PR to include point_cloud_transport in Rviz2 ros2/rviz#1008

@peci1
Copy link
Contributor

peci1 commented Jul 11, 2023

Draft PR to include point_cloud_transport in Rviz2 ros2/rviz#1008

Awesome, I wanted to do that for ROS 1 too, but haven't found the time for it yet :) Thanks!

CMakeLists.txt Outdated Show resolved Hide resolved
@ahcorde
Copy link
Collaborator

ahcorde commented Jul 13, 2023

@peci1 I have a question for you,

When I start the draco plugin I need to open the rqt_reconfigure tool to uncheck the force_quantization flag, but I started the code with this flag deactivate I still see the error (and then I need to check and uncheck the param):

[ERROR] [1689244703.737228226] [point_cloud_transport]: Error encoding message by transport draco: Draco encoder returned code -1: Failed to encode point attributes...

@peci1
Copy link
Contributor

peci1 commented Jul 13, 2023

At least in ROS 1, the flag defaults to True: https://github.com/ctu-vras/point_cloud_transport_plugins/blob/2751d9a7fbcdceaa97673b9577d8d02746a459a0/draco_point_cloud_transport/cfg/DracoPublisher.cfg#L31 .

Do I understand correctly that this error shows when you set the param to false before starting the publisher?

@ahcorde
Copy link
Collaborator

ahcorde commented Jul 13, 2023

This is the most recent code with the default parameters:

https://github.com/john-maidbot/point_cloud_transport_plugins/blob/7d96f96c0414418f07af65d6b5be3ab499fba1cd/draco_point_cloud_transport/include/draco_point_cloud_transport/draco_publisher.hpp#L70-L83

The error appears with the default parameters, to get rid of the error I need to unset force_quantization.

@peci1
Copy link
Contributor

peci1 commented Jul 13, 2023

Hmm, can you get the stacktrace when the error is written?

@ahcorde
Copy link
Collaborator

ahcorde commented Jul 13, 2023

it's inside the EncodePointCloudToBuffer method.

draco::Status status = encoder.EncodePointCloudToBuffer(*pc, &encode_buffer);

@peci1
Copy link
Contributor

peci1 commented Jul 13, 2023

Maybe it needs the calls to encoder.SetAttributeQuantization() done even in case no (or automatic) encoding method is set?

If that doesn't help, I think you have to start debugging Draco. The problem should be discoverable in this function: https://github.com/google/draco/blob/9f856abaafb4b39f1f013763ff061522e0261c6f/src/draco/compression/point_cloud/point_cloud_encoder.cc#L101 .

Signed-off-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Alejandro Hernandez Cordero <[email protected]>
@john-maidbot
Copy link
Collaborator Author

@ahcorde are you seeing this error when you build by any chance? Or do you have any ideas about what the issue might be?

CMake Error at ament_cmake_symlink_install/ament_cmake_symlink_install.cmake:100 (message):
  ament_cmake_symlink_install_directory() can't find
  '.../ros_ws/build/point_cloud_transport/_deps/expected-src/TYPE'
Call Stack (most recent call first):
  ament_cmake_symlink_install/ament_cmake_symlink_install.cmake:317 (ament_cmake_symlink_install_directory)
  cmake_install.cmake:46 (include)

I wonder if its related to the FetchContent command?

@john-maidbot
Copy link
Collaborator Author

I finally have the pointcloud codec PR ready for review! 😃 (sorry it took so long, finding non-work time at my computer has been challenging this month)

@ahcorde there is no rush, but could you please review that PR when you have time? It is a lot of changes, so if you would prefer, I can try to break it up into separate PR's? Just lmk 🙂

In the meantime, I will look into that build error either later today or later this week.

@john-maidbot
Copy link
Collaborator Author

john-maidbot commented Jul 23, 2023

@ahcorde are you seeing this error when you build by any chance? Or do you have any ideas about what the issue might be?

CMake Error at ament_cmake_symlink_install/ament_cmake_symlink_install.cmake:100 (message):
  ament_cmake_symlink_install_directory() can't find
  '.../ros_ws/build/point_cloud_transport/_deps/expected-src/TYPE'
Call Stack (most recent call first):
  ament_cmake_symlink_install/ament_cmake_symlink_install.cmake:317 (ament_cmake_symlink_install_directory)
  cmake_install.cmake:46 (include)

I wonder if its related to the FetchContent command?

ok found a seemingly related issue on ament_cmake: ament/ament_cmake#471

And it seems that just building without --symlink-install resolves the problem.

@ahcorde
Copy link
Collaborator

ahcorde commented Jul 24, 2023

PR in rosdistro to add draco and make it available from rosdep ros/rosdistro#38056

john-maidbot and others added 5 commits July 25, 2023 16:24
* Update topic / transport name introspection

* Fix some build errors

* Replacing shapeshifter with rclcpp::serializedmessage

* remove c_api

* consolidate bindable code into codec

* Update tests

* Get pybind working

* remove stale comments

* Fix python nodes

* doc update

* Add pybind11_vendor

* Update include/point_cloud_transport/point_cloud_codec.hpp

* Add license to pybind_codec

* param docs + standardize \param

* remove references to ros wiki

* make flake8 happy

* cpplint

---------

Signed-off-by: Alejandro Hernández Cordero <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
#12)

* Update package to support building offline

* Exclude thirdparty folder from ament_lint

* Suggestions to #12 - Fixed linters (#14)

* Suyggestions to #12 - Fixed linters

Signed-off-by: Alejandro Hernández Cordero <[email protected]>

* missing dependency

Signed-off-by: Alejandro Hernández Cordero <[email protected]>

---------

Signed-off-by: Alejandro Hernández Cordero <[email protected]>

---------

Signed-off-by: Alejandro Hernández Cordero <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
* Use whitelist instead of blacklist

Signed-off-by: Alejandro Hernández Cordero <[email protected]>

* Feedback

Signed-off-by: Alejandro Hernández Cordero <[email protected]>

* feedback

Signed-off-by: Alejandro Hernández Cordero <[email protected]>

* Updates to param namespacing (#16)

---------

Signed-off-by: Alejandro Hernández Cordero <[email protected]>
Co-authored-by: john-maidbot <[email protected]>
* Define declareParameters for raw pub/sub

* Add queue_size version of advertise

* Fix copyright linting
* Add gitignore

* Test coverage for message filter subscriber

* Remove cras expected.hpp

* Standardize docstrings

* Fix typo
@ahcorde ahcorde marked this pull request as ready for review August 24, 2023 14:08
@ahcorde
Copy link
Collaborator

ahcorde commented Aug 24, 2023

I will merge this PR and I will open issue for the remaining open tasks

@ahcorde ahcorde merged commit 4bdab19 into rolling Aug 24, 2023
3 checks passed
@peci1
Copy link
Contributor

peci1 commented Aug 24, 2023

Does this mean you're about to release the package in the current state?

@ahcorde
Copy link
Collaborator

ahcorde commented Aug 24, 2023

I would love to release the package at some point (at least in rolling)

@peci1
Copy link
Contributor

peci1 commented Aug 24, 2023

Good. I wanted to go through the code and have a look at the points where it diverges from the ROS 1 version, and probably discuss some of the points. I think I might have time for it this weekend ;)

@ahcorde ahcorde deleted the ros2 branch August 28, 2023 07:38
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