Android ROS Message crash

asked 2018-02-25 23:12:44 -0500

ByteMonster gravatar image

This question is a continuation of a previous asked question that I made, posted at . I tried to use the from this Github repository . However I got a crash with no error message when I try to send a message.

The main idea of the functionality is to type a message to send to ROS via ROSJava that is collected from an Android Dialog Box . So say for example you send a message with the contents "Go here". My Android app would crash before the dialog box shows up. Can anyone give me an idea what is wrong with my code and a way to fix my issue?

In regards to the "Talker" class that class is a model class in my application.

I will post my code below.

  public void executeCommand(NodeMainExecutor nme){

      java.lang.String command = dialogBoxCommand();

      Talker talker = new Talker();
 socket = new, getMasterUri().getPort());
 local_network_address = socket.getLocalAddress();
          NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic(local_network_address.getHostAddress(), getMasterUri());

          java.lang.String commandTopic = "/rosout";

          NameResolver appNameSpace = getMasterNameSpace();
          commandTopic = appNameSpace.resolve(commandTopic).toString();


      }catch (IOException e) {
          Toast.makeText(getApplicationContext(), "Unable to execute command",Toast.LENGTH_SHORT).show();

  protected java.lang.String dialogBoxCommand(){

      AlertDialog.Builder builder = new AlertDialog.Builder(this);

      final EditText input = new EditText(this);


      builder.setPositiveButton("Start Command", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
              final java.lang.String command = input.getText().toString();
      builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
      return input.getText().toString();
edit retag flag offensive close merge delete


ok so I realised I had to put previous two lines within the try catch statement. That is done now.The only thing is the message is not sent over.

ByteMonster gravatar image ByteMonster  ( 2018-02-25 23:45:19 -0500 )edit

Now I just can't figure out why it can't send any messages to ROS. Can someone help me? I have been going at it for a while and can't figure it out.

ByteMonster gravatar image ByteMonster  ( 2018-02-26 00:17:38 -0500 )edit

One thing to check: ROS nodes need to be able to resolve hostnames to IP addresses -- or only use IP addresses -- when sending msgs. If you don't have a working DNS for all hosts (ie: a local router), then try to configure ROS_IP on all hosts, and use an IP-only master URL.

gvdhoorn gravatar image gvdhoorn  ( 2018-02-26 01:39:23 -0500 )edit

What exception are you getting? Try debugging with logcat: .

That will give you more clues. The problem may be completely unrelated to the code you posted. What does Talker do? Is it just the regular publisher from the examples?

jubeira gravatar image jubeira  ( 2018-02-26 07:40:37 -0500 )edit

@juberia The talker class is similar to the one that was in your Git repository that I linked, except it just has a get and set for a message.

I also did some testing on the code and it seems that the dialog box will show up but will not send the message. The catch statement would show an error.

ByteMonster gravatar image ByteMonster  ( 2018-02-26 16:36:58 -0500 )edit

I don't understand why you need all that socket open / close code. Did you try debugging with logcat?

jubeira gravatar image jubeira  ( 2018-02-28 12:06:53 -0500 )edit