This package provides an implementation of TF for rosjava.
We use jgrapht to represent the tree of TF frames and javax.vecmath for linear algebra.
All dependencies are handled via gradle. Just clone this package into your rosjava workspace and run catkin_make
.
If you need cross-compile compatability for older java versions have a look at the java6 branch.
import org.ros.rosjava.tf.Transform;
import org.ros.rosjava.tf.pubsub.TransformListener;
...
TransformListener tfl = new TransformListener(connectedNode);
long now = (long) System.currentTimeMillis() * 1000000; // nanoseconds
String from = "map";
String to = "base_link";
try {
Transform tx = tfl.getTree().lookupTransformBetween(from, to, now);
System.out.println(tx);
}
catch (Exception e) {
System.err.println("Error: "+e.toString());
}
Most of this software is based on the previous works of Nick Armstrong Crews' rosjava-tf package. It has been updated to Kinetic and many unfinished and/or broken methods have been fixed.