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

image_proc for ros2 #369

Closed
wants to merge 2 commits into from
Closed

Conversation

ahuizxc
Copy link

@ahuizxc ahuizxc commented Dec 4, 2018

image_proc for ros2

This was referenced Dec 5, 2018
find_package(OpenCV REQUIRED)
find_package(Boost REQUIRED COMPONENTS thread)
find_package(image_geometry REQUIRED)

if(cv_bridge_VERSION VERSION_GREATER "1.12.0")
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be unnecessary now, since we are already setting standard to 14

const image_geometry::PinholeCameraModel& model,
ImageSet& output, int flags = ALL) const;
};
// Processing state (note: only safe because we're using single-threaded NodeHandle!)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't believe the single-threaded assumption holds anymore, this may need to be protected via mutex.

Copy link
Author

Choose a reason for hiding this comment

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

these code is just same as ros branch did, so i am not change it in ros2 version.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, to be clear, this was previously using single threaded NodeHandle's in the ROS1/Nodelet paradigm. Because this is now inheriting from an rclcpp::Node, we can't make the same guarantees about this only executing in a single-threaded context (people could add the Node to a multi-threaded executor). Since that assumption no longer holds, I believe that we need to add some locking here to guarantee safety.

image_proc/src/debayer.cpp Outdated Show resolved Hide resolved
image_proc/src/debayer.cpp Outdated Show resolved Hide resolved
image_proc/src/edge_aware.cpp Outdated Show resolved Hide resolved
image_proc/src/edge_aware.cpp Outdated Show resolved Hide resolved
@ahuizxc
Copy link
Author

ahuizxc commented Dec 10, 2018

@mjcarroll already create a new commit for your suggestions, thanks :)

@klintan
Copy link
Contributor

klintan commented Feb 17, 2019

@ahuizxc I had some issues getting your fork of image_proc working. First it only starts the first node. Second it can't be shutdown using ctrl+c. I'm suspecting some lock/thread/callback issue, but I'm really just a C++ beginner so.

However I rewrote some of it to use the Ros2 built-in namespacing instead of a custom namespace argument which I think makes more sense. Allthough, perhaps removing the parameter service is a bad idea, but I can't really judge that.

this seems to work now:
https://github.com/klintan/image_pipeline/tree/image_proc_for_ros2

just start it using:
ros2 run image_proc image_proc __ns:=/my_namespace

would love to understand what the benefits of the parameter/callback approach ? :) feel free to provide some feedback on my branch as well. If you want to I can create an additional PR to better and easier be able to compare.

@ahuizxc
Copy link
Author

ahuizxc commented Feb 21, 2019

@ahuizxc I had some issues getting your fork of image_proc working. First it only starts the first node. Second it can't be shutdown using ctrl+c. I'm suspecting some lock/thread/callback issue, but I'm really just a C++ beginner so.

However I rewrote some of it to use the Ros2 built-in namespacing instead of a custom namespace argument which I think makes more sense. Allthough, perhaps removing the parameter service is a bad idea, but I can't really judge that.

this seems to work now:
https://github.com/klintan/image_pipeline/tree/image_proc_for_ros2

just start it using:
ros2 run image_proc image_proc __ns:=/my_namespace

would love to understand what the benefits of the parameter/callback approach ? :) feel free to provide some feedback on my branch as well. If you want to I can create an additional PR to better and easier be able to compare.

I also ported image_view for ros2, I think we should see what advice is given in the community and then focus on the details, thanks :)

@klintan
Copy link
Contributor

klintan commented Feb 26, 2019

@ahuizxc I had some issues getting your fork of image_proc working. First it only starts the first node. Second it can't be shutdown using ctrl+c. I'm suspecting some lock/thread/callback issue, but I'm really just a C++ beginner so.
However I rewrote some of it to use the Ros2 built-in namespacing instead of a custom namespace argument which I think makes more sense. Allthough, perhaps removing the parameter service is a bad idea, but I can't really judge that.
this seems to work now:
https://github.com/klintan/image_pipeline/tree/image_proc_for_ros2
just start it using:
ros2 run image_proc image_proc __ns:=/my_namespace
would love to understand what the benefits of the parameter/callback approach ? :) feel free to provide some feedback on my branch as well. If you want to I can create an additional PR to better and easier be able to compare.

I also ported image_view for ros2, I think we should see what advice is given in the community and then focus on the details, thanks :)

Yes great job! However I don't really understand how it relates to this PR (except for it being in the same image_pipeline package) ?

Since this is open source, my definition of community is whoever might be using the package and feel that they want to contribute to it, but perhaps you have a more narrow definition of it? :)

Also you already got a couple of comments from mjcarrol who is one of the owners which should qualify as "advice is given in the community". I think not doing it the ROS2 way merits an explanation. But as I said before, I'm just a C++ novice, so I could very well be missing a very obvious reason for it, should be easy enough to just point it out to me.

Many thanks for putting in the hard work of contributing this, I made good use of it after my minor changes.

@yechun1
Copy link
Contributor

yechun1 commented Mar 15, 2019

@ahuizxc See the file processor.h has be renamed, but don't know why, and this makes stereo_image_proc package which depend on image_proc fail to find the include file: #include <image_proc/processor.h>

May I suggest to keep the same folder structure and file name while port code. It would be helpful for other package porting on ROS2 without interface changes. And also be easy for code review.

@JWhitleyWork
Copy link
Collaborator

@yechun1 and @ahuizxc - Is this effort still ongoing? Could we provide a crystal-devel branch for you to both have a common development pipeline? It seems like this PR and #374 were done in isolation.

@yechun1
Copy link
Contributor

yechun1 commented Apr 19, 2019

Hi @JWhitleyAStuff
There is already ros2 branch for development. @mjcarroll had generated crystal bloom release previously, with merged code on ros2 branch. I think we could use ros2 branch currently.

@ahuizxc has ported image_proc and image_view from ROS1 to ROS2. This PR is for image_proc and #374 is for image_view. These patches are waiting for review, hope someone could give some comments, and then approve and merge.

We took effort on image_pipeline ROS2 porting, here is the status with Todo list. most of the modules ready and waiting for maintainer's review, not sure if you would please help to review the PRs, we'll update the patch if need any changes.

@mjcarroll
Copy link
Contributor

We should be able to continue to release for ros2, and I plan on doing it for dashing, earlier testing is always better than later.

@yechun1 and his team have done a great job contributing here, I just haven't had the bandwidth to keep up with reviews. @JWhitleyAStuff if you and your team have some spare cycles, getting these things reviewed and in would be awesome!

Copy link
Collaborator

@JWhitleyWork JWhitleyWork left a comment

Choose a reason for hiding this comment

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

See my comments. Also, why are a bunch of files/nodes missing from this PR like rectify, advertisement_checker, processor, crop_decimate, and crop_non_zero?

endif()
install(TARGETS
image_proc
DESTINATION lib/${PROJECT_NAME})
Copy link
Collaborator

Choose a reason for hiding this comment

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

In ROS1, this would have been installed under lib/ but the convention for ROS2 seems to be bin/ for executables and lib/ only for libraries.

@@ -31,47 +31,43 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/
#ifndef IMAGE_PROC_PROCESSOR_H
#define IMAGE_PROC_PROCESSOR_H
#include <thread>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good work on adding includes for the std:: objects that you use. However, you seem to have lost the header-guard in the process. Please re-add.

@@ -39,8 +39,8 @@
#define WAVG4(a,b,c,d,x,y) ( ( ((int)(a) + (int)(b)) * (int)(x) + ((int)(c) + (int)(d)) * (int)(y) ) / ( 2 * ((int)(x) + (int(y))) ) )
using namespace std;
Copy link
Collaborator

Choose a reason for hiding this comment

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

For the love of Pete, please fix this.

Copy link
Author

Choose a reason for hiding this comment

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

i don't know how to change this, do you mean this code is too long?

// limitations under the License.

#ifdef __clang__
// TODO(dirk-thomas) custom implementation until we can use libc++ 3.9
Copy link
Collaborator

Choose a reason for hiding this comment

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

The version of clang included with Ubuntu Bionic (target for Crystal) is v7. I think we can likely remove this section and test with clang/libc++.

Copy link
Contributor

Choose a reason for hiding this comment

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

This functionality has actually been refactored into rcpputils, so I would suggest using that. https://github.com/ros2/rcpputils/blob/master/include/rcpputils/filesystem_helper.hpp

Supporting macOS still presents issues when using std::filesystem, so this is currently the suggested approach.

#include <image_geometry/pinhole_camera_model.h>
#include <cv_bridge/cv_bridge.h>
#include "visibility.h"
#include "../include/rectify.hpp"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use local-relative paths here (e.g. "rectify.hpp"). CMake should take care of the include paths.

@JWhitleyWork
Copy link
Collaborator

@yechun1, @mjcarroll, and @ahuizxc - Are you all OK with me rebasing the ros2 branch on the melodic branch? This will incorporate some of the fixes that we've made to image_view and add in the new CI (which I will modify to work with ROS2 afterward). This would mean that you would have to rebase your PRs on the new ros2 branch. Otherwise, I can just manually apply the CI changes to the ros2 branch.


void DebayerNodelet::onInit()
namespace enc = sensor_msgs::image_encodings;
DebayerNode::DebayerNode()
Copy link
Contributor

Choose a reason for hiding this comment

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

Nodes should take const rclcpp::NodeOptions& in order to make them composable (replacement for nodelets)

@yechun1
Copy link
Contributor

yechun1 commented Apr 25, 2019

@JWhitleyAStuff @mjcarroll thank you for take time to review our patches.

@ahuizxc would you please help to check the comments and give some changes? thanks.

@JWhitleyWork
Copy link
Collaborator

@ahuizxc - Please rebase your branch on the ros2 branch. This will bring in fixes from melodic and the new CI.

@JWhitleyWork
Copy link
Collaborator

Closing in favor of #426.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants