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

publisher and subscriber in rosjava

asked 2013-11-15 16:19:43 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

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?

edit retag flag offensive close merge delete

Comments

I am using ROS hydro.

uzair gravatar image uzair  ( 2013-11-15 16:48:01 -0600 )edit

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?

jorge gravatar image jorge  ( 2013-11-17 13:03:11 -0600 )edit

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;

uzair gravatar image uzair  ( 2013-11-17 16:42:24 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-11-18 01:05:21 -0600

jorge gravatar image

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.

edit flag offensive delete link more

Comments

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?

uzair gravatar image uzair  ( 2013-11-26 14:50:11 -0600 )edit

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.

jorge gravatar image jorge  ( 2013-11-26 15:34:36 -0600 )edit

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.

uzair gravatar image uzair  ( 2013-11-26 15:48:10 -0600 )edit

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.

jorge gravatar image jorge  ( 2013-11-26 16:53:11 -0600 )edit

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")

uzair gravatar image uzair  ( 2013-11-26 17:45:57 -0600 )edit

mmm... good improvement! Tutorial must be outdated; replace new GraphName("rosjava_tutorial_pubsub/listener") with GraphName.of("rosjava_tutorial_pubsub/listener")

jorge gravatar image jorge  ( 2013-11-26 17:58:28 -0600 )edit

All works now? Please mark question as solved if so

jorge gravatar image jorge  ( 2013-11-28 21:12:18 -0600 )edit

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.

uzair gravatar image uzair  ( 2013-12-26 16:12:23 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-11-15 16:19:43 -0600

Seen: 311 times

Last updated: Nov 18 '13