Skip to content

Conversation

@clalancette
Copy link
Collaborator

This pull request adds the ability to specify options to the node, much like is done for rclcpp and rclpy. It consists of 3 commits:

  1. The first one plumbs getName and getNamespace so that they both get data from the underlying rcl implementation. While this isn't strictly related to this PR, this is more correct and it makes it possible to write tests to ensure that the argument parsing is working as intended.
  2. The second one plumbs through more options into createNode, and ultimately the nativeCreateNodeHandle JNI functions.
  3. The third one adds a test to make sure this is working.

I will note that this PR changes the RCLJava::createNode full signature in non-backwards-compatible ways. I did it that way to more closely mimic the rclcpp API, but I could also be convinced to just append to the createNode parameters, rather than rearranging them.

On a separate note, a lot of methods and functions at the JNI layer are being invoked without error checking. This generally leads to a crash of the JVM if an error condition is hit. We should probably have a separate effort to audit those and add error checking as appropriate.

@jacobperron FYI.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Copy link
Collaborator

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

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

I haven't reviewed the tests yet.

The overall approach looks good to me, but I would prefer to have a NodeOptions class defined in Java.
That will make the API look nicer.

This should make the code much easier to read.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
This makes it a lot nicer to use.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Copy link
Collaborator

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

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

LGTM

1.  Check return value of malloc.
2.  Get rid of unnecessary cast.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
@clalancette
Copy link
Collaborator Author

All right, I ended up doing the minor fixes pointed out by @ivanpauno . I'm going to go ahead and merge this, then rebase #5 on top. Thanks for the reviews!

@clalancette clalancette merged commit 10cc08d into osrf:foxy-devel Aug 11, 2020
@clalancette clalancette deleted the clalancette/add-node-options branch August 11, 2020 13:17
ivanpauno added a commit to ros2-java/ros2_java that referenced this pull request Nov 16, 2021
* Get the node name and namespace from the native interface.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

* Add in node options to nativeCreateNodeHandle.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

* Add in NodeOptions test.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

* Move argument parsing to its own helper function.

This should make the code much easier to read.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

* Add a NodeOptions class.

This makes it a lot nicer to use.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

* Make sure to DeleteLocalRef after use.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

* Fixes from review.

1.  Check return value of malloc.
2.  Get rid of unnecessary cast.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

* android compatibility

Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>

Co-authored-by: Chris Lalancette <clalancette@openrobotics.org>
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.

2 participants