ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

rosjava unable to find node (can't run resulting class)

asked 2011-10-05 02:09:02 -0600

morrowsend gravatar image

I built my own package, then I copied in the source form the Publisher/subscriber tutorial (LIstener.java and Talker.java) into the "src" directory. Building works fine, the resulting .class files are located in ../my_package/build/org/ros/tutorials/my_package. I attempt to run the code using this command (after roscore is running of course):

rosrun rosjava_bootstrap run.py my_package org.ros.tutorials.my_package.Listener

However, each time I try to run it, I get the following result:

    Buildfile: /home/user/ros_workspace/my_package/dependencies.xml

get-dependencies:

BUILD SUCCESSFUL
Total time: 3 seconds
Executing command: ['java', '-classpath', u'/home/user/ros_workspace/my_package/target/org.ros.rosjava.my_package-0.0.0.jar:/home/user/.ros/rosjava/lib/org.ros.rosjava.test_ros-0.0.0.jar:/home/user/.ros/rosjava/lib/org.ros.rosjava.roscpp-0.0.0.jar:/home/user/.ros/rosjava/lib/org.ros.rosjava.topic_tools-0.0.0.jar:/home/user/ros_workspace/rosjava/apache_xmlrpc/target/org.ros.rosjava.apache-xmlrpc-3.1.3.jar:/home/user/ros_workspace/rosjava/rosjava_bootstrap/target/org.ros.rosjava.rosjava_bootstrap-0.0.0.jar:/home/user/.ros/rosjava/lib/org.ros.rosjava.std_msgs-0.0.0.jar:/home/user/ros_workspace/rosjava/rosjava/target/org.ros.rosjava-0.0.0.jar:/home/user/.ros/rosjava/lib/org.ros.rosjava.rosgraph_msgs-0.0.0.jar:/home/user/.ros/rosjava/lib/org.ros.rosjava.geometry_msgs-0.0.0.jar:/home/user/ros_workspace/rosjava/apache_commons_util/target/org.ros.rosjava.ws-commons-util-1.0.2.jar:/home/user/.ros/rosjava/lib/org.ros.rosjava.sensor_msgs-0.0.0.jar:/home/user/.m2/repository/com/google/guava/org.ros.rosjava.guava/r07/org.ros.rosjava.guava-r07.jar:/home/user/.m2/repository/dnsjava/org.ros.rosjava.dnsjava/2.1.1/org.ros.rosjava.dnsjava-2.1.1.jar:/home/user/.m2/repository/org/apache/commons/com.springsource.org.apache.commons.codec/1.3.0/com.springsource.org.apache.commons.codec-1.3.0.jar:/home/user/.m2/repository/org/apache/commons/com.springsource.org.apache.commons.httpclient/3.1.0/com.springsource.org.apache.commons.httpclient-3.1.0.jar:/home/user/.m2/repository/org/apache/commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar:/home/user/.m2/repository/org/jboss/netty/netty/3.2.4.Final/netty-3.2.4.Final.jar', 'org.ros.RosRun', 'org.ros.tutorials.my_package.Listener']
Loading node class: org.ros.tutorials.my_package.Listener
Unable to locate node: org.ros.tutorials.my_package.Listener

I have no idea how it can not find the Listener.class file since the path is correct. Am I missing something here?

edit retag flag offensive close merge delete

Comments

After posting this, I found a similar topic http://answers.ros.org/question/2121/cant-run-a-ros-package-created-with-rosjava mentioning that a .jar is not being created. This seems to be the case for me as well, even though my manifest.xml has an Export section as mentioned in the ROSJava/build page. I am unsure how to create the jar.
morrowsend gravatar image morrowsend  ( 2011-10-05 02:30:27 -0600 )edit
I got it working. I added the "jar" sections to my build.xml (copied form the pubsub build.xml). Then I had to explicitly build the jar in Eclipse's Ant window. ONce the jar was there, everything went smoothly.
morrowsend gravatar image morrowsend  ( 2011-10-05 02:49:45 -0600 )edit
Could you please post your solution as an answer and mark it as accepted?
damonkohler gravatar image damonkohler  ( 2011-10-08 04:33:38 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2011-10-11 09:53:17 -0600

morrowsend gravatar image

To get this working, you have to use a better skelaton build.xml file than provided on the ROSJAVA wiki. The one I used is below. It basically adds the jar information to the build settings.

You must build the jar file from the ANT window in eclipse in order to create a new jar file each time you want to recompile. I haven't found a way to automate that part yet.

<?xml version="1.0" encoding="UTF-8"?>
<project name="my_second_package" default="default">

  <property file="ros.properties" />
  <property name="build" location="build" />

  <property name="dist" location="dist" />
  <property name="build" location="build" />
  <property name="src" location="src" />
  <property name="jar" location="${ros.artifact.built}" />

  <path id="classpath">
    <pathelement path="${ros.compile.classpath}" />
  </path>

    <echo message="${toString:classpath}" />

  <target name="default" depends="init, compile, jar" />

  <target name="init">
    <fail unless="ros.compile.classpath" message="ros.properties is missing.  Please type 'rosmake' first "/>
    <mkdir dir="${build}" />
    <mkdir dir="${dist}" />
  </target>

  <target name="compile" depends="init">

    <javac destdir="${build}">
      <classpath refid="classpath" />
      <src path="${src}" />
    </javac>
  </target>

      <target name="jar" depends="compile">
        <jar destfile="${jar}">
          <fileset dir="${build}" />
        </jar>
      </target>

  <target name="clean">
    <delete dir="${build}" />
    <delete dir="${dist}" />
  </target>

  <!-- required entry point -->
  <target name="test" />

</project>
edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-10-05 02:09:02 -0600

Seen: 778 times

Last updated: Oct 11 '11