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!
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)
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
First, install rosjava itself
python
sudo apt-get install ros-kinetic-rosjava
Install rosjava with
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
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
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
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.
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