Skip to content

Commit

Permalink
🔖 0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
calvertdw committed Sep 18, 2018
2 parents ece8153 + 170d41d commit ea490dd
Show file tree
Hide file tree
Showing 18 changed files with 70 additions and 32 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,41 @@ This library provides a minimal implementation of a Ros2Node in Java. Two versio
PeriodicThreadSchedulerFactory threadFactory = SystemUtils.IS_OS_LINUX ? // realtime threads only work on linux
new PeriodicRealtimeThreadSchedulerFactory(20) : // see https://github.com/ihmcrobotics/ihmc-realtime
new PeriodicNonRealtimeThreadSchedulerFactory(); // to setup realtime threads
RealtimeRos2Node node = new RealtimeRos2Node(PubSubImplementation.FAST_RTPS, threadFactory, "NonRealtimeRos2PublishSubscribeExample", "");
RealtimeRos2Publisher<Int64> publisher = node.createPublisher(Int64.getPubSubType().get(), "/example");
RealtimeRos2Subscription<Int64> subscription = node.createSubscription(Int64.getPubSubType().get(), "/example");
RealtimeRos2Node node = new RealtimeRos2Node(PubSubImplementation.FAST_RTPS, threadFactory, "NonRealtimeRos2PublishSubscribeExample", "/us/ihmc");
RealtimeRos2Publisher<Int64> publisher = node.createPublisher(new Int64PubSubType(), "/example", Ros2QosProfile.KEEP_HISTORY(3), 10);
RealtimeRos2Subscription<Int64> subscription = node.createQueuedSubscription(new Int64PubSubType(), "/example", Ros2QosProfile.KEEP_HISTORY(3), 10);


node.spin(); // start the realtime node thread

Int64 message = new Int64();
for (int i = 0; i < 10; i++)
{
message.setData(i);
publisher.publish(message); // publish
publisher.publish(message);
System.out.println("Sending: " + message);
}

Int64 incomingMessage = new Int64();
while (!subscription.poll(incomingMessage))
; // just waiting for the first message
System.out.println(incomingMessage); // first message
System.out.println("Receiving: " + incomingMessage); // first message
int i = 1;
while (i < 10)
{
if (subscription.poll(incomingMessage)) // poll for new messages
if (subscription.poll(incomingMessage))
{
System.out.println(incomingMessage);
System.out.println("Receiving: " + incomingMessage);
i++;
}
else
{
// no available messages
}
}
System.out.println("Received all messages!");

node.destroy();
```

## Note
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath "us.ihmc:ihmc-build:0.14.0"
classpath "us.ihmc:ihmc-build:0.15.1"
}
}
apply plugin: "us.ihmc.ihmc-build"
5 changes: 3 additions & 2 deletions ihmc-ros2-library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
mavenLocal()
}
dependencies {
classpath "us.ihmc:ihmc-build:0.14.0"
classpath "us.ihmc:ihmc-build:0.15.1"
}
}

Expand All @@ -20,12 +20,13 @@ ihmc {
}

mainDependencies {
compile group: "us.ihmc", name: "ihmc-pub-sub", version: "0.8.3"
compile group: "us.ihmc", name: "ihmc-pub-sub", version: "0.9.0"
compile group: "us.ihmc", name: "IHMCRealtime", version: "1.1.8"
compile group: "us.ihmc", name: "ihmc-commons", version: "0.20.0"
}

testDependencies {
compile group: "us.ihmc", name: "ros2-common-interfaces", version: version
compile group: "us.ihmc", name: "ros2-msg-to-pubsub-generator-test", version: version
compile group: "us.ihmc", name: "ihmc-ci-core-api", version: "0.18.0"
}
2 changes: 1 addition & 1 deletion ihmc-ros2-library/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
mavenLocal()
}
dependencies {
classpath "us.ihmc:ihmc-build:0.14.0"
classpath "us.ihmc:ihmc-build:0.15.1"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
public class RealtimeRos2Node
{
public static int THREAD_PERIOD_MICROSECONDS = 1000;
public static final int DEFAULT_QUEUE_SIZE = 10;

private final Ros2NodeBasics node;

Expand Down Expand Up @@ -136,7 +137,7 @@ public RealtimeRos2Node(Ros2Node ros2Node, PeriodicThreadSchedulerFactory thread
*/
public <T> RealtimeRos2Publisher<T> createPublisher(TopicDataType<T> topicDataType, String topicName) throws IOException
{
return createPublisher(topicDataType, topicName, Ros2QosProfile.DEFAULT(), 10);
return createPublisher(topicDataType, topicName, Ros2QosProfile.DEFAULT(), DEFAULT_QUEUE_SIZE);
}

/**
Expand Down Expand Up @@ -186,7 +187,7 @@ public <T> RealtimeRos2Publisher<T> createPublisher(TopicDataType<T> topicDataTy
*/
public <T> RealtimeRos2Subscription<T> createQueuedSubscription(TopicDataType<T> topicDataType, String topicName) throws IOException
{
return createQueuedSubscription(topicDataType, topicName, Ros2QosProfile.DEFAULT(), 10);
return createQueuedSubscription(topicDataType, topicName, Ros2QosProfile.DEFAULT(), DEFAULT_QUEUE_SIZE);
}

/**
Expand Down
27 changes: 26 additions & 1 deletion ihmc-ros2-library/src/main/java/us/ihmc/ros2/Ros2NodeBasics.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.io.IOException;

import us.ihmc.commons.PrintTools;
import us.ihmc.pubsub.Domain;
import us.ihmc.pubsub.DomainFactory;
import us.ihmc.pubsub.DomainFactory.PubSubImplementation;
Expand All @@ -41,7 +42,7 @@
*/
class Ros2NodeBasics
{
public static final int ROS_DEFAULT_DOMAIN_ID = 0;
public static final int ROS_DEFAULT_DOMAIN_ID = domainFromEnvironment();

private final Ros2Distro ros2Distro;

Expand Down Expand Up @@ -285,4 +286,28 @@ public void destroy()
domain = null;
participant = null;
}

public static int domainFromEnvironment()
{
String rosDomainId = System.getenv("ROS_DOMAIN_ID");

int rosDomainIdAsInteger = 0; // default to 0

if (rosDomainId != null)
{
rosDomainId = rosDomainId.trim();
try
{
rosDomainIdAsInteger = Integer.valueOf(rosDomainId);
}
catch (NumberFormatException e)
{
PrintTools.warn("Environment variable ROS_DOMAIN_ID cannot be parsed as an integer: " + rosDomainId);
}
}

PrintTools.info(Ros2NodeBasics.class, "Default ROS_DOMAIN_ID: " + rosDomainIdAsInteger);

return rosDomainIdAsInteger;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import us.ihmc.ros2.RealtimeRos2Node;
import us.ihmc.ros2.RealtimeRos2Publisher;
import us.ihmc.ros2.RealtimeRos2Subscription;
import us.ihmc.ros2.Ros2QosProfile;
import us.ihmc.util.PeriodicNonRealtimeThreadSchedulerFactory;
import us.ihmc.util.PeriodicRealtimeThreadSchedulerFactory;
import us.ihmc.util.PeriodicThreadSchedulerFactory;
Expand All @@ -45,9 +46,10 @@ public static void main(String[] args) throws IOException, InterruptedException
new PeriodicRealtimeThreadSchedulerFactory(20) : // see https://github.com/ihmcrobotics/ihmc-realtime
new PeriodicNonRealtimeThreadSchedulerFactory(); // to setup realtime threads
RealtimeRos2Node node = new RealtimeRos2Node(PubSubImplementation.FAST_RTPS, threadFactory, "NonRealtimeRos2PublishSubscribeExample", "/us/ihmc");
RealtimeRos2Publisher<Int64> publisher = node.createPublisher(new Int64PubSubType(), "/example");
RealtimeRos2Subscription<Int64> subscription = node.createQueuedSubscription(new Int64PubSubType(), "/example");
RealtimeRos2Publisher<Int64> publisher = node.createPublisher(new Int64PubSubType(), "/example", Ros2QosProfile.KEEP_HISTORY(3), 10);
RealtimeRos2Subscription<Int64> subscription = node.createQueuedSubscription(new Int64PubSubType(), "/example", Ros2QosProfile.KEEP_HISTORY(3), 10);


node.spin(); // start the realtime node thread

Int64 message = new Int64();
Expand All @@ -61,7 +63,7 @@ public static void main(String[] args) throws IOException, InterruptedException
Int64 incomingMessage = new Int64();
while (!subscription.poll(incomingMessage))
; // just waiting for the first message
System.out.println(incomingMessage); // first message
System.out.println("Receiving: " + incomingMessage); // first message
int i = 1;
while (i < 10)
{
Expand All @@ -75,5 +77,8 @@ public static void main(String[] args) throws IOException, InterruptedException
// no available messages
}
}
System.out.println("Received all messages!");

node.destroy();
}
}
4 changes: 2 additions & 2 deletions ros2-common-interfaces/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
jcenter()
}
dependencies {
classpath "us.ihmc:ihmc-build:0.14.0"
classpath "us.ihmc:ihmc-build:0.15.1"
classpath "us.ihmc:ros2-msg-to-pubsub-generator:0.7.6-alpha"
classpath "org.ajoberstar:grgit:2.1.0"
}
Expand Down Expand Up @@ -40,7 +40,7 @@ ihmc {
mainDependencies {
compile group: "us.ihmc", name: "euclid-core", version: "0.4.13"
compile group: "us.ihmc", name: "euclid", version: "0.7.5"
compile group: "us.ihmc", name: "ihmc-pub-sub", version: "0.8.3"
compile group: "us.ihmc", name: "ihmc-pub-sub", version: "0.9.0"
}

generatorDependencies {
Expand Down
2 changes: 1 addition & 1 deletion ros2-common-interfaces/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
mavenLocal()
}
dependencies {
classpath "us.ihmc:ihmc-build:0.14.0"
classpath "us.ihmc:ihmc-build:0.15.1"
}
}

Expand Down
2 changes: 1 addition & 1 deletion ros2-msg-to-idl-generator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
mavenLocal()
}
dependencies {
classpath "us.ihmc:ihmc-build:0.14.0"
classpath "us.ihmc:ihmc-build:0.15.1"
}
}
apply plugin: "us.ihmc.ihmc-build"
Expand Down
2 changes: 1 addition & 1 deletion ros2-msg-to-idl-generator/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
mavenLocal()
}
dependencies {
classpath "us.ihmc:ihmc-build:0.14.0"
classpath "us.ihmc:ihmc-build:0.15.1"
}
}

Expand Down
7 changes: 4 additions & 3 deletions ros2-msg-to-pubsub-generator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
mavenLocal()
}
dependencies {
classpath "us.ihmc:ihmc-build:0.14.0"
classpath "us.ihmc:ihmc-build:0.15.1"
}
}
apply plugin: "us.ihmc.ihmc-build"
Expand All @@ -28,12 +28,13 @@ dependencies {
}

mainDependencies {
compile group: "us.ihmc", name: "ihmc-pub-sub-generator", version: "0.8.3"
compile group: "us.ihmc", name: "ihmc-pub-sub-generator", version: "0.9.0"
compile group: "us.ihmc", name: "ros2-msg-to-idl-generator", version: version
}

testDependencies {
compile group: "us.ihmc", name: "ihmc-pub-sub", version: "0.8.3"
compile group: "us.ihmc", name: "ihmc-pub-sub", version: "0.9.0"
compile group: "us.ihmc", name: "ihmc-ci-core-api", version: "0.18.0"
}

task show() {
Expand Down
2 changes: 1 addition & 1 deletion ros2-msg-to-pubsub-generator/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
mavenLocal()
}
dependencies {
classpath "us.ihmc:ihmc-build:0.14.0"
classpath "us.ihmc:ihmc-build:0.15.1"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module ros_msgs
@TypeCode(type="ros_msgs::msg::dds_::BigNumSequence_")
struct BigNumSequence
{
sequence<ros_msgs::msg::dds::Num, 100> large_sequence;
sequence<ros_msgs::msg::dds::Num, 10000> large_sequence;
};
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class BigNumSequence extends Packet<BigNumSequence> implements Settable<B

public BigNumSequence()
{
large_sequence_ = new us.ihmc.idl.IDLSequence.Object<ros_msgs.msg.dds.Num> (100, new ros_msgs.msg.dds.NumPubSubType());
large_sequence_ = new us.ihmc.idl.IDLSequence.Object<ros_msgs.msg.dds.Num> (10000, new ros_msgs.msg.dds.NumPubSubType());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static int getMaxCdrSerializedSize(int current_alignment)
{
int initial_alignment = current_alignment;

current_alignment += 4 + us.ihmc.idl.CDR.alignment(current_alignment, 4);for(int i0 = 0; i0 < 100; ++i0)
current_alignment += 4 + us.ihmc.idl.CDR.alignment(current_alignment, 4);for(int i0 = 0; i0 < 10000; ++i0)
{
current_alignment += ros_msgs.msg.dds.NumPubSubType.getMaxCdrSerializedSize(current_alignment);}
return current_alignment - initial_alignment;
Expand All @@ -65,7 +65,7 @@ public final static int getCdrSerializedSize(ros_msgs.msg.dds.BigNumSequence dat

public static void write(ros_msgs.msg.dds.BigNumSequence data, us.ihmc.idl.CDR cdr)
{
if(data.getLargeSequence().size() <= 100)
if(data.getLargeSequence().size() <= 10000)
cdr.write_type_e(data.getLargeSequence());else
throw new RuntimeException("large_sequence field exceeds the maximum length");

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Num[<=100] large_sequence
Num[<=10000] large_sequence
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
mavenLocal()
}
dependencies {
classpath "us.ihmc:ihmc-build:0.14.0"
classpath "us.ihmc:ihmc-build:0.15.1"
}
}

Expand Down

0 comments on commit ea490dd

Please sign in to comment.