A story about developing ROS called rosjava with java

Based on the heretical idea that I really want to write ROS in java, it supports an environment where the formula can be developed even in java called rosjava, and it was the best to use (there are individual differences), so I will summarize it here. More and more

I want more ROS java development to spread!

usage environment

This is the environment I am using. Please for reference ubuntu16.04 (Japanese version) ROS ( kinetic ) java8 (It seems that java9 does not support it?) gradle (probably needed)

0. About pre-introduction

As for the installation of ROS and java, we will proceed on the assumption that it has already been completed, so if you have not done so, please complete the installation. I think that the installation method is also on the official page

1. Introduction

1.1 Installing rosjava

First, install rosjava itself

python


sudo apt-get install ros-kinetic-rosjava

Install rosjava with

1.2 Creating a workspace

Perhaps those who are already using ROS will have catkin_ws in their Home directory There is no problem if you make it together in it, but a little trouble will occur later, so I will make it separately here. Here, create it with the name catkin_ws_java

Under the Home directory

python


mkdir catkin_ws_java
cd catkin_ws_java
mkdir src
cd src
catkin_init_workspace

To create a workspace for rosjava by executing each in turn

1.3 Creating a project or package

Next, make a package for rosjava

Here, packages and projects can be created by entering the following.

python


catkin_create_rosjava_pkg arbitrary package name

python


catkin_create_rosjava_project Arbitrary project name

(It seems that uppercase letters cannot be used in each arbitrary name)

In the following, we will talk on the assumption that the arbitrary package name is test_pkg and the arbitrary project name is test_pj.

Go back to your Home directory

python


cd catkin_ws_java/src

Move with

python


catkin_create_rosjava_pkg test_pkg

If the following command is output, the package creation is successful.

python


BUILD SUCCESSFUL

Total time: 8.479 secs

This completes the package creation Move into the project created as it is

python


cd test_pkg

Then create a project

python


catkin_create_rosjava_project test_pj

If the following command is output, the project creation is successful. rosjava is a beginner-friendly specification that creates a tutorial-like basic file every time you create a project Talker and Listener are mainly used in this.

python


Creating rosjava project 
  Name      : test_pj
  File      : build.gradle
  File      : settings.gradle
  File      : Talker.java
  File      : Listener.java
  File      : CMakeLists.txt (gradle task update)

By the way, the file structure of rosjava is

python


src ┳ Project A
┃┣ Package B
┃┗Package C
    ┃ 
┗ Project E
┣ Package F
┗ Package G

Can be expanded in the form of

1.4 catkin_make

So far, I just created a package and a project and it can not be used as it is, so catkin_make However, rosjava's catkin_make is a sad specification that can only be used online. However, this can be avoided and will be described in another article.

python


cd ~/catkin_ws_java

Return to the workspace with

python


catkin_make

There is no problem if the following output is output

python


[100%] Built target gradle-test_pkg

Even if the following output is output, there is no problem, so you can ignore it. It is possible as long as there is no wording that it failed.

python


warning: [options]Bootstrap classpath-source 1.Not set with 7

2. Run rosjava

All you have to do is run rosjava Run rosjava from a shell file, not from a launch file

First, move to the location where the shell script is

python


cd ~/catkin_ws_java/src/test_pkg/test_pj/build/install/test_pj/bin

Here is the shell and bat file Let's check with the ls command

Decide which node to launch next This time this project has a Talker and a Listener Launch Listener first

First of all, if roscore is not started, there is nothing you can do, so start it in another terminal

python


roscore

Next, launch Listner (execution directory is the bin directory)

python


bash test_pj com.github.rosjava.test_pkg.test_pj.Listener

Then launch Talker in another terminal (also move to bin with the cd command)

python


bash test_pj com.github.rosjava.test_pkg.test_pj.Listener

Now at the terminal on the Listner side

python


5 10, 2018 8:20:38 am org.ros.internal.node.RosoutLogger info
information: I heard: "Hello world! 3"
5 10, 2018 8:20:39 am org.ros.internal.node.RosoutLogger info
information: I heard: "Hello world! 4"
5 10, 2018 8:20:40 am org.ros.internal.node.RosoutLogger info
information: I heard: "Hello world! 5"
5 10, 2018 8:20:41 am org.ros.internal.node.RosoutLogger info
information: I heard: "Hello world! 6"

Communication is complete if is displayed as

Thank you for staying with us for a long time

From now on, I would like to write a detailed explanation of each, a little more in-depth, and how to make rosjava easier to use.

* Addition

It seems that there are places where it occurs by people and places where it does not occur In gradle related, such as when the first package was created

python


Exception in thread "main" java.lang.RuntimeException
java.util.zip.ZipException: error in opening zip file

If you get an error like, please try the following methods

Display hidden files with ctrl + H in your home directory Then you should have a .gradle file Let's get rid of our hearts and just put the .gradle folder in the trash

This is probably the solution. Thank you for your hard work.

Recommended Posts

A story about developing ROS called rosjava with java
[Note] A story about changing Java build tools with VS Code
A story about hitting the League Of Legends API with JAVA
A story about Java 11 support for Web services
A story about the JDK in the Java 11 era
A story about trying to operate JAVA File
[PHP] A story about outputting PDF with TCPDF + FPDI
A story about trying to get along with Mockito
A story about reducing memory consumption to 1/100 with find_in_batches
A story about making catkin_make of rosjava compatible offline
A note about Java GC
A story stuck with NotSerializableException
Story of making a task management application with swing, java
Try developing a containerized Java web application with Eclipse + Codewind
About the behavior when doing a file map with java
A confused story about a ternary operator with multiple conditional expressions
A story about misunderstanding how to use java scanner (memo)
A story that I struggled to challenge a competition professional with Java
Learn about transaction savepoints (with Java)
A really scary (Java anti-pattern) story
About signature authentication with java 1st
The story of making a game launcher with automatic loading function [Java]
A story about creating a service that tells a story of a portfolio by developing alone
A story about a Spring Boot project written in Java that supports Kotlin
[Beginner] A story about starting studying Java for job hunting ~ 2nd month ~
[Beginner] A story about starting studying Java for job hunting ~ 3rd month ~
[Beginner] A story about starting studying Java for job hunting ~ 1st month ~
[Beginner] A story about starting studying Java for job hunting ~ 5th month ~
[Beginner] A story about starting studying Java for job hunting ~ 4th month ~
About returning a reference in a Java Getter
[Creating] A memorandum about coding in Java
A little addictive story with def initialize
Split a string with ". (Dot)" in Java
A story about saving an image with carrierwave in a nested form using a form object.
A story about creating a library that operates next-generation sequencer data with Ruby ruby-htslib
Read a string in a PDF file with Java
About getting a tens digit with "(two-digit integer) / 10% 10"
Create a CSR with extended information in Java
Create a simple bulletin board with Java + MySQL
[Windows] [IntelliJ] [Java] [Tomcat] Create a Tomcat9 environment with IntelliJ
Let's create a timed process with Java Timer! !!
A story about a very useful Ruby Struct class
A story about Apache Wicket and atomic design
[Java] Create a collection with only one element
A story about making a Builder that inherits the Builder
Prepare a scraping environment with Docker and Java
A story about a new engineer reading a passion programmer
Try debugging a Java program with VS Code
I tried to break a block with java (1)
Build a Java development environment with VS Code
[Jackson] A story about converting the return value of BigDecimal type with a custom serializer.
A story about PKIX path building failed when trying to deploy to tomcat with Jenkins
A story about an error collating checksum values after npm install with Laravel Homestead