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

How to build a simple rosjava package successfully?

asked 2012-08-15 04:26:59 -0600

sam gravatar image

updated 2012-08-17 02:59:51 -0600

I followed rosjava_tutorial_pubsub and rosjavaのプロジェクト作成&Talker作成.

I run:

  roscreate-pkg sam_rosjava_basic
  cd sam_rosjava_basic/

My build.gradle:

  apply plugin: 'java'

  // The Maven plugin is only required if your package is used as a library.
  apply plugin: 'maven'

  // The Application plugin and mainClassName attribute are only required if
  // your package is used as a binary.
  apply plugin: 'application'
  mainClassName = 'org.ros.RosRun'

  sourceCompatibility = 1.6
  targetCompatibility = 1.6

  repositories {
    mavenLocal()
    maven {
      url 'http://robotbrains.hideho.org/nexus/content/groups/ros-public'
    }
  }

  version = '0.0.0-SNAPSHOT'
  group = 'ros.my_stack'

  dependencies {
    compile 'ros.rosjava_core:rosjava:0.0.0-SNAPSHOT'
  }

And I run:

  mkdir -p src/main/java

My src/main/java/talker.java:

   package org.ros.rosjava_tutorial_pubsub;

  import org.ros.concurrent.CancellableLoop;
  import org.ros.namespace.GraphName;
  import org.ros.node.AbstractNodeMain;
  import org.ros.node.ConnectedNode;
  import org.ros.node.NodeMain;
  import org.ros.node.topic.Publisher;

  /**
   * A simple {@link Publisher} {@link NodeMain}.
   * 
   * @author damonkohler@google.com (Damon Kohler)
   */
  public class Talker extends AbstractNodeMain {

    @Override
    public GraphName getDefaultNodeName() {
      return new GraphName("rosjava_tutorial_pubsub/talker");
    }

    @Override
    public void onStart(final ConnectedNode connectedNode) {
      final Publisher<std_msgs.String> publisher =
          connectedNode.newPublisher("chatter", std_msgs.String._TYPE);
      // This CancellableLoop will be canceled automatically when the node shuts
      // down.
      connectedNode.executeCancellableLoop(new CancellableLoop() {
        private int sequenceNumber;

        @Override
        protected void setup() {
          sequenceNumber = 0;
        }

        @Override
        protected void loop() throws InterruptedException {
          std_msgs.String str = publisher.newMessage();
          str.setData("Hello world! " + sequenceNumber);
          publisher.publish(str);
          sequenceNumber++;
          Thread.sleep(1000);
        }
      });
    }
  }

Then I run:

  sam@/home/sam$ `rosstack find rosjava_core`/gradlew installApp
  bash: /opt/ros/electric/stacks/rosjava_core/gradlew: No such file or directory      
  sam@/home/sam$

How to solve it?

Thank you~

===================================================

I try to use rosws to init my workspace,download rosjava,and rosmake successfully!

I run:

  cd ~/code/ros
  rosws init
  echo 'source ~/code/ros/setup.bash' >> ~/.bashrc
  rosws merge /opt/ros/electric/.rosinstall
  rosws merge http://rosjava.googlecode.com/hg/.rosinstall
  rosws update
  cd rosjava_core/
  rosmake

But when I try:

   sam@/home/sam/code/ros/java/sam_rosjava_basic$ `rosstack find rosjava_core`/gradlew installApp
  Downloading http://services.gradle.org/distributions/gradle-1.0-milestone-9-bin.zip
  .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
  Unzipping /home/sam/.gradle/wrapper/dists/gradle-1.0-milestone-9-bin/7ilkmgo2rn79vvfvd51rqf17ks/gradle-1.0-milestone-9-bin.zip to /home/sam/.gradle/wrapper/dists/gradle-1.0-milestone-9-bin/7ilkmgo2rn79vvfvd51rqf17ks
  Set executable permissions for: /home/sam/.gradle/wrapper/dists/gradle-1.0-milestone-9-bin/7ilkmgo2rn79vvfvd51rqf17ks/gradle-1.0-milestone-9/bin/gradle
  :compileJava

  FAILURE: Build failed with an exception.

  * What went wrong:
  Could not resolve all dependencies for configuration ':compile'.
  > Could not find group:ros.rosjava_core, module:rosjava, version:0.0.0-SNAPSHOT.
    Required by:
        ros.my_stack:sam_rosjava_basic:0.0.0-SNAPSHOT

  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

  BUILD FAILED

  Total time: 2 mins 29.874 secs

  sam@/home/sam/code/ros/java/sam_rosjava_basic$

I try again with sudo:

   sam@/home/sam/code/ros/java/sam_rosjava_basic$ sudo `rosstack find rosjava_core`/gradlew installApp
  [sudo] password for sam: 
  Downloading http://services.gradle.org/distributions/gradle-1.0-milestone-9-bin.zip
  .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
  Unzipping /root/.gradle/wrapper/dists/gradle-1.0-milestone-9-bin/7ilkmgo2rn79vvfvd51rqf17ks/gradle-1.0-milestone-9-bin.zip to /root/.gradle/wrapper/dists/gradle-1.0-milestone-9-bin/7ilkmgo2rn79vvfvd51rqf17ks
  Set executable ...
(more)
edit retag flag offensive close merge delete

Comments

Please ask only one question at a time, and do not change the question. You need to run gradlew install in rosjava_core first, not rosmake. Never use sudo, unless a tutorial tells you to.

KruseT gravatar image KruseT  ( 2012-08-17 04:12:47 -0600 )edit

3 Answers

Sort by » oldest newest most voted
1

answered 2012-08-24 22:52:57 -0600

damonkohler gravatar image

You need to follow the directions exactly as they are described in the documentation. rosmake has no effect in rosjava_core. Your package is failing to build because you have not executed the install task for rosjava_core.

Follow the directions, make sure the tutorials build as described, and then try your project again.

edit flag offensive delete link more

Comments

What I know is trying to follow the doc. I can't understand what you told to me. I have already run 'rosws merge http://rosjava.googlecode.com/hg/.rosinstall'. What can I do next? Thank you~

sam gravatar image sam  ( 2012-09-02 21:33:12 -0600 )edit

Create a package in ~/<your_ws>/rosjava_core/ and follow this link http://docs.rosjava.googlecode.com/hg/rosjava_core/html/getting_started.html#creating-a-new-java-package

you must create package rosjava_core and if everything is okey, you run ../gradlew installApp.

caca gravatar image caca  ( 2013-06-20 00:24:45 -0600 )edit
0

answered 2012-08-15 23:26:37 -0600

KruseT gravatar image

updated 2012-08-15 23:38:47 -0600

As an alternative to gradlew, you can try to install gradle and run gradle instead of gradlew.

Else you can always clone the rosjava sources, move the supplied gradlew to your own project, and run it from there.

edit flag offensive delete link more
0

answered 2012-08-15 09:03:09 -0600

You receive this error as the gradle wrapper is not present in your copy of rosjava_core. I think a number of major changes have been made to rosjava_core since the release of that deb. You should download and install rosjava_core from source as per the new installation instructions here: http://docs.rosjava.googlecode.com/hg/rosjava_core/html/installing.html

Note that these instructions use rosws/rosinstall, and you'll have to place your example package in the same workspace to get it to work.

edit flag offensive delete link more

Comments

I follow the link you provide,and I also met problems which I edited in my original post. How to solve it? Thank you~

sam gravatar image sam  ( 2012-08-17 03:01:23 -0600 )edit

Question Tools

Stats

Asked: 2012-08-15 04:26:59 -0600

Seen: 2,334 times

Last updated: Aug 24 '12