How to build a simple rosjava package successfully?
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 ...
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.