Skip to content
Chris Burbridge edited this page Nov 30, 2013 · 2 revisions

Overview

A rosjava 'project' lives inside a rosjava package, as created in the first steps tutorials. The example programs repository is itself a rosjava project, but you can (and should) create your own project inside your package alongside the examples.

The structure of your workspace will look something like this

catkin_ws/             <- The catkin workspace
  src/
    java_projects/     <- A ROSJava package, also a ROS package
      rosjava_examples <- The examples rosjava project, git repo
      my_project1      <- Your project
      my_project2
  build/              <- Autogenerated by catkin_make
  devel/              <- Autogenerated by catkin_make

Creating your project

To create your rosjava project inside the workspace, use the catkin tools:

roscd java_projects
catkin_create_rosjava_project my_project
cd my_project/

This creates the directory structure, but you also need to set up the build instructions: Edit build.gradle so that it looks like this:

apply plugin: 'application'
apply plugin: 'eclipse'
 
mainClassName = 'org.ros.RosRun'

dependencies {
   compile 'org.ros.rosjava_core:rosjava:[0.1,)'
}

The dependencies section tells gradle to include the rosjava libraries on the class path. If you are using messages (for example, LaserScan) then you need to also include them as dependencies.

Next, you can start creating you code inside the src/main/com/github/uobirlab/my_project folder. (Or whatever package path you choose). The default "Dude.java" file can safely be deleted.

Compiling and executing your nodes

Running your own code is done in the same way as for the examples. First, use gradle to compile your project:

roscd java_projects/my_project
../gradlew installApp

Then rebuild the catkin workspace:

cd ../../..
catkin_make

And finally, run your nodes with:

roscd java_projects/my_project
./build/install/my_project/bin/my_project com.github.uobirlab.my_project.MyNodeMainClass
Clone this wiki locally