diff --git a/.travis.yml b/.travis.yml index c315df3..1761059 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,7 +47,6 @@ matrix: env: - PYTHON_PATH="/usr/local/opt/python3/bin/python3.6" - TRAVIS_OS_NAME="osx" - - PKG_EXCLUDE="$PKG_EXCLUDE console_bridge orocos_kdl class_loader rosidl_generator_py pendulum_msgs rttest rclcpp dummy_map_server tf2 tf2_msgs tf2_ros tf2_eigen urdfdom_headers urdfdom urdf kdl_parser robot_state_publisher dummy_robot_bringup common_interfaces test_msgs dummy_sensors image_geometry sros2 test_security tf2_geometry_msgs nav_msgs actionlib_msgs diagnostic_msgs rcljava_utils rcl_lifecycle" osx_image: xcode9.1 allow_failures: - env: DOCKER_DIST="debian-stable" diff --git a/ament_cmake_export_jars/package.xml b/ament_cmake_export_jars/package.xml index 6210f24..3d38ff6 100644 --- a/ament_cmake_export_jars/package.xml +++ b/ament_cmake_export_jars/package.xml @@ -3,7 +3,7 @@ ament_cmake_export_jars - 0.0.0 + 0.4.0 The ability to export Java archives to downstream packages in the ament buildsystem in CMake. Esteve Fernandez Apache License 2.0 diff --git a/rcljava/include/rcljava/org_ros2_rcljava_node_service_NativeClient.hpp b/rcljava/include/rcljava/org_ros2_rcljava_node_service_NativeClient.hpp index e1cc576..0203725 100644 --- a/rcljava/include/rcljava/org_ros2_rcljava_node_service_NativeClient.hpp +++ b/rcljava/include/rcljava/org_ros2_rcljava_node_service_NativeClient.hpp @@ -38,11 +38,11 @@ JNIEXPORT jlong JNICALL /* * Class: org_ros2_rcljava_node_service_NativeClient * Method: nativeSendClientRequest - * Signature: (JJJJLjava/lang/Object;)V + * Signature: (JJJLjava/lang/Object;)J */ -JNIEXPORT void JNICALL +JNIEXPORT jlong JNICALL Java_org_ros2_rcljava_node_service_NativeClient_nativeSendClientRequest - (JNIEnv *, jclass, jlong, jlong, jlong, jlong, jobject); + (JNIEnv *, jclass, jlong, jlong, jlong, jobject); /* * Class: org_ros2_rcljava_node_service_NativeClient diff --git a/rcljava/package.xml b/rcljava/package.xml index 1d53e64..4692ab8 100644 --- a/rcljava/package.xml +++ b/rcljava/package.xml @@ -2,7 +2,7 @@ rcljava - 0.0.2 + 0.4.0 Package containing the Java client. Mickael Gaillard Apache License 2.0 diff --git a/rcljava/src/main/cpp/org_ros2_rcljava_node_NativeNode.cpp b/rcljava/src/main/cpp/org_ros2_rcljava_node_NativeNode.cpp index d7c8a49..aac515e 100644 --- a/rcljava/src/main/cpp/org_ros2_rcljava_node_NativeNode.cpp +++ b/rcljava/src/main/cpp/org_ros2_rcljava_node_NativeNode.cpp @@ -81,7 +81,6 @@ Java_org_ros2_rcljava_node_NativeNode_nativeDispose( rcl_node_t * node = handle2Instance(jnode_handle); rcl_ret_t ret = rcl_node_fini(node); - free(node); if (ret != RCL_RET_OK) { std::string message("Failed finish node: " + std::string(rcl_get_error_string_safe())); diff --git a/rcljava/src/main/cpp/org_ros2_rcljava_node_service_NativeClient.cpp b/rcljava/src/main/cpp/org_ros2_rcljava_node_service_NativeClient.cpp index 925164d..edfe017 100644 --- a/rcljava/src/main/cpp/org_ros2_rcljava_node_service_NativeClient.cpp +++ b/rcljava/src/main/cpp/org_ros2_rcljava_node_service_NativeClient.cpp @@ -88,12 +88,11 @@ Java_org_ros2_rcljava_node_service_NativeClient_nativeCreateClientHandle( /* * nativeSendClientRequest */ -JNIEXPORT void JNICALL +JNIEXPORT jlong JNICALL Java_org_ros2_rcljava_node_service_NativeClient_nativeSendClientRequest( JNIEnv * env, jclass, jlong client_handle, - jlong sequence_number, jlong jrequest_from_java_converter_handle, jlong jrequest_to_java_converter_handle, jobject jrequest_msg) @@ -109,8 +108,9 @@ Java_org_ros2_rcljava_node_service_NativeClient_nativeSendClientRequest( reinterpret_cast(jrequest_from_java_converter_handle); void * request_msg = convert_from_java(jrequest_msg, nullptr); + int64_t seq_number; - rcl_ret_t ret = rcl_send_request(client, request_msg, &sequence_number); + rcl_ret_t ret = rcl_send_request(client, request_msg, &seq_number); if (ret != RCL_RET_OK) { std::string message("Failed to send request from a client: " + @@ -118,6 +118,8 @@ Java_org_ros2_rcljava_node_service_NativeClient_nativeSendClientRequest( rcl_reset_error(); throwException(env, message); } + + return seq_number; } /* @@ -134,7 +136,6 @@ Java_org_ros2_rcljava_node_service_NativeClient_nativeDispose( rcl_client_t * client = handle2Instance(jclient_handle); rcl_ret_t ret = rcl_client_fini(client, node); - free(client); if (ret != RCL_RET_OK) { std::string message("Failed to destroy client: " + std::string(rcl_get_error_string_safe())); diff --git a/rcljava/src/main/cpp/org_ros2_rcljava_node_service_NativeService.cpp b/rcljava/src/main/cpp/org_ros2_rcljava_node_service_NativeService.cpp index c443a70..8ac0c02 100644 --- a/rcljava/src/main/cpp/org_ros2_rcljava_node_service_NativeService.cpp +++ b/rcljava/src/main/cpp/org_ros2_rcljava_node_service_NativeService.cpp @@ -86,7 +86,6 @@ Java_org_ros2_rcljava_node_service_NativeService_nativeDispose( rcl_service_t * service = handle2Instance(jservice_handle); rcl_ret_t ret = rcl_service_fini(service, node); - free(service); if (ret != RCL_RET_OK) { std::string message("Failed to destroy service: " + std::string(rcl_get_error_string_safe())); diff --git a/rcljava/src/main/cpp/org_ros2_rcljava_node_topic_NativePublisher.cpp b/rcljava/src/main/cpp/org_ros2_rcljava_node_topic_NativePublisher.cpp index d8a67a0..04a51ee 100644 --- a/rcljava/src/main/cpp/org_ros2_rcljava_node_topic_NativePublisher.cpp +++ b/rcljava/src/main/cpp/org_ros2_rcljava_node_topic_NativePublisher.cpp @@ -114,7 +114,6 @@ Java_org_ros2_rcljava_node_topic_NativePublisher_nativeDispose( rcl_publisher_t * publisher = handle2Instance(jpublisher_handle); rcl_ret_t ret = rcl_publisher_fini(publisher, node); - free(publisher); if (ret != RCL_RET_OK) { std::string message("Failed to destroy publisher: " + std::string(rcl_get_error_string_safe())); diff --git a/rcljava/src/main/cpp/org_ros2_rcljava_node_topic_NativeSubscription.cpp b/rcljava/src/main/cpp/org_ros2_rcljava_node_topic_NativeSubscription.cpp index 80f4ac1..61590d7 100644 --- a/rcljava/src/main/cpp/org_ros2_rcljava_node_topic_NativeSubscription.cpp +++ b/rcljava/src/main/cpp/org_ros2_rcljava_node_topic_NativeSubscription.cpp @@ -87,7 +87,6 @@ Java_org_ros2_rcljava_node_topic_NativeSubscription_nativeDispose( rcl_subscription_t * subscription = handle2Instance(jsubscription_handle); rcl_ret_t ret = rcl_subscription_fini(subscription, node); - free(subscription); if (ret != RCL_RET_OK) { std::string message("Failed to destroy subscription: " + std::string(rcl_get_error_string_safe())); diff --git a/rcljava/src/main/java/org/ros2/rcljava/RCLJava.java b/rcljava/src/main/java/org/ros2/rcljava/RCLJava.java index b8f631a..1e7cc6c 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/RCLJava.java +++ b/rcljava/src/main/java/org/ros2/rcljava/RCLJava.java @@ -43,6 +43,9 @@ public final class RCLJava { private static final Logger logger = LoggerFactory.getLogger(RCLJava.class); + private static final String DISPLAY_SEPARATOR = + "==============================================================="; + /** * The identifier of the currently active RMW implementation. */ @@ -54,6 +57,8 @@ public final class RCLJava { */ private static volatile boolean initialized = false; + private static String libExtention = ".unknow"; + private static String[] arguments; /** @@ -129,16 +134,26 @@ private static String getRmwImplementationSuffix(final String rmwImplementation) } private static void displayContext() { + RCLJava.logger.debug(DISPLAY_SEPARATOR); + // https://docs.oracle.com/javase/7/docs/api/java/lang/System.html#getProperties + // http://lopica.sourceforge.net/os.html final String libpath = System.getProperty("java.library.path"); final String arch = System.getProperty("os.arch"); final String os = System.getProperty("os.name"); + final String osVer = System.getProperty("os.version"); final String pidAndHost = ManagementFactory.getRuntimeMXBean().getName(); final String pid = pidAndHost.substring(0, pidAndHost.indexOf('@')); // For JAVA9 : long pid = ProcessHandle.current().getPid(); + final String user = System.getProperty("user.name"); + final String pathSeparator = System.getProperty("path.separator"); + // Java Value RCLJava.logger.debug(String.format("Process ID : %s", pid)); + RCLJava.logger.debug(String.format("Process User : %s", user)); + + RCLJava.logger.debug(String.format("Java Home : %s", System.getProperty("java.home"))); RCLJava.logger.debug(String.format("Java JVM : %s %s %s", System.getProperty("java.vm.vendor"), System.getProperty("java.vm.name"), @@ -151,9 +166,24 @@ private static void displayContext() { System.getProperty("java.specification.version"))); // Native Value - RCLJava.logger.debug(String.format("Native Library OS : %s", os)); + RCLJava.logger.debug(String.format("Native Library OS : %s %s", os, osVer)); RCLJava.logger.debug(String.format("Native Library Archi : %s", arch)); - RCLJava.logger.debug(String.format("Native Library path : \n\t%s", libpath.replace(":", "\n\t"))); + RCLJava.logger.debug(String.format("Native Library path : %n\t%s", libpath.replace(pathSeparator, System.lineSeparator() + "\t"))); + RCLJava.logger.debug(DISPLAY_SEPARATOR); + } + + private static void displayReport() { + RCLJava.logger.debug(DISPLAY_SEPARATOR); + + // List loaded libraries. + final String[] list = NativeUtils.getLoadedLibraries(RCLJava.class.getClassLoader()); + final StringBuilder msgLog = new StringBuilder(); + for (final String key : list) { + msgLog.append(key); + msgLog.append(System.lineSeparator()); + } + RCLJava.logger.debug(String.format("Native libraries Loaded: %n", msgLog.toString())); + RCLJava.logger.debug(DISPLAY_SEPARATOR); } /** @@ -336,7 +366,7 @@ public static void setRMWImplementation(final String rmwImplementation) if (rmwImplementation != null && !rmwImplementation.isEmpty()) { if (!rmwImplementation.equals(RCLJava.rmwImplementation)) { final String file = "rcljava"+ RCLJava.getRmwImplementationSuffix(rmwImplementation); - RCLJava.logger.debug("Load native RMW file : lib" + file + ".so"); + RCLJava.logger.debug("Load native RMW file : " + System.mapLibraryName(file)); try { System.loadLibrary(file); @@ -363,7 +393,7 @@ public static void setRMWImplementation(final String rmwImplementation) */ @SuppressWarnings("PMD.AvoidUsingNativeCode") public static void loadLibrary(final String name) { - RCLJava.logger.debug("Load native file : lib" + name + ".so"); + RCLJava.logger.debug("Load native file :" + System.mapLibraryName(name)); RCLJava.lockAndCheckInitialized(); try { @@ -392,20 +422,12 @@ private static void autoLoadRmw() { } protected static void shutdownHook() { - RCLJava.shutdown(true); - RCLJava.logger.debug("Final Shutdown..."); - // List loaded libraries. - final String[] list = NativeUtils.getLoadedLibraries(RCLJava.class.getClassLoader()); - final StringBuilder msgLog = new StringBuilder(); - for (final String key : list) { - msgLog.append(key); - msgLog.append('\n'); - } - RCLJava.logger.debug("Native libraries Loaded: \n" + msgLog.toString()); - + RCLJava.shutdown(true); GraphName.dispose(); + + RCLJava.displayReport(); } private static void lockAndCheckInitialized() { diff --git a/rcljava/src/main/java/org/ros2/rcljava/executor/MultiThreadedExecutor.java b/rcljava/src/main/java/org/ros2/rcljava/executor/MultiThreadedExecutor.java index e12ca9e..4c0493e 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/executor/MultiThreadedExecutor.java +++ b/rcljava/src/main/java/org/ros2/rcljava/executor/MultiThreadedExecutor.java @@ -58,7 +58,6 @@ public MultiThreadedExecutor(final int numberOfThreads) { * Pool-multiple threaded implementation of spin. * This function will block until work comes in, execute it, and keep blocking. * It will only be interrupt by a CTRL-C (managed by the global signal handler). - * @throws InterruptedException */ @Override public void spin() { diff --git a/rcljava/src/main/java/org/ros2/rcljava/executor/NativeExecutor.java b/rcljava/src/main/java/org/ros2/rcljava/executor/NativeExecutor.java index 2e0eda7..c60609f 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/executor/NativeExecutor.java +++ b/rcljava/src/main/java/org/ros2/rcljava/executor/NativeExecutor.java @@ -254,7 +254,7 @@ private static void executeService(final Service service) { } if (requestMessage != null && responseMessage != null) { - final RMWRequestId rmwRequestId = (RMWRequestId) NativeExecutor.nativeTakeRequest( + final RMWRequestId rmwRequestId = NativeExecutor.nativeTakeRequest( nativeService.getServiceHandle(), nativeService.getRequest().getFromJavaConverterHandle(), nativeService.getRequest().getToJavaConverterHandle(), @@ -301,7 +301,7 @@ public static native void nativeWaitSetInit( public static native void nativeWaitSetFini(long waitSetHandle); public static native Message nativeTake(long SubscriptionHandle, Class msgType); - public static native Object nativeTakeRequest( + public static native RMWRequestId nativeTakeRequest( long serviceHandle, long requestFromJavaConverterHandle, long requestToJavaConverterHandle, diff --git a/rcljava/src/main/java/org/ros2/rcljava/namespace/GraphName.java b/rcljava/src/main/java/org/ros2/rcljava/namespace/GraphName.java index 1e107f4..839ce14 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/namespace/GraphName.java +++ b/rcljava/src/main/java/org/ros2/rcljava/namespace/GraphName.java @@ -116,7 +116,7 @@ public static String getFullName(final String nameSpace, final String nodeName) /** * * - * + *
* * * diff --git a/rcljava/src/main/java/org/ros2/rcljava/node/NativeNode.java b/rcljava/src/main/java/org/ros2/rcljava/node/NativeNode.java index 3e9763e..9d8b4c1 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/node/NativeNode.java +++ b/rcljava/src/main/java/org/ros2/rcljava/node/NativeNode.java @@ -248,11 +248,6 @@ public WallTimer createWallTimer( * @param serviceName The service to subscribe on. * @param qosProfile The quality of service profile to pass on to the rmw implementation. * @return Client instance of the service. - * @throws SecurityException - * @throws NoSuchFieldException - * @throws IllegalAccessException - * @throws IllegalArgumentException - * @throws NoSuchMethodException */ @Override public Client createClient( @@ -288,11 +283,6 @@ public Client createClient( * @param callback The user-defined callback function. * @param qosProfile The quality of service profile to pass on to the rmw implementation. * @return Service instance of the service. - * @throws SecurityException - * @throws NoSuchFieldException - * @throws IllegalAccessException - * @throws IllegalArgumentException - * @throws NoSuchMethodException */ @Override public Service createService( @@ -415,7 +405,7 @@ public int countSubscribers(final String topic) { /** * TODO REMOVE !!! * Return the rcl_node_t node handle (non-const version). - * @return + * @return Node handler. */ public long getNodeHandle() { return this.nodeHandle; diff --git a/rcljava/src/main/java/org/ros2/rcljava/node/internal/NodeGraph.java b/rcljava/src/main/java/org/ros2/rcljava/node/internal/NodeGraph.java index 8457cfc..65cdfde 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/node/internal/NodeGraph.java +++ b/rcljava/src/main/java/org/ros2/rcljava/node/internal/NodeGraph.java @@ -25,13 +25,13 @@ public interface NodeGraph { /** * This is typically only used by the rclcpp::graph_listener::GraphListener. - * Return the number of on loan graph events, see get_graph_event(). + * @return The number of on loan graph events, see get_graph_event(). */ int countGraphUsers(); /** * - * @return + * @return Map of Services with list of type. */ Map> getServiceNamesAndTypes(); @@ -60,13 +60,13 @@ public interface NodeGraph { List getNodeNames(); /** - * @param topic + * @param topic Topic name filter. * @return Return the number of publishers that are advertised on a given topic. */ int countPublishers(final String topic); /** - * @param topic + * @param topic Topic name filter. * @return Return the number of subscribers who have created a subscription for a given topic. */ int countSubscribers(final String topic); @@ -87,7 +87,7 @@ public interface NodeGraph { * This is typically only used by the rclcpp::graph_listener::GraphListener. * * return Return a graph event, which will be set anytime a graph change occurs. - * @throws RCLBaseError (a child of that exception) when an rcl error occurs + * throws RCLBaseError (a child of that exception) when an rcl error occurs */ void notifyGraphChange(); @@ -108,9 +108,12 @@ public interface NodeGraph { * * The given Event must be acquire through the get_graph_event() method. * - * @throws InvalidEventError if the given event is nullptr - * @throws EventNotRegisteredError if the given event was not acquired with + * throws InvalidEventError if the given event is nullptr + * throws EventNotRegisteredError if the given event was not acquired with * get_graph_event(). + * + * @param event Event. + * @param timeout Timeout. */ void waitForGraphChange(final Object event, final int timeout); diff --git a/rcljava/src/main/java/org/ros2/rcljava/node/internal/NodeParameters.java b/rcljava/src/main/java/org/ros2/rcljava/node/internal/NodeParameters.java index 1fd5afe..63dcace 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/node/internal/NodeParameters.java +++ b/rcljava/src/main/java/org/ros2/rcljava/node/internal/NodeParameters.java @@ -49,6 +49,7 @@ public interface NodeParameters { /** * Define parameter if not set. * + * @param Generic. * @param name of parameter. * @param value of the parameter. */ @@ -104,30 +105,30 @@ public interface NodeParameters { /** * Get description of parameters filtered by name. * - * @param names + * @param names List of names filter. * @return List of Parameter Descriptor. */ List describeParameters(final List names); /** * - * @param names + * @param names List of names filter. * @return Types list of parameter. */ List> getParameterTypes(final List names); /** * - * @param names - * @return + * @param names List of names filter. + * @return Types list of parameter. */ List getParametersTypes(final List names); /** * - * @param names - * @param depth - * @return ParameterResult + * @param names List of names filter. + * @param depth Depth of filter. + * @return List of parameters result. */ ListParametersResult listParameters(final List names, final int depth); @@ -135,6 +136,7 @@ public interface NodeParameters { * Register the callback for parameter changes. Repeated invocations of this * function will overwrite previous callbacks * + * @param Message. * @param callback * defined callback function, It is expected to atomically set * parameters. diff --git a/rcljava/src/main/java/org/ros2/rcljava/node/parameter/ParameterCallback.java b/rcljava/src/main/java/org/ros2/rcljava/node/parameter/ParameterCallback.java index 0705898..8572b3a 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/node/parameter/ParameterCallback.java +++ b/rcljava/src/main/java/org/ros2/rcljava/node/parameter/ParameterCallback.java @@ -27,8 +27,8 @@ public interface ParameterCallback { /** * - * @param config - * @return + * @param configs List of parameters. + * @return Parameters result. */ - SetParametersResult onParamChange(final List> config); + SetParametersResult onParamChange(final List> configs); } diff --git a/rcljava/src/main/java/org/ros2/rcljava/node/parameter/ParameterEventCallback.java b/rcljava/src/main/java/org/ros2/rcljava/node/parameter/ParameterEventCallback.java index f5f8c3b..22490a9 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/node/parameter/ParameterEventCallback.java +++ b/rcljava/src/main/java/org/ros2/rcljava/node/parameter/ParameterEventCallback.java @@ -15,6 +15,8 @@ package org.ros2.rcljava.node.parameter; +import rcl_interfaces.msg.ParameterEvent; + /** * Parameter Event Consumer. * @@ -23,7 +25,7 @@ public interface ParameterEventCallback { /** * - * @param event + * @param event Parameter event. */ - void onEvent(final rcl_interfaces.msg.ParameterEvent event); + void onEvent(final ParameterEvent event); } diff --git a/rcljava/src/main/java/org/ros2/rcljava/node/service/BaseClient.java b/rcljava/src/main/java/org/ros2/rcljava/node/service/BaseClient.java index 16a57d8..97ba011 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/node/service/BaseClient.java +++ b/rcljava/src/main/java/org/ros2/rcljava/node/service/BaseClient.java @@ -45,8 +45,6 @@ public abstract class BaseClient implements Client private final Class requestType; private final Class responseType; - private long sequenceNumber; - /** * * @param ownerNode @@ -114,7 +112,7 @@ public void handleResponse(final RMWRequestId header,final V synchronized(pendingRequests) { final long sequenceNumber = header.sequenceNumber; @SuppressWarnings("unchecked") - final RCLFuture future = (RCLFuture) pendingRequests.remove(sequenceNumber); + final RCLFuture future = (RCLFuture) this.pendingRequests.remove(sequenceNumber); future.set(response); } } @@ -128,6 +126,7 @@ public boolean waitForService(final int i) { public Node getNode() { return this.ownerNode; } + /* (non-Javadoc) * @see org.ros2.rcljava.node.topic.Publisher#getQosProfile() */ @@ -136,14 +135,6 @@ public QoSProfile getQosProfile() { return this.qosProfile; } - public long getSequenceNumber() { - return this.sequenceNumber; - } - - public void incrementSequenceNumber() { - this.sequenceNumber++; - } - public Map> getPendingRequests() { return this.pendingRequests; } diff --git a/rcljava/src/main/java/org/ros2/rcljava/node/service/BaseService.java b/rcljava/src/main/java/org/ros2/rcljava/node/service/BaseService.java index 15b3dfb..43da5d7 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/node/service/BaseService.java +++ b/rcljava/src/main/java/org/ros2/rcljava/node/service/BaseService.java @@ -25,7 +25,7 @@ /** * This class is Service Server of RCLJava. * - * @param Service Type. + * param Service Type. */ public class BaseService implements Service { diff --git a/rcljava/src/main/java/org/ros2/rcljava/node/service/NativeClient.java b/rcljava/src/main/java/org/ros2/rcljava/node/service/NativeClient.java index 7f5314b..9fe57f0 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/node/service/NativeClient.java +++ b/rcljava/src/main/java/org/ros2/rcljava/node/service/NativeClient.java @@ -49,9 +49,8 @@ private static native long nativeCreateClientHandle( private static native void nativeDispose(long nodeHandle, long clientHandle); - private static native void nativeSendClientRequest( + private static native long nativeSendClientRequest( long clientHandle, - long sequenceNumber, long requestFromJavaConverterHandle, long requestToJavaConverterHandle, Object requestMessage); @@ -126,20 +125,19 @@ public NativeNode getNode() { @Override public Future sendRequest(final U request) { - synchronized(this.getPendingRequests()) { - this.incrementSequenceNumber(); + final RCLFuture future; - NativeClient.nativeSendClientRequest( + synchronized(this.getPendingRequests()) { + final Long sequenceNumber = NativeClient.nativeSendClientRequest( this.clientHandle, - this.getSequenceNumber(), this.request.getFromJavaConverterHandle(), this.request.getToJavaConverterHandle(), request); - final RCLFuture future = new RCLFuture(new WeakReference(this.getNode())); - getPendingRequests().put(this.getSequenceNumber(), future); - return future; - } + future = new RCLFuture(new WeakReference(this.getNode())); + this.getPendingRequests().put(sequenceNumber, future); + } + return future; } public long getClientHandle() { diff --git a/rcljava/src/main/java/org/ros2/rcljava/node/service/NativeService.java b/rcljava/src/main/java/org/ros2/rcljava/node/service/NativeService.java index 75589d1..e00bbf2 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/node/service/NativeService.java +++ b/rcljava/src/main/java/org/ros2/rcljava/node/service/NativeService.java @@ -27,7 +27,7 @@ /** * This class is Native(rcl) Service Server of RCLJava. * - * @param Service Type. + * param Service Type. */ public class NativeService extends BaseService { diff --git a/rcljava/src/main/java/org/ros2/rcljava/node/topic/NativePublisher.java b/rcljava/src/main/java/org/ros2/rcljava/node/topic/NativePublisher.java index de94f5c..4d0a223 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/node/topic/NativePublisher.java +++ b/rcljava/src/main/java/org/ros2/rcljava/node/topic/NativePublisher.java @@ -28,7 +28,7 @@ /** * This class serves as a bridge between ROS2's rcl_publisher_t and RCLJava. * A Publisher must be created via - * @{link Node#createPublisher(Class<T>, String)} + * {@link Node#createPublisher(Class<T>, String)} * * @param The type of the messages that this publisher will publish. */ diff --git a/rcljava/src/main/java/org/ros2/rcljava/node/topic/NativeSubscription.java b/rcljava/src/main/java/org/ros2/rcljava/node/topic/NativeSubscription.java index 29ceb5c..fea36af 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/node/topic/NativeSubscription.java +++ b/rcljava/src/main/java/org/ros2/rcljava/node/topic/NativeSubscription.java @@ -28,7 +28,7 @@ /** * This class serves as a bridge between ROS2's rcl_subscription_t and RCLJava. * A Subscription must be created via - * @{link Node#createSubscription(Class<T>, String, Consumer<T>)} + * {@link Node#createSubscription(Class<T>, String, Consumer<T>)} * * @param The type of the messages that this subscription will receive. */ @@ -62,7 +62,7 @@ private static native long nativeCreateSubscriptionHandle( * @param messageType The Class of the messages that this * subscription will receive. We need this because of Java's type erasure, * which doesn't allow us to use the generic parameter of - * @{link org.ros2.rcljava.Subscription} directly. + * {@link org.ros2.rcljava.Subscription} directly. * @param topicName The topic to which this subscription will be subscribed. * @param callback The callback function that will be triggered when a new * message is received. diff --git a/rcljava/src/main/java/org/ros2/rcljava/qos/QoSProfile.java b/rcljava/src/main/java/org/ros2/rcljava/qos/QoSProfile.java index 2dabb5b..2c667ff 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/qos/QoSProfile.java +++ b/rcljava/src/main/java/org/ros2/rcljava/qos/QoSProfile.java @@ -107,10 +107,10 @@ public class QoSProfile { /** * Constructor. - * @param history - * @param depth - * @param reliability - * @param durability + * @param history History + * @param depth Depth + * @param reliability Reliability + * @param durability Durability */ public QoSProfile(final History history, final int depth, final Reliability reliability, final Durability durability) { this.history = history; diff --git a/rcljava/src/main/java/org/ros2/rcljava/time/BaseWallTimer.java b/rcljava/src/main/java/org/ros2/rcljava/time/BaseWallTimer.java index a574e11..df9f99e 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/time/BaseWallTimer.java +++ b/rcljava/src/main/java/org/ros2/rcljava/time/BaseWallTimer.java @@ -36,9 +36,9 @@ public abstract class BaseWallTimer implements WallTimer { /** * - * @param nodeReference - * @param callback - * @param timerPeriodNS + * @param nodeReference Node. + * @param callback Call-back. + * @param timerPeriodNS Time period in nano-second. */ public BaseWallTimer( final WeakReference nodeReference, @@ -99,7 +99,7 @@ public long getTimerPeriodNS() { } /** - * @return + * @return Node. */ public Node getNode() { return this.nodeReference.get(); diff --git a/rcljava/src/main/java/org/ros2/rcljava/time/JavaWallTimer.java b/rcljava/src/main/java/org/ros2/rcljava/time/JavaWallTimer.java index f91741c..0d08ff6 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/time/JavaWallTimer.java +++ b/rcljava/src/main/java/org/ros2/rcljava/time/JavaWallTimer.java @@ -28,9 +28,9 @@ public class JavaWallTimer extends BaseWallTimer { /** * - * @param nodeReference - * @param callback - * @param timerPeriodNS + * @param nodeReference Node. + * @param callback Call-back. + * @param timerPeriodNS Time period in nano-second. */ public JavaWallTimer( final WeakReference nodeReference, diff --git a/rcljava/src/main/java/org/ros2/rcljava/time/NativeWallTimer.java b/rcljava/src/main/java/org/ros2/rcljava/time/NativeWallTimer.java index eb0410d..85b8bfd 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/time/NativeWallTimer.java +++ b/rcljava/src/main/java/org/ros2/rcljava/time/NativeWallTimer.java @@ -53,9 +53,9 @@ public class NativeWallTimer extends BaseWallTimer { /** * Constructor. * - * @param nodeReference - * @param callback - * @param timerPeriodNS + * @param nodeReference Node. + * @param callback Call-back. + * @param timerPeriodNS Time period in nano-second. */ public NativeWallTimer( final WeakReference nodeReference, @@ -143,7 +143,7 @@ public long getTimerPeriodNS() { } /** - * @return + * @return Handle. */ public long getHandle() { return this.wallTimerHandle; diff --git a/rcljava_common/package.xml b/rcljava_common/package.xml index 0e2f537..aa85398 100644 --- a/rcljava_common/package.xml +++ b/rcljava_common/package.xml @@ -2,7 +2,7 @@ rcljava_common - 0.0.2 + 0.4.0 Common code for ROS2 Java projects. Mickael Gaillard Apache License 2.0 diff --git a/rosidl_generator_java/package.xml b/rosidl_generator_java/package.xml index 7465d70..fef1d57 100644 --- a/rosidl_generator_java/package.xml +++ b/rosidl_generator_java/package.xml @@ -2,7 +2,7 @@ rosidl_generator_java - 0.0.2 + 0.4.0 Generate the ROS interfaces in Java. Mickael Gaillard Apache License 2.0 diff --git a/scripts/travis-ci/osx_prepare.sh b/scripts/travis-ci/osx_prepare.sh index 34d864c..ee02130 100755 --- a/scripts/travis-ci/osx_prepare.sh +++ b/scripts/travis-ci/osx_prepare.sh @@ -4,24 +4,29 @@ set -e # Install default OSX stack. -time brew update -time brew tap osrf/ros2 -time brew tap ros/deps -time brew install python3 wget cppcheck gtest tinyxml eigen pcre # cmake already installed -time brew install asio tinyxml2 -#brew install Caskroom/cask/java -time brew install gradle -time brew tap homebrew/science +brew update +brew tap osrf/ros2 +brew tap ros/deps +brew upgrade python +brew install cppcheck tinyxml eigen pcre # wget cmake python3 already installed +brew install asio tinyxml2 +brew install gradle +brew tap caskroom/versions +brew cask install java8 +#brew tap homebrew/science # - brew install opencv --without-python -time sudo -H python3 -m pip install empy setuptools nose vcstool pep8 pydocstyle pyflakes flake8 mock coverage +sudo -H python3 -m pip install argcomplete catkin_pkg coverage empy flake8 flake8-blind-except flake8-builtins flake8-class-newline flake8-comprehensions flake8-deprecated flake8-docstrings flake8-import-order flake8-quotes mock nose pep8 pydocstyle pyflakes pyparsing pytest pytest-cov pytest-runner pyyaml vcstool +# setuptools already installed gem install xcpretty +export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/ + echo "INSTALL/BUILD ROS2 AMENT..." mkdir -p $HOME_BUILD/ament_ws/src cd $HOME_BUILD/ament_ws wget https://gist.githubusercontent.com/Theosakamg/e6084cfafa6b7ea690104424cef970a2/raw/ament_java.repos vcs import $HOME_BUILD/ament_ws/src < ament_java.repos -time src/ament/ament_tools/scripts/ament.py build --parallel --symlink-install --isolated +src/ament/ament_tools/scripts/ament.py build --parallel --symlink-install --isolated echo "INSTALL ROS2 WS..." mkdir -p $ROS2WS/src diff --git a/scripts/travis-ci/osx_run.sh b/scripts/travis-ci/osx_run.sh index caf7798..6229909 100755 --- a/scripts/travis-ci/osx_run.sh +++ b/scripts/travis-ci/osx_run.sh @@ -3,6 +3,8 @@ set -e +cd $HOME_BUILD +. ament_ws/install_isolated/local_setup.sh cd $ROS2WS -. $ROS2WS/install_isolated/local_setup.sh -ament test --symlink-install --isolated --only-packages ament_cmake_export_jars rcljava rcljava_common rosidl_generator_java +. install_isolated/local_setup.sh +ament test --symlink-install --isolated --only-packages ament_cmake_export_jars rcljava rcljava_common
Input Name Node: my_node NS: none Node: my_node NS: /my_ns
ping /ping /my_ns/ping
/ping /ping /ping