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

Communicate between Android and ROS threads

asked 2017-05-24 04:58:08 -0500

TristanKpka gravatar image


I have a simple Java class that launch a thread containing a ROS node

public class ROSThread implements Runnable {
private Thread m_thread;

public ROSThread() {
    this.m_thread = new Thread(this);

public void rosrun(){

public void run() {
    // start your classic ROS node (spin()) in a dedicated thread

//load C/C++ shared library
private native void startROSNode();

Which is launched in the Activity class

ROSThread rosThread = new ROSThread();

In this activity, I would like to indicate to my ROS nod that it needs to publish something. Any idea how to do that ?

Thanks in advance,

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-10-13 15:20:49 -0500

jubeira gravatar image

@TristanKpka take a look at this post: .

You need to create a node that can publish something "on demand", and the call that method whenever you want.

Unless you need a package that was already written in Cpp, I would just use the regular nodes provided by rosjava. Those will give you the functionality you need to publish messages.

A bit late, but hope it helps!

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-05-24 04:58:08 -0500

Seen: 231 times

Last updated: Oct 13 '17