-
Notifications
You must be signed in to change notification settings - Fork 92
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
Fix service and action interface generation #76
Conversation
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>
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:
versus how they are currently referenced:
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 |
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>
* 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>
0dd0877
to
efaf468
Compare
With #68, I've rebased this PR. |
There was a problem hiding this 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.
output_file = os.path.join( | ||
output_dir, *namespaces[1:], '{0}.ep.{1}.cpp'.format(goal_type_name, typesupport_impl)) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
output_file = os.path.join( | ||
output_dir, *namespaces[1:], '{0}.ep.{1}.cpp'.format(goal_type_name, typesupport_impl)) |
There was a problem hiding this comment.
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
@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>
@esteve I think I've address all of your comments. |
@esteve Friendly ping. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jacobperron thanks!
* 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>
* 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>
* 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>
* 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>
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
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.