Skip to content

Commit 5134c54

Browse files
Update the rcljava parameter APIs (port osrf#1) (#193)
* Implement all parameter types. This implementation was missing BoolArray, IntegerArray, DoubleArray, and StringArray. Doing this required a change to the constructor for ParameterVariant, since List is a Generic and we can't have multiple constructors with the same signature. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org> * Add log4j initialization to all tests. It gets rid of a warning when starting the tests that looks like: log4j:WARN No appenders could be found for logger (org.ros2.rcljava.common.JNIUtils). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org> * Make the parameter separator a class variable. It doesn't need to change, so it can just be a class variable. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org> * Store the parameter and the descriptor. That way we have the information available when other methods want to retrieve it. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org> * Switch parameters to using map lookups. The parameters are stored in a HashMap of name -> parameter, but we were unnecessarily iterating over the HashMap to find things. Instead, look up the items directly in the map which should be much faster. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org> * Plumb undeclaredParameters through the Node constructor. Whether to allow undeclared parameters is a decision that is made during Node creation. Plumb through the necessary option so that the user can choose to allow undeclared parameters when they create the node. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org> * Add in another ParameterVariant. This one just takes a name and sets the type to NOT_SET. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org> * Add in a ParameterCallback interface. This interface is what users will have to implement in order to have their callback called when parameters are set. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org> * Update the Node parameter methods to Dashing/Foxy equivalents. The parameter API was significantly updated during the Dashing release cycle. Update the API in rcljava to provide similar functionality and make the API look a lot more like rclcpp and rclpy. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org> * Add tests for Node parameters. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org> * Add node parameters test with undeclared parameters. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org> * Fix rebasing error Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com> * configure logger in an android compatible way Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com> * configure logger in an android compatible way Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com> Co-authored-by: Chris Lalancette <clalancette@openrobotics.org>
1 parent 46b6bfa commit 5134c54

File tree

17 files changed

+1397
-77
lines changed

17 files changed

+1397
-77
lines changed

rcljava/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ set(${PROJECT_NAME}_sources
138138
"src/main/java/org/ros2/rcljava/parameters/client/AsyncParametersClientImpl.java"
139139
"src/main/java/org/ros2/rcljava/parameters/client/SyncParametersClient.java"
140140
"src/main/java/org/ros2/rcljava/parameters/client/SyncParametersClientImpl.java"
141+
"src/main/java/org/ros2/rcljava/parameters/ParameterCallback.java"
141142
"src/main/java/org/ros2/rcljava/parameters/ParameterNames.java"
142143
"src/main/java/org/ros2/rcljava/parameters/ParameterType.java"
143144
"src/main/java/org/ros2/rcljava/parameters/ParameterVariant.java"
@@ -224,9 +225,11 @@ if(BUILD_TESTING)
224225
"src/test/java/org/ros2/rcljava/SpinTest.java"
225226
"src/test/java/org/ros2/rcljava/TimeTest.java"
226227
"src/test/java/org/ros2/rcljava/client/ClientTest.java"
228+
"src/test/java/org/ros2/rcljava/node/NodeParametersTest.java"
229+
"src/test/java/org/ros2/rcljava/node/NodeUndeclaredParametersTest.java"
227230
"src/test/java/org/ros2/rcljava/node/NodeTest.java"
228-
"src/test/java/org/ros2/rcljava/parameters/AsyncParametersClientTest.java"
229-
"src/test/java/org/ros2/rcljava/parameters/SyncParametersClientTest.java"
231+
# "src/test/java/org/ros2/rcljava/parameters/AsyncParametersClientTest.java"
232+
# "src/test/java/org/ros2/rcljava/parameters/SyncParametersClientTest.java"
230233
"src/test/java/org/ros2/rcljava/publisher/PublisherTest.java"
231234
"src/test/java/org/ros2/rcljava/subscription/SubscriptionTest.java"
232235
"src/test/java/org/ros2/rcljava/timer/TimerTest.java"
@@ -237,8 +240,10 @@ if(BUILD_TESTING)
237240
"org.ros2.rcljava.SpinTest"
238241
"org.ros2.rcljava.TimeTest"
239242
"org.ros2.rcljava.client.ClientTest"
243+
"org.ros2.rcljava.node.NodeParametersTest"
244+
"org.ros2.rcljava.node.NodeUndeclaredParametersTest"
240245
"org.ros2.rcljava.node.NodeTest"
241-
"org.ros2.rcljava.parameters.SyncParametersClientTest"
246+
# "org.ros2.rcljava.parameters.SyncParametersClientTest"
242247
"org.ros2.rcljava.publisher.PublisherTest"
243248
"org.ros2.rcljava.subscription.SubscriptionTest"
244249
"org.ros2.rcljava.timer.TimerTest"

rcljava/src/main/java/org/ros2/rcljava/RCLJava.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public static Context createContext() {
217217
* structure.
218218
*/
219219
public static Node createNode(final String nodeName) {
220-
return createNode(nodeName, "", RCLJava.getDefaultContext());
220+
return createNode(nodeName, "", RCLJava.getDefaultContext(), false);
221221
}
222222

223223
/**
@@ -229,8 +229,12 @@ public static Node createNode(final String nodeName) {
229229
* structure.
230230
*/
231231
public static Node createNode(final String nodeName, final String namespace, final Context context) {
232+
return createNode(nodeName, namespace, context, false);
233+
}
234+
235+
public static Node createNode(final String nodeName, final String namespace, final Context context, final boolean allowUndeclaredParameters) {
232236
long nodeHandle = nativeCreateNodeHandle(nodeName, namespace, context.getHandle());
233-
Node node = new NodeImpl(nodeHandle, nodeName, context);
237+
Node node = new NodeImpl(nodeHandle, nodeName, context, allowUndeclaredParameters);
234238
nodes.add(node);
235239
return node;
236240
}

0 commit comments

Comments
 (0)