Ask Your Question
0

Communicate between Android and ROS threads

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

TristanKpka gravatar image

Hello,

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(){
    m_thread.start();
}

@Override
public void run() {
    // start your classic ROS node (spin()) in a dedicated thread
    startROSNode();
}

//load C/C++ shared library
static
{
    System.loadLibrary("ros_main");
}
private native void startROSNode();
}

Which is launched in the Activity class

ROSThread rosThread = new ROSThread();
rosThread.rosrun();

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
0

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

jubeira gravatar image

@TristanKpka take a look at this post: https://answers.ros.org/question/2729... .

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 168 times

Last updated: Oct 13 '17