Ask Your Question

Dynamic information flow between ROSJAVA nodes and ROSActivity

asked 2013-02-18 12:55:14 -0500

updated 2014-01-28 17:15:18 -0500

ngrennan gravatar image

Hi All,

When using ROSJAVA with android I'd like to pass information from the ROSActivity gui to the ros_node implementing nodeMain. Is there a way to do this without using the normal ROS message traffic?

If there is, how is it done?



edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-02-19 10:31:25 -0500

damonkohler gravatar image

There's a lot of options here. You're basically asking how to write a multi-threaded Activity. This tutorial seems to cover a lot of the various concepts:

edit flag offensive delete link more


I looked at the handlers type of processing but in the tutorial, it mentioned that it must be run in the same scope as the main activity. I attribute my failure to the fact that I'm trying to update a handler inside my class and therefore out of scope. What method do you recommend?

PeterMilani gravatar image PeterMilani  ( 2013-03-01 14:41:33 -0500 )edit

answered 2013-03-05 02:05:28 -0500

updated 2013-03-05 02:08:19 -0500

Based off Damon's answer, I applied the transfer of information between threads by using an application class as described in his link and elaborated here

To use the application class which contains the data I wanted to transfer. I created a global instance in the mainActivity onCreate() method, then I created my node classes, passing the instance of the application to them like this:

    protected void onCreate(Bundle savedInstanceState) {
        rApplication = (ROSApplication)getApplicationContext();
        interfacenode= new cartesian_interface_node(rApplication);
        statusupdate = (TextView) findViewById(;

After the in the init() method after all the nodes had been set running by the nodeMainExecutor, I passed to a function called loop() and placed the following code.

protected void loop()
    while (true)
        runOnUiThread(new Runnable() {
            public void run() {

        try {
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block

there's probably a more correct way to implement the loop other than the while loop, but it is effective and the update to ui works! The power of Android UI and ROS!

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


Asked: 2013-02-18 12:55:14 -0500

Seen: 859 times

Last updated: Mar 05 '13