Coder Social home page Coder Social logo

spyroskou / plain-ros-java-system-example Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 1.0 138 KB

A ROS system running completely on Java. No ROS installation required. The system includes a Java roscore, a Topic Publisher, a Topic Subscriber, a Service Server and a Service Client.

License: Apache License 2.0

Java 100.00%
java ros ros-java gradle publisher subscriber service topic

plain-ros-java-system-example's Introduction

ROS Java contains a plain java, standalone version of roscore that does not require any ROS instalation to be present. This is an example ROS system running completely on Java with no ROS instalation required. It is an example that demonstrates running a roscore and four rosjava ROS nodes. A Topic Publisher, a ROS Topic Subscriber, a ROS Service Server and a Service Client.

This example project demonstrates how to do the following programmatically through the ROS Java API:

  1. Create, start and shutdown the Java roscore
  2. Create, start and shutdown ROS nodes
  3. Publish and subscribe to a ROS topic
  4. Create a ROS Service Server and call it from a ROS Service Client

This repository also provides an example that demonstrates how to run rosjava with an another roscore. E.g. cpp roscore from ROS noetic.
A version of this repository that uses custom ROS messages is available here.

Requirements

In order to compile and run this project only Java needs to be installed. GIT also makes getting the source very easy. Links are provided for convenience.

  • GIT , in order to clone the project repository
  • JDK, the project has been developed and tested using JDK 17
  • Gradle, is used for project compilation. Installing it is not required. Following the instructions below will automatically download gradle 7.5 and ignore any existing installation.

Quick Instructions for Windows Power Shell

  1. Clone the project repository: git clone https://github.com/SpyrosKou/Plain-ROS-Java-System-Example.git

  2. Go into the cloned repository directory: cd .\Plain-ROS-Java-System-Example\

  3. Compile the project and prepare for running: gradlew installDist

  4. Run the project using the generated script: .\build\install\Plain-ROS-Java-System-Example\bin\Plain-ROS-Java-System-Example.bat

  5. Build and run in a single command using the gradle application plugin: gradlew run

Quick Instructions for Linux

  1. Clone the project repository: git clone https://github.com/SpyrosKou/Plain-ROS-Java-System-Example.git

  2. Go into the cloned repository directory: cd Plain-ROS-Java-System-Example/

  3. Add execute permission to gradlew script: sudo chmod +x gradlew

  4. Compile the project and install it locally: gradlew installDist

  5. Run the project using the generated script: ./build/install/Plain-ROS-Java-System-Example/bin/Plain-ROS-Java-System-Example

  6. Build and run in a single command using using the gradle application plugin: gradlew run

Using with an existing, external, non-rosjava roscore

It is possible to use rosjava to run rosjava nodes in an environment where a ros system is already running. E.g. a cpp noetic ros instance. An example on how to run rosjava nodes programmatically without starting roscore is provided in MainExternal Note that if a roscore is not running, then this example will not run correctly. In order to use it do the following:

  1. Set ROS_MASTER_URI and ROS_IP environment variables. Both these variables are needed. If these environment variables are missing, you will see some errors in step 4 below. The following commands assumes the example and roscore run in 127.0.0.1 aka localhost.
    export ROS_MASTER_URI=http://127.0.0.1:11311
    export ROS_IP=http://127.0.0.1:11311

  2. Start roscore Run the following: roscore

  3. With the roscore already started externaly run MainExternal

  4. You can start directly the MainExternal from the gradle by running: ./gradlew runWithExternalRos

plain-ros-java-system-example's People

Contributors

spyroskou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

suc1

plain-ros-java-system-example's Issues

Custom android project merging with Plain-ROS-Java-System-Example

Dear SpyrosKou,

Greetings! First of all, thank you for you clean and straight forward example. I am a student that completely new to ROS. I am currently working on a personal android-ROS communication project. However, the version problem annoyed me for a whole month, your project gave me the direction of ROS functions. I am sorry if I ask stupid question, how can I make the functions work if I want to communicate with ROS through android? (Like the app "ROSandroid") I would like to receive map data from ROS robot that my friend working on and visualize it on the phone. May you kindly point me some directions? As this project is the most updated source that I can find through out these two months. I know this is not an project issue but I will keep learning and any guidance are welcome! Thank you so much for you time and the example project!

Best
Percival

Question about using ROSJAVA with existing ros network

Thank you for providing a good code!

Since ros noetic is not supported by rosjava, I would like to implement communication with the rospy nodes of the existing ros noetic communication using the ROSJAVA code you provided.

May I know if your ROSJAVA can be used in parallel with the existing ros network?

Once again, thank you for providing a good and useful code!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.