0
$\begingroup$

Rosanswers logo

I am trying to follow the publisher/subscriber tutorial for rosjava provided at this link.

http : //rosjava.github.io/rosjava_core/latest/getting_started.html#creating-a-new-java-package

However, when i copy paste the code into a file in my project, I am getting compilation errors like (1)package std_msgs does not exist and 2)cannot find symbol) when i build my package with catkin_make. I am using catkin_make for building because this tutorial says so: --http ://wiki.ros.org/rosjava_build_tools/Tutorials/hydro/Creating%20Rosjava%20Packages

I added my dependencies (rosjava_bootstrap,rosjava_build_tools,std_msgs,rosjava_messages) in my package.xml file like this.(i think i should be doing this in the gradle file)

<build_depend>rosjava_build_tools</build_depend> <run_depend>rosjava_build_tools</run_depend>

How do I add the dependencies for the modules being imported in the begining of the publisher program. the modules are-

import org.ros.namespace.GraphName; import org.ros.node.Node; import org.ros.node.NodeMain;

Can somebody tell me how to add the dependencies?


Originally posted by uzair on ROS Answers with karma: 87 on 2013-11-15

Post score: 0


Original comments

Comment by uzair on 2013-11-15:
I am using ROS hydro.

Comment by jorge on 2013-11-17:
So you create a package following the second tutorial, and then you add the code from the first one? right? Can you just follow the second tutorial and compile without errors?

Comment by uzair on 2013-11-17:
I couldnt find any code for publisher or subscriber for the second tutorial using catkin_make for building. I am pretty sure i need to add the dependencies in the gradle file but i dont know how. I read the gradle tutorial where it says i need to specify the version of the package too. How do i specify these packages [.org.ros.namespace.GraphName; org.ros.node.Node; org.ros.node.NodeMain]according to the syntax given here for dependencies [http://www.gradle.org/docs/current/userguide/tutorial_java_projects.html]-go to example 7.4;

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Yes, I think so; you add dependencies on build.gradle file. An example:

dependencies {
    compile 'org.ros.rosjava_core:rosjava:[0.1,0.2)'
    compile 'org.ros.rosjava_messages:std_msgs:[0.5,0.6)'
}

not sure if this will work or you need something more.


Originally posted by jorge with karma: 2284 on 2013-11-18

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by uzair on 2013-11-26:
There are two build.gradle files. One in my package folder and one inside the project folder in my package folder. In which build.gradle file do i add this?

Comment by jorge on 2013-11-26:
Not fully sure what you mean with project and package... I think the one in project. Must have almost no additional contents. The one in the package contains some groovy functions.

Comment by uzair on 2013-11-26:
I created a pakcage called rosjava_foo and in that i created a project called dude as it is said in the tutorial. THere is one build.gradle in the rosjava_foo folder and one in the dude folder. The one in the dude folder has a section called "dependencies{ } " but it is commented between /* and */. The build.gradle in hte package folder has some commands like apply plugin etc along with the maven repository and the dependency block.

Comment by jorge on 2013-11-26:
Right; add dependencies to the one in the dude folder. Please mark the question as answered if it works to help others with the same problem.

Comment by uzair on 2013-11-26:
i added compile 'org.ros.rosjava_core:rosjava:[0.1,)' and the errors reduced from from 20 to 1.

The error I have now states that "GraphName(java.lang.String) has private access in org.ros.namespace.GraphName return new GraphName("rosjava_tutorial_pubsub/listener")

Comment by jorge on 2013-11-26:
mmm... good improvement! Tutorial must be outdated; replace new GraphName("rosjava_tutorial_pubsub/listener") with GraphName.of("rosjava_tutorial_pubsub/listener")

Comment by jorge on 2013-11-28:
All works now? Please mark question as solved if so

Comment by uzair on 2013-12-26:
If I do that then i get a new error. It says symbol not defined and the arrow points to the dot in GraphName.of .Appreciate all the help.

Comment by uzair on 2013-12-27:
Hi jorge..please take a look at my question. THanks

http://answers.ros.org/question/113431/rosjava-listener/

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.