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

Fix service and action interface generation #76

Merged
merged 7 commits into from
Mar 18, 2020

Conversation

jacobperron
Copy link
Contributor

Depends on #68.
After #68 is merged, I can rebase this branch.

Before, we were not generating code for the messages and services that make up service and action
interfaces.

Due to issues with duplicate definitions caused by instantiating the msg.cpp.em template
multiple times, I've opted to generate separate files for each service, action, and the interfaces
that they are made of. This is similar to what we are doing with the generated Java code.

I've added a test confirming that generated service code can be used. Adding a test for actions is
difficult at the moment due to a circular dependency with action_msgs.

@jacobperron jacobperron mentioned this pull request Feb 5, 2020
25 tasks
jacobperron added a commit that referenced this pull request Feb 7, 2020
Tests that involve services are broken due to issues related to interface generation.
There's a separate PR for a fix: #76.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron
Copy link
Contributor Author

In retrospect, I think it would be worth doing some further refactoring so that service and action sub-interfaces are member classes. Then, in code the symbols are referenced like:

examples_interfaces.srv.AddTwoInts.Request

versus how they are currently referenced:

examples_interfaces.srv.AddTwoInts_Request

It seems more intuitive and in line with the C++ and Python code generators. Since this would be a significant refactor, I've ticketed it separately to do after the current string of PRs have landed: #83

jacobperron added a commit that referenced this pull request Feb 8, 2020
Tests that involve services are broken due to issues related to interface generation.
There's a separate PR for a fix: #76.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
esteve pushed a commit that referenced this pull request Feb 11, 2020
* Update API for getting rcl error string

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add implementation for ROS Context

A context represents an init/shutdown cycle and is used in the creation of top level entities
like nodes and guard conditions.

For convenience, a default context is created when rcljava is initialized.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add implementation for Clock

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Update for Dashing support

* Update wait set API calls
* Update entity creation API calls
* Use Context objects to check 'ok()' status
* Add Clock and Context members to NodeImpl
* Fix static member reference: 'this.defaultContext' -> 'RCLJava.defaultContext'

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Avoid hiding errors when cleaning up init options

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Disable tests

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix typos in JNI library files

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix native node method signature

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Populate missing QoS settings with defaults

Otherwise we run into a runtime error about Fast-RTPS not supporting liveliness.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix issues with Clock class

* Load with JNIUtils
* Rename native create method for consistency
* Fix bug in native implementation

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Enable linter tests

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix lint errors

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Enable RCLJava test and fix bugs

* Use Context.ok() and deprecate RCLJava.isInitialized().
* Move implementation loading to static initialization code.
  Otherwise, calls to getDefaultContext() fail if called before rclJavaInit().
  It wasn't clear to me why the implementation should be loaded in a separate function call.
  We can probably refactor the code to avoid the error if we want to move the loading back
  into rclJavaInit().
* Refactor test into one init/shutdown test. Previously, not calling RCLJava.shutdown()
  was leaving a context around between tests.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix NodeTest

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Enable most tests

Tests that involve services are broken due to issues related to interface generation.
There's a separate PR for a fix: #76.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Before, we were not generating code for the messages and services that make up service and action
interfaces.

Due to issues with duplicate definitions caused by instantiating the msg.cpp.em template
multiple times, I've opted to generate separate files for each service, action, and the interfaces
that they are made of. This is similar to what we are doing with the generated Java code.

I've added a test confirming that generated service code can be used. Adding a test for actions is
difficult at the moment due to a circular dependency with action_msgs.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
This avoids name clashing with other generated files. Similar to what we do with generated Java files.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
…types

For example, 'example_interfaces/srv/AddTwoInts_Request' should be mangled to 'example_1interfaces_srv_AddTwoInts_1Request'.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron
Copy link
Contributor Author

With #68, I've rebased this PR.

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.

I've only got minor comments here; otherwise, looks good to me. It's a bit unfortunate that there is so much duplication between the msg.cpp.em, idl.cpp.em, and srv.cpp.em, but that's OK for now.

Comment on lines +25 to +26
output_file = os.path.join(
output_dir, *namespaces[1:], '{0}.ep.{1}.cpp'.format(goal_type_name, typesupport_impl))
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a question; why the ".ep." portion of the filename?

Copy link
Member

Choose a reason for hiding this comment

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

ep originally stood for entry point, so that code could be split between common code and for each typesupport implementation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there are suggestions for renaming (or removing it) I'm happy to do so.

rosidl_generator_java/resource/idl.cpp.em Outdated Show resolved Hide resolved
rosidl_generator_java/resource/srv.cpp.em Outdated Show resolved Hide resolved
rosidl_generator_java/resource/msg.cpp.em Show resolved Hide resolved
Comment on lines +25 to +26
output_file = os.path.join(
output_dir, *namespaces[1:], '{0}.ep.{1}.cpp'.format(goal_type_name, typesupport_impl))
Copy link
Member

Choose a reason for hiding this comment

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

ep originally stood for entry point, so that code could be split between common code and for each typesupport implementation

@esteve
Copy link
Member

esteve commented Feb 27, 2020

In retrospect, I think it would be worth doing some further refactoring so that service and action sub-interfaces are member classes. Then, in code the symbols are referenced like:

examples_interfaces.srv.AddTwoInts.Request

versus how they are currently referenced:

examples_interfaces.srv.AddTwoInts_Request

It seems more intuitive and in line with the C++ and Python code generators. Since this would be a significant refactor, I've ticketed it separately to do after the current string of PRs have landed: #83

@jacobperron I remember trying to get that working, but I can't remember why I couldn't. But in any case, yeah, I agree having Request and Response as member classes.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron
Copy link
Contributor Author

@esteve I think I've address all of your comments.

@jacobperron
Copy link
Contributor Author

@esteve Friendly ping.

@jacobperron jacobperron requested a review from esteve March 17, 2020 22:21
Copy link
Member

@esteve esteve left a comment

Choose a reason for hiding this comment

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

@jacobperron thanks!

@esteve esteve merged commit bf1e4b6 into ros2-java:dashing Mar 18, 2020
@jacobperron jacobperron mentioned this pull request Oct 7, 2020
4 tasks
jacobperron added a commit that referenced this pull request May 17, 2021
* Update API for getting rcl error string

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add implementation for ROS Context

A context represents an init/shutdown cycle and is used in the creation of top level entities
like nodes and guard conditions.

For convenience, a default context is created when rcljava is initialized.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add implementation for Clock

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Update for Dashing support

* Update wait set API calls
* Update entity creation API calls
* Use Context objects to check 'ok()' status
* Add Clock and Context members to NodeImpl
* Fix static member reference: 'this.defaultContext' -> 'RCLJava.defaultContext'

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Avoid hiding errors when cleaning up init options

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Disable tests

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix typos in JNI library files

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix native node method signature

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Populate missing QoS settings with defaults

Otherwise we run into a runtime error about Fast-RTPS not supporting liveliness.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix issues with Clock class

* Load with JNIUtils
* Rename native create method for consistency
* Fix bug in native implementation

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Enable linter tests

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix lint errors

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Enable RCLJava test and fix bugs

* Use Context.ok() and deprecate RCLJava.isInitialized().
* Move implementation loading to static initialization code.
  Otherwise, calls to getDefaultContext() fail if called before rclJavaInit().
  It wasn't clear to me why the implementation should be loaded in a separate function call.
  We can probably refactor the code to avoid the error if we want to move the loading back
  into rclJavaInit().
* Refactor test into one init/shutdown test. Previously, not calling RCLJava.shutdown()
  was leaving a context around between tests.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix NodeTest

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Enable most tests

Tests that involve services are broken due to issues related to interface generation.
There's a separate PR for a fix: #76.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
jacobperron added a commit that referenced this pull request May 17, 2021
* Fix service and action interface generation

Before, we were not generating code for the messages and services that make up service and action
interfaces.

Due to issues with duplicate definitions caused by instantiating the msg.cpp.em template
multiple times, I've opted to generate separate files for each service, action, and the interfaces
that they are made of. This is similar to what we are doing with the generated Java code.

I've added a test confirming that generated service code can be used. Adding a test for actions is
difficult at the moment due to a circular dependency with action_msgs.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add missing header include

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Rename top level generated cpp file

This avoids name clashing with other generated files. Similar to what we do with generated Java files.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix JNI name mangling function so it works for service and action subtypes

For example, 'example_interfaces/srv/AddTwoInts_Request' should be mangled to 'example_1interfaces_srv_AddTwoInts_1Request'.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Remove vestigal references to jni_package_name

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add comment about action and service headers

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Simplify include logic

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
jacobperron added a commit that referenced this pull request May 17, 2021
* Update API for getting rcl error string

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add implementation for ROS Context

A context represents an init/shutdown cycle and is used in the creation of top level entities
like nodes and guard conditions.

For convenience, a default context is created when rcljava is initialized.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add implementation for Clock

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Update for Dashing support

* Update wait set API calls
* Update entity creation API calls
* Use Context objects to check 'ok()' status
* Add Clock and Context members to NodeImpl
* Fix static member reference: 'this.defaultContext' -> 'RCLJava.defaultContext'

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Avoid hiding errors when cleaning up init options

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Disable tests

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix typos in JNI library files

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix native node method signature

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Populate missing QoS settings with defaults

Otherwise we run into a runtime error about Fast-RTPS not supporting liveliness.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix issues with Clock class

* Load with JNIUtils
* Rename native create method for consistency
* Fix bug in native implementation

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Enable linter tests

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix lint errors

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Enable RCLJava test and fix bugs

* Use Context.ok() and deprecate RCLJava.isInitialized().
* Move implementation loading to static initialization code.
  Otherwise, calls to getDefaultContext() fail if called before rclJavaInit().
  It wasn't clear to me why the implementation should be loaded in a separate function call.
  We can probably refactor the code to avoid the error if we want to move the loading back
  into rclJavaInit().
* Refactor test into one init/shutdown test. Previously, not calling RCLJava.shutdown()
  was leaving a context around between tests.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix NodeTest

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Enable most tests

Tests that involve services are broken due to issues related to interface generation.
There's a separate PR for a fix: #76.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
jacobperron added a commit that referenced this pull request May 17, 2021
* Fix service and action interface generation

Before, we were not generating code for the messages and services that make up service and action
interfaces.

Due to issues with duplicate definitions caused by instantiating the msg.cpp.em template
multiple times, I've opted to generate separate files for each service, action, and the interfaces
that they are made of. This is similar to what we are doing with the generated Java code.

I've added a test confirming that generated service code can be used. Adding a test for actions is
difficult at the moment due to a circular dependency with action_msgs.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add missing header include

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Rename top level generated cpp file

This avoids name clashing with other generated files. Similar to what we do with generated Java files.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix JNI name mangling function so it works for service and action subtypes

For example, 'example_interfaces/srv/AddTwoInts_Request' should be mangled to 'example_1interfaces_srv_AddTwoInts_1Request'.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Remove vestigal references to jni_package_name

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add comment about action and service headers

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Simplify include logic

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
ivanpauno pushed a commit that referenced this pull request Oct 28, 2021
Signed-off-by: Jacob Perron <jacob@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.

3 participants