Ask Your Question
0

Running rosjava node on an android device - crashes

asked 2012-02-04 20:50:07 -0500

svepe gravatar image

updated 2014-01-28 17:11:16 -0500

ngrennan gravatar image

I am trying to write a node that is supposed to run on an android device. Here is the code I have; basically I want to create a node when a button is clicked (I know it is not a good idea to do it on the UI thread, but this is just for testing purposes). The node itself extends MainNode and publishes a string to a topic.

Button send_btn;
TalkerNode node;
NodeMainExecutor exec;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    send_btn = (Button)findViewById(R.id.send_button);
    send_btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v)
        {
            send_btn.setText(R.string.sending);
            String masterUri = "http://192.168.1.35:11311";
            URI uri;
            NodeConfiguration node_conf;
            try 
            {
                uri = new URI(masterUri);
                String host = InetAddressFactory.newNonLoopback().getHostAddress();
                node_conf = NodeConfiguration.newPublic(host);
                node_conf.setNodeName("android_node");
                node_conf.setMasterUri(uri);
            } 
            catch (URISyntaxException e) 
            {
                e.printStackTrace();
                return;
            }
            node = new TalkerNode();

            exec = DefaultNodeMainExecutor.newDefault();
            exec.execute(node, node_conf);
        }
    });
}

Everything compiles, the program on the device starts, but it crashes at the line:

String host = InetAddressFactory.newNonLoopback().getHostAddress();

with error - NoClassDefFoundError for the class com.google.common.collect.Lists. Moreover, I tried to set the host manually as the ip of the device, but then the program crashes on the next line:

node_conf = NodeConfiguration.newPublic(host);

with error - NoClassDefFoundError for the class com.google.common.base.Preconditions. I tried importing com.google.common.*, but it didn't help. Any clue how I can fix it? I am using android API level 10 and have pulled rosjava from the repository yesterday.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

answered 2012-02-04 22:11:33 -0500

svepe gravatar image

I found out that I need guava, so I have just put it and this solved the problem, but now I am getting SocketException at the same line.

edit flag offensive delete link more
1

answered 2012-02-06 10:10:52 -0500

selliott gravatar image

I'm not sure if this will help, but here's an example of how I'm currently creating a node using DefaultNodeFactory with the newest rosjava:

NodeMainExecutor nodeMainExecutor = DefaultNodeMainExecutor.newDefault(); 
node = new DefaultNodeFactory(nodeMainExecutor.getScheduledExecutorService()).newNode(config);
edit flag offensive delete link more

Comments

It still crashes... I guess I will have to wait a bit until they write up some documentation.
svepe gravatar image svepe  ( 2012-02-07 06:17:28 -0500 )edit

Have you also updated your appmanandroid library? Parts of that library were updated to match with the newest rosjava. Wthout actually seeing your errors, I'd say that outdated appmanandroid parts could cause errors with NodeRunner and DefaultNodeFactory.

selliott gravatar image selliott  ( 2012-02-17 10:27:58 -0500 )edit
0

answered 2012-02-05 01:46:59 -0500

svepe gravatar image

So solved the problem by setting the host name to the IP of the device, but now the TalkerNode crashes. I tried different ways to create a node but all examples seem to be outdated with the NodeRunner and the DefaultNodeFactory. Are there any examples for the new structure of rosjava?

edit flag offensive delete link more

Comments

If you build rosjava_core and android_core from source, all of the examples (*_tutorial packages) are up to date.

damonkohler gravatar image damonkohler  ( 2012-02-23 03:35:39 -0500 )edit

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2012-02-04 20:50:07 -0500

Seen: 1,078 times

Last updated: Feb 06 '12