Skip to content

Commit c365a1f

Browse files
authored
Merge pull request #3 from rosjava/kinetic
sync with rosjava/kinetic
2 parents 12bee5d + 111c1d1 commit c365a1f

17 files changed

+184
-62
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ bin
99
*.iml
1010
.idea
1111
bazel-*
12+
local.properties

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Changelog
33
=========
44

5+
0.3.7 (2019-01-22)
6+
------------------
7+
* Gradle update to 4.10.2.
8+
* Use new http_archive rule for Bazel deps.
9+
* Contributors: Juan Ignacio Ubeira, Rodrigo Queiro
10+
511
0.3.6 (2018-09-06)
612
------------------
713
* Using `time=0` by default; prevents `NullPointerException` when using `sim_time`.

bazel/repositories.bzl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
Maven dependencies must be added to the workspace with bazel-deps.
44
"""
55

6+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
7+
68
def rosjava_repositories():
7-
_maybe(native.http_archive,
9+
_maybe(http_archive,
810
name = "com_googlesource_gerrit_bazlets",
911
sha256 = "cdd1a90733cdb71ac4fb86aa6027d3fcad275fe74781175f8437a9c86a0db149",
1012
strip_prefix = "bazlets-4459b9706a6eedb8453a98d4434fb3bc4db84211",
@@ -13,7 +15,7 @@ def rosjava_repositories():
1315
],
1416
)
1517

16-
_maybe(native.http_archive,
18+
_maybe(http_archive,
1719
name = "com_github_rosjava_rosjava_bootstrap",
1820
sha256 = "3c59776a8c6e22232d07f29a686c0e5f401812ec27f59405711657d54a792c08",
1921
strip_prefix = "rosjava_bootstrap-62f865dbe8a7830b21e054dc2a5ac7d2edc6eafe",

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
task wrapper(type: Wrapper) {
18-
gradleVersion = '3.5.1'
18+
gradleVersion = '4.10.2'
1919
}
2020

2121
buildscript {

gradle/wrapper/gradle-wrapper.jar

1.43 KB
Binary file not shown.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Fri Jan 26 13:47:21 ART 2018
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-bin.zip

gradlew

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,43 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
22

33
##############################################################################
44
##
55
## Gradle start up script for UN*X
66
##
77
##############################################################################
88

9-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10-
DEFAULT_JVM_OPTS=""
9+
# Attempt to set APP_HOME
10+
# Resolve links: $0 may be a link
11+
PRG="$0"
12+
# Need this for relative symlinks.
13+
while [ -h "$PRG" ] ; do
14+
ls=`ls -ld "$PRG"`
15+
link=`expr "$ls" : '.*-> \(.*\)$'`
16+
if expr "$link" : '/.*' > /dev/null; then
17+
PRG="$link"
18+
else
19+
PRG=`dirname "$PRG"`"/$link"
20+
fi
21+
done
22+
SAVED="`pwd`"
23+
cd "`dirname \"$PRG\"`/" >/dev/null
24+
APP_HOME="`pwd -P`"
25+
cd "$SAVED" >/dev/null
1126

1227
APP_NAME="Gradle"
1328
APP_BASE_NAME=`basename "$0"`
1429

30+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31+
DEFAULT_JVM_OPTS=""
32+
1533
# Use the maximum available, or set MAX_FD != -1 to use that value.
1634
MAX_FD="maximum"
1735

18-
warn ( ) {
36+
warn () {
1937
echo "$*"
2038
}
2139

22-
die ( ) {
40+
die () {
2341
echo
2442
echo "$*"
2543
echo
@@ -30,6 +48,7 @@ die ( ) {
3048
cygwin=false
3149
msys=false
3250
darwin=false
51+
nonstop=false
3352
case "`uname`" in
3453
CYGWIN* )
3554
cygwin=true
@@ -40,31 +59,11 @@ case "`uname`" in
4059
MINGW* )
4160
msys=true
4261
;;
62+
NONSTOP* )
63+
nonstop=true
64+
;;
4365
esac
4466

45-
# For Cygwin, ensure paths are in UNIX format before anything is touched.
46-
if $cygwin ; then
47-
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48-
fi
49-
50-
# Attempt to set APP_HOME
51-
# Resolve links: $0 may be a link
52-
PRG="$0"
53-
# Need this for relative symlinks.
54-
while [ -h "$PRG" ] ; do
55-
ls=`ls -ld "$PRG"`
56-
link=`expr "$ls" : '.*-> \(.*\)$'`
57-
if expr "$link" : '/.*' > /dev/null; then
58-
PRG="$link"
59-
else
60-
PRG=`dirname "$PRG"`"/$link"
61-
fi
62-
done
63-
SAVED="`pwd`"
64-
cd "`dirname \"$PRG\"`/" >&-
65-
APP_HOME="`pwd -P`"
66-
cd "$SAVED" >&-
67-
6867
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
6968

7069
# Determine the Java command to use to start the JVM.
@@ -90,7 +89,7 @@ location of your Java installation."
9089
fi
9190

9291
# Increase the maximum file descriptors if we can.
93-
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
92+
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
9493
MAX_FD_LIMIT=`ulimit -H -n`
9594
if [ $? -eq 0 ] ; then
9695
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -114,6 +113,7 @@ fi
114113
if $cygwin ; then
115114
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116115
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116+
JAVACMD=`cygpath --unix "$JAVACMD"`
117117

118118
# We build the pattern for arguments to be converted via cygpath
119119
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
@@ -154,11 +154,19 @@ if $cygwin ; then
154154
esac
155155
fi
156156

157-
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158-
function splitJvmOpts() {
159-
JVM_OPTS=("$@")
157+
# Escape application args
158+
save () {
159+
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160+
echo " "
160161
}
161-
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162-
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
162+
APP_ARGS=$(save "$@")
163+
164+
# Collect all arguments for the java command, following the shell quoting and substitution rules
165+
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166+
167+
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168+
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169+
cd "$(dirname "$0")"
170+
fi
163171

164-
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
172+
exec "$JAVACMD" "$@"

gradlew.bat

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
@rem Set local scope for the variables with windows NT shell
99
if "%OS%"=="Windows_NT" setlocal
1010

11-
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12-
set DEFAULT_JVM_OPTS=
13-
1411
set DIRNAME=%~dp0
1512
if "%DIRNAME%" == "" set DIRNAME=.
1613
set APP_BASE_NAME=%~n0
1714
set APP_HOME=%DIRNAME%
1815

16+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17+
set DEFAULT_JVM_OPTS=
18+
1919
@rem Find java.exe
2020
if defined JAVA_HOME goto findJavaFromJavaHome
2121

@@ -46,10 +46,9 @@ echo location of your Java installation.
4646
goto fail
4747

4848
:init
49-
@rem Get command-line arguments, handling Windowz variants
49+
@rem Get command-line arguments, handling Windows variants
5050

5151
if not "%OS%" == "Windows_NT" goto win9xME_args
52-
if "%@eval[2+2]" == "4" goto 4NT_args
5352

5453
:win9xME_args
5554
@rem Slurp the command line arguments.
@@ -60,11 +59,6 @@ set _SKIP=2
6059
if "x%~1" == "x" goto execute
6160

6261
set CMD_LINE_ARGS=%*
63-
goto execute
64-
65-
:4NT_args
66-
@rem Get arguments from the 4NT Shell from JP Software
67-
set CMD_LINE_ARGS=%$
6862

6963
:execute
7064
@rem Setup the command line

package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<package>
33
<name>rosjava_core</name>
4-
<version>0.3.6</version>
4+
<version>0.3.7</version>
55
<description>
66
An implementation of ROS in pure-Java with Android support.
77
</description>

rosjava/src/main/java/org/ros/internal/node/DefaultNode.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import org.ros.node.topic.DefaultSubscriberListener;
6666
import org.ros.node.topic.Publisher;
6767
import org.ros.node.topic.Subscriber;
68+
import org.ros.node.topic.TransportHints;
6869
import org.ros.time.ClockTopicTimeProvider;
6970
import org.ros.time.TimeProvider;
7071

@@ -283,7 +284,7 @@ public <T> Publisher<T> newPublisher(GraphName topicName, String messageType) {
283284
TopicDescription topicDescription =
284285
nodeConfiguration.getTopicDescriptionFactory().newFromType(messageType);
285286
TopicDeclaration topicDeclaration =
286-
TopicDeclaration.newFromTopicName(resolvedTopicName, topicDescription);
287+
TopicDeclaration.newFromTopicName(resolvedTopicName, topicDescription, null);
287288
org.ros.message.MessageSerializer<T> serializer = newMessageSerializer(messageType);
288289
return publisherFactory.newOrExisting(topicDeclaration, serializer);
289290
}
@@ -295,19 +296,29 @@ public <T> Publisher<T> newPublisher(String topicName, String messageType) {
295296

296297
@Override
297298
public <T> Subscriber<T> newSubscriber(GraphName topicName, String messageType) {
299+
return newSubscriber(topicName, messageType, null);
300+
}
301+
302+
@Override
303+
public <T> Subscriber<T> newSubscriber(GraphName topicName, String messageType, TransportHints transportHints) {
298304
GraphName resolvedTopicName = resolveName(topicName);
299305
TopicDescription topicDescription =
300306
nodeConfiguration.getTopicDescriptionFactory().newFromType(messageType);
301307
TopicDeclaration topicDeclaration =
302-
TopicDeclaration.newFromTopicName(resolvedTopicName, topicDescription);
308+
TopicDeclaration.newFromTopicName(resolvedTopicName, topicDescription, transportHints);
303309
MessageDeserializer<T> deserializer = newMessageDeserializer(messageType);
304310
Subscriber<T> subscriber = subscriberFactory.newOrExisting(topicDeclaration, deserializer);
305311
return subscriber;
306312
}
307313

308314
@Override
309315
public <T> Subscriber<T> newSubscriber(String topicName, String messageType) {
310-
return newSubscriber(GraphName.of(topicName), messageType);
316+
return newSubscriber(GraphName.of(topicName), messageType, null);
317+
}
318+
319+
@Override
320+
public <T> Subscriber<T> newSubscriber(String topicName, String messageType, TransportHints transportHints) {
321+
return newSubscriber(GraphName.of(topicName), messageType, transportHints);
311322
}
312323

313324
@Override
@@ -416,8 +427,6 @@ public void shutdown() {
416427
// NOTE(damonkohler): We don't want to raise potentially spurious
417428
// exceptions during shutdown that would interrupt the process. This is
418429
// simply best effort cleanup.
419-
slaveServer.shutdown();
420-
topicParticipantManager.shutdown();
421430
for (ServiceServer<?, ?> serviceServer : serviceManager.getServers()) {
422431
try {
423432
Response<Integer> response =
@@ -436,8 +445,9 @@ public void shutdown() {
436445
for (ServiceClient<?, ?> serviceClient : serviceManager.getClients()) {
437446
serviceClient.shutdown();
438447
}
439-
registrar.shutdown();
440448
slaveServer.shutdown();
449+
topicParticipantManager.shutdown();
450+
registrar.shutdown();
441451
signalOnShutdownComplete();
442452
}
443453

rosjava/src/main/java/org/ros/internal/node/response/TopicListResultFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public List<TopicDeclaration> newFromValue(Object value) {
4343
String name = (String) ((Object[]) topic)[0];
4444
String type = (String) ((Object[]) topic)[1];
4545
descriptions.add(TopicDeclaration.newFromTopicName(GraphName.of(name), new TopicDescription(type, null,
46-
null)));
46+
null), null));
4747
}
4848
return descriptions;
4949
}

rosjava/src/main/java/org/ros/internal/node/topic/DefaultPublisher.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.ros.node.topic.PublisherListener;
3636
import org.ros.node.topic.Subscriber;
3737

38+
import java.util.concurrent.CountDownLatch;
3839
import java.util.concurrent.ScheduledExecutorService;
3940
import java.util.concurrent.TimeUnit;
4041

@@ -63,6 +64,7 @@ public class DefaultPublisher<T> extends DefaultTopicParticipant implements Publ
6364
private final ListenerGroup<PublisherListener<T>> listeners;
6465
private final NodeIdentifier nodeIdentifier;
6566
private final MessageFactory messageFactory;
67+
private CountDownLatch shutdownLatch;
6668

6769
public DefaultPublisher(NodeIdentifier nodeIdentifier, TopicDeclaration topicDeclaration,
6870
MessageSerializer<T> serializer, MessageFactory messageFactory,
@@ -105,9 +107,20 @@ public boolean getLatchMode() {
105107
return outgoingMessageQueue.getLatchMode();
106108
}
107109

110+
/**
111+
* Sends shutdown signals and awaits for them to be received by
112+
* {@link DefaultPublisher#signalOnMasterUnregistrationSuccess()} or
113+
* {@link DefaultPublisher#signalOnMasterUnregistrationFailure()} before continuing shutdown
114+
*/
108115
@Override
109116
public void shutdown(long timeout, TimeUnit unit) {
117+
shutdownLatch = new CountDownLatch(listeners.size());
110118
signalOnShutdown(timeout, unit);
119+
try {
120+
shutdownLatch.await(timeout, unit);
121+
} catch (InterruptedException e) {
122+
log.error(e.getMessage(), e);
123+
}
111124
outgoingMessageQueue.shutdown();
112125
listeners.shutdown();
113126
}
@@ -252,6 +265,7 @@ public void signalOnMasterUnregistrationSuccess() {
252265
@Override
253266
public void run(PublisherListener<T> listener) {
254267
listener.onMasterUnregistrationSuccess(publisher);
268+
shutdownLatch.countDown();
255269
}
256270
});
257271
}
@@ -269,6 +283,7 @@ public void signalOnMasterUnregistrationFailure() {
269283
@Override
270284
public void run(PublisherListener<T> listener) {
271285
listener.onMasterUnregistrationFailure(publisher);
286+
shutdownLatch.countDown();
272287
}
273288
});
274289
}

0 commit comments

Comments
 (0)