Skip to content

Commit 598f9e7

Browse files
committed
Update rcljava for Dashing (#75)
* Update API for getting rcl error string Signed-off-by: Jacob Perron <[email protected]> * 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 <[email protected]> * Add implementation for Clock Signed-off-by: Jacob Perron <[email protected]> * 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 <[email protected]> * Avoid hiding errors when cleaning up init options Signed-off-by: Jacob Perron <[email protected]> * Disable tests Signed-off-by: Jacob Perron <[email protected]> * Fix typos in JNI library files Signed-off-by: Jacob Perron <[email protected]> * Fix native node method signature Signed-off-by: Jacob Perron <[email protected]> * Populate missing QoS settings with defaults Otherwise we run into a runtime error about Fast-RTPS not supporting liveliness. Signed-off-by: Jacob Perron <[email protected]> * Fix issues with Clock class * Load with JNIUtils * Rename native create method for consistency * Fix bug in native implementation Signed-off-by: Jacob Perron <[email protected]> * Enable linter tests Signed-off-by: Jacob Perron <[email protected]> * Fix lint errors Signed-off-by: Jacob Perron <[email protected]> * 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 <[email protected]> * Fix NodeTest Signed-off-by: Jacob Perron <[email protected]> * 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 <[email protected]>
1 parent a5a112e commit 598f9e7

31 files changed

+860
-307
lines changed

rcljava/CMakeLists.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ set(${PROJECT_NAME}_jni_sources
5757
"src/main/cpp/org_ros2_rcljava_RCLJava.cpp"
5858
"src/main/cpp/org_ros2_rcljava_Time.cpp"
5959
"src/main/cpp/org_ros2_rcljava_client_ClientImpl.cpp"
60+
"src/main/cpp/org_ros2_rcljava_contexts_ContextImpl.cpp"
6061
"src/main/cpp/org_ros2_rcljava_executors_BaseExecutor.cpp"
6162
"src/main/cpp/org_ros2_rcljava_node_NodeImpl.cpp"
6263
"src/main/cpp/org_ros2_rcljava_publisher_PublisherImpl.cpp"
6364
"src/main/cpp/org_ros2_rcljava_service_ServiceImpl.cpp"
6465
"src/main/cpp/org_ros2_rcljava_subscription_SubscriptionImpl.cpp"
66+
"src/main/cpp/org_ros2_rcljava_time_Clock.cpp"
6567
"src/main/cpp/org_ros2_rcljava_timer_WallTimerImpl.cpp"
6668
)
6769

@@ -118,6 +120,8 @@ set(${PROJECT_NAME}_sources
118120
"src/main/java/org/ros2/rcljava/client/ClientImpl.java"
119121
"src/main/java/org/ros2/rcljava/concurrent/Callback.java"
120122
"src/main/java/org/ros2/rcljava/concurrent/RCLFuture.java"
123+
"src/main/java/org/ros2/rcljava/contexts/Context.java"
124+
"src/main/java/org/ros2/rcljava/contexts/ContextImpl.java"
121125
"src/main/java/org/ros2/rcljava/consumers/BiConsumer.java"
122126
"src/main/java/org/ros2/rcljava/consumers/Consumer.java"
123127
"src/main/java/org/ros2/rcljava/consumers/TriConsumer.java"
@@ -151,6 +155,7 @@ set(${PROJECT_NAME}_sources
151155
"src/main/java/org/ros2/rcljava/service/ServiceImpl.java"
152156
"src/main/java/org/ros2/rcljava/subscription/Subscription.java"
153157
"src/main/java/org/ros2/rcljava/subscription/SubscriptionImpl.java"
158+
"src/main/java/org/ros2/rcljava/time/Clock.java"
154159
"src/main/java/org/ros2/rcljava/time/ClockType.java"
155160
"src/main/java/org/ros2/rcljava/timer/Timer.java"
156161
"src/main/java/org/ros2/rcljava/timer/WallTimer.java"
@@ -194,12 +199,15 @@ if(BUILD_TESTING)
194199
"srv/AddTwoInts.srv"
195200
)
196201

202+
rosidl_generator_java_get_typesupports(_java_type_supports)
203+
197204
rosidl_generate_interfaces(${PROJECT_NAME}
198205
${${PROJECT_NAME}_message_files}
199206
${${PROJECT_NAME}_service_files}
200207
DEPENDENCIES
201208
builtin_interfaces
202209
rcl_interfaces
210+
${_java_type_supports}
203211
SKIP_INSTALL
204212
)
205213

@@ -214,10 +222,10 @@ if(BUILD_TESTING)
214222
set(${PROJECT_NAME}_test_sources
215223
"src/test/java/org/ros2/rcljava/RCLJavaTest.java"
216224
"src/test/java/org/ros2/rcljava/TimeTest.java"
217-
"src/test/java/org/ros2/rcljava/client/ClientTest.java"
225+
# "src/test/java/org/ros2/rcljava/client/ClientTest.java"
218226
"src/test/java/org/ros2/rcljava/node/NodeTest.java"
219-
"src/test/java/org/ros2/rcljava/parameters/AsyncParametersClientTest.java"
220-
"src/test/java/org/ros2/rcljava/parameters/SyncParametersClientTest.java"
227+
# "src/test/java/org/ros2/rcljava/parameters/AsyncParametersClientTest.java"
228+
# "src/test/java/org/ros2/rcljava/parameters/SyncParametersClientTest.java"
221229
"src/test/java/org/ros2/rcljava/publisher/PublisherTest.java"
222230
"src/test/java/org/ros2/rcljava/subscription/SubscriptionTest.java"
223231
"src/test/java/org/ros2/rcljava/timer/TimerTest.java"
@@ -226,9 +234,9 @@ if(BUILD_TESTING)
226234
set(${PROJECT_NAME}_testsuites
227235
"org.ros2.rcljava.RCLJavaTest"
228236
"org.ros2.rcljava.TimeTest"
229-
"org.ros2.rcljava.client.ClientTest"
237+
# "org.ros2.rcljava.client.ClientTest"
230238
"org.ros2.rcljava.node.NodeTest"
231-
"org.ros2.rcljava.parameters.SyncParametersClientTest"
239+
# "org.ros2.rcljava.parameters.SyncParametersClientTest"
232240
"org.ros2.rcljava.publisher.PublisherTest"
233241
"org.ros2.rcljava.subscription.SubscriptionTest"
234242
"org.ros2.rcljava.timer.TimerTest"

rcljava/include/org_ros2_rcljava_RCLJava.h

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,55 +22,45 @@ extern "C" {
2222
#endif
2323
/*
2424
* Class: org_ros2_rcljava_RCLJava
25-
* Method: nativeRCLJavaInit
26-
* Signature: ()V
25+
* Method: nativeCreateContextHandle
26+
* Signature: ()J
2727
*/
28-
JNIEXPORT void JNICALL Java_org_ros2_rcljava_RCLJava_nativeRCLJavaInit(JNIEnv *, jclass);
28+
JNIEXPORT jlong
29+
JNICALL Java_org_ros2_rcljava_RCLJava_nativeCreateContextHandle(JNIEnv *, jclass);
2930

3031
/*
3132
* Class: org_ros2_rcljava_RCLJava
3233
* Method: nativeCreateNodeHandle
33-
* Signature: (Ljava/lang/String;Ljava/lang/String;)J
34+
* Signature: (Ljava/lang/String;Ljava/lang/String;J)J
3435
*/
35-
JNIEXPORT jlong JNICALL
36-
Java_org_ros2_rcljava_RCLJava_nativeCreateNodeHandle(JNIEnv *, jclass, jstring, jstring);
36+
JNIEXPORT jlong
37+
JNICALL Java_org_ros2_rcljava_RCLJava_nativeCreateNodeHandle(
38+
JNIEnv *, jclass, jstring, jstring, jlong);
3739

3840
/*
3941
* Class: org_ros2_rcljava_RCLJava
4042
* Method: nativeGetRMWIdentifier
4143
* Signature: ()Ljava/lang/String;
4244
*/
43-
JNIEXPORT jstring JNICALL Java_org_ros2_rcljava_RCLJava_nativeGetRMWIdentifier(JNIEnv *, jclass);
44-
45-
/*
46-
* Class: org_ros2_rcljava_RCLJava
47-
* Method: nativeOk
48-
* Signature: ()Z
49-
*/
50-
JNIEXPORT jboolean JNICALL Java_org_ros2_rcljava_RCLJava_nativeOk(JNIEnv *, jclass);
51-
52-
/*
53-
* Class: org_ros2_rcljava_RCLJava
54-
* Method: nativeShutdown
55-
* Signature: ()V
56-
*/
57-
JNIEXPORT void JNICALL Java_org_ros2_rcljava_RCLJava_nativeShutdown(JNIEnv *, jclass);
45+
JNIEXPORT jstring
46+
JNICALL Java_org_ros2_rcljava_RCLJava_nativeGetRMWIdentifier(JNIEnv *, jclass);
5847

5948
/*
6049
* Class: org_ros2_rcljava_RCLJava
6150
* Method: nativeConvertQoSProfileToHandle
6251
* Signature: (IIIIZ)J
6352
*/
64-
JNIEXPORT jlong JNICALL Java_org_ros2_rcljava_RCLJava_nativeConvertQoSProfileToHandle(
53+
JNIEXPORT jlong
54+
JNICALL Java_org_ros2_rcljava_RCLJava_nativeConvertQoSProfileToHandle(
6555
JNIEnv *, jclass, jint, jint, jint, jint, jboolean);
6656

6757
/*
6858
* Class: org_ros2_rcljava_RCLJava
6959
* Method: nativeDisposeQoSProfile
7060
* Signature: (J)V
7161
*/
72-
JNIEXPORT void JNICALL
73-
Java_org_ros2_rcljava_RCLJava_nativeDisposeQoSProfile(JNIEnv *, jclass, jlong);
62+
JNIEXPORT void
63+
JNICALL Java_org_ros2_rcljava_RCLJava_nativeDisposeQoSProfile(JNIEnv *, jclass, jlong);
7464

7565
#ifdef __cplusplus
7666
}

rcljava/include/org_ros2_rcljava_Time.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@ extern "C" {
2525
* Method: nativeRCLSystemTimeNow
2626
* Signature: ()J
2727
*/
28-
JNIEXPORT jlong JNICALL Java_org_ros2_rcljava_Time_nativeRCLSystemTimeNow(JNIEnv *, jclass);
28+
JNIEXPORT jlong
29+
JNICALL Java_org_ros2_rcljava_Time_nativeRCLSystemTimeNow(JNIEnv *, jclass);
2930

3031
/*
3132
* Class: org_ros2_rcljava_Time
3233
* Method: nativeRCLSteadyTimeNow
3334
* Signature: ()J
3435
*/
35-
JNIEXPORT jlong JNICALL Java_org_ros2_rcljava_Time_nativeRCLSteadyTimeNow(JNIEnv *, jclass);
36+
JNIEXPORT jlong
37+
JNICALL Java_org_ros2_rcljava_Time_nativeRCLSteadyTimeNow(JNIEnv *, jclass);
3638

3739
#ifdef __cplusplus
3840
}

rcljava/include/org_ros2_rcljava_client_ClientImpl.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ extern "C" {
2525
* Method: nativeSendClientRequest
2626
* Signature: (JJJJJLorg/ros2/rcljava/interfaces/MessageDefinition;)V
2727
*/
28-
JNIEXPORT void JNICALL Java_org_ros2_rcljava_client_ClientImpl_nativeSendClientRequest(
28+
JNIEXPORT void
29+
JNICALL Java_org_ros2_rcljava_client_ClientImpl_nativeSendClientRequest(
2930
JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, jobject);
3031

3132
/*
3233
* Class: org_ros2_rcljava_client_ClientImpl
3334
* Method: nativeDispose
3435
* Signature: (JJ)V
3536
*/
36-
JNIEXPORT void JNICALL
37-
Java_org_ros2_rcljava_client_ClientImpl_nativeDispose(JNIEnv *, jclass, jlong, jlong);
37+
JNIEXPORT void
38+
JNICALL Java_org_ros2_rcljava_client_ClientImpl_nativeDispose(JNIEnv *, jclass, jlong, jlong);
3839

3940
#ifdef __cplusplus
4041
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2019 Open Source Robotics Foundation, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <jni.h>
16+
/* Header for class org_ros2_rcljava_contexts_ContextImpl */
17+
18+
#ifndef ORG_ROS2_RCLJAVA_CONTEXTS_CONTEXTIMPL_H_
19+
#define ORG_ROS2_RCLJAVA_CONTEXTS_CONTEXTIMPL_H_
20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
24+
/*
25+
* Class: org_ros2_rcljava_contexts_ContextImpl
26+
* Method: nativeInit
27+
* Signature: (J)V
28+
*/
29+
JNIEXPORT void
30+
JNICALL Java_org_ros2_rcljava_contexts_ContextImpl_nativeInit(JNIEnv *, jclass, jlong);
31+
32+
/*
33+
* Class: org_ros2_rcljava_contexts_ContextImpl
34+
* Method: nativeShutdown
35+
* Signature: (J)V
36+
*/
37+
JNIEXPORT void
38+
JNICALL Java_org_ros2_rcljava_contexts_ContextImpl_nativeShutdown(JNIEnv *, jclass, jlong);
39+
40+
/*
41+
* Class: org_ros2_rcljava_contexts_ContextImpl
42+
* Method: nativeIsValid
43+
* Signature: (J)Z
44+
*/
45+
JNIEXPORT jboolean
46+
JNICALL Java_org_ros2_rcljava_contexts_ContextImpl_nativeIsValid(JNIEnv *, jclass, jlong);
47+
48+
/*
49+
* Class: org_ros2_rcljava_contexts_ContextImpl
50+
* Method: nativeDispose
51+
* Signature: (J)V
52+
*/
53+
JNIEXPORT void
54+
JNICALL Java_org_ros2_rcljava_contexts_ContextImpl_nativeDispose(JNIEnv *, jclass, jlong);
55+
56+
#ifdef __cplusplus
57+
}
58+
#endif
59+
#endif // ORG_ROS2_RCLJAVA_CONTEXTS_CONTEXTIMPL_H_

0 commit comments

Comments
 (0)