[ros-users] ROSjava and non-standard messages

Ken Conley kwc at willowgarage.com
Mon Aug 15 18:16:20 UTC 2011

On Mon, Aug 15, 2011 at 10:34 AM, Mark Rowan <m.s.rowan at cs.bham.ac.uk> wrote:
> On 15 August 2011 18:07, Ken Conley <kwc at willowgarage.com> wrote:
>> On Mon, Aug 15, 2011 at 10:00 AM, Mark Rowan <m.s.rowan at cs.bham.ac.uk> wrote:
>>> Ok, I've got ant working (thanks to the supplied build.xml on the
>>> rosjava wiki page you linked to, although there was a small error in
>>> the XML file which I've corrected on the wiki) but I can't seem to
>>> find any way to run the compiled classes using rosrun. Is this
>>> possible, or do we have to manually execute nodes using java
>>> -classpath <path> package.class ?
>> This is still be tweaked and documentation hasn't been written yet,
>> but you can use:
>> "
>> rosrun rosjava_bootstrap run.py <pkg> <node_class>  [args ... ]
>> "
> Thanks for this info. I assume <pkg> relates to the ROS package, not
> the Java package?


>> That script generally assumes that you are using the <export> tags to
>> setup your path.  These <export> tags are currently being finalized
>> and you'd have to look at rosjava_core packages for examples.
> My path is currently set manually in .bashrc -- is this a suitable
> alternative, or are the <export> tags specifically required?

That's fine.  The <export> tasks basically let you more easily use
other rosjava-based packages (and lets others use yours as well).

>> But, the script basically constructs the path from the export tags and runs:
>> java -classpath <classpath> org.ros.RosRun <node_class> [args...]
>> So that should be fairly similar to what you are used to.
> Thanks. I'm clearly doing something wrong, as run.py responds that it
> is 'Unable to locate node'.

That means that the <classpath> is not correct.  More thoughts below.

> I have a ROS package directory, initialised with rospkg-create, and
> containing 'src' and 'build' directories. The 'src' contains a further
> Java package directory Running 'ant compile' takes my source and
> compiles it into the build directory, at myPackage/MyClass.class .
> Running 'rosrun rosjava_bootstrap run.py <ros-package>
> myPackage.MyClass' builds successfully from dependencies.xml (although
> it declares an error, "Could not load definitions from resource
> net/sf/antcontrib/antlib.xml. It could not be found." -- is this
> important?)

Don't worry about that error.

> but after the execution stage begins, the script returns
> "Unable to locate node myPackage.MyClass".
> The huge auto-generated classpath does not include the
> <ros-package>/build/ directory, which seems relevant.

You can use the:

java -classpath <classpath> org.ros.RosRun <node_class> [args...]

If you wish to keep manually configuring your classpath and the like.

If you wish to use run.py instead of manually calling the java RosRun
syntax, you need to use the exports.  As before, this comes with the
caveat that this is where we are currently doing a lot of work on
rosjava to stabilize things.

Based on your description of your build you will need to:

 1) Add a <jar> build to your build.xml
 2) Add an export to that describes the jar you built, e.g.:

<rosjava-pathelement location="target" groupId="ws-commons-util"
artifactId="org.ros.rosjava.ws-commons-util" version="0.0.0"
built="true" />

The above is using Maven's nomenclature (http://maven.apache.org/):

 * location: path to directory where your jar file is
 * artifactId: name of jar file (sans version number and .jar)
 * version: version number in jar file

Thus, the jar file name for the above is


> Thanks again, and sorry for the many questions!
> Mark
> --
> Mark Rowan  |  http://www.tamias.co.uk
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users

More information about the ros-users mailing list