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

Rosjava image_transport tutorial - no image display on android tablet despite successful compilation

asked 2011-08-04 09:10:24 -0600

Tuan gravatar image

Hi, 

I am trying out the rosjava image_transport tutorial by importing it as an android project in Eclipse and port it to a Motorola Xoom.

To get the sample code to compile, I have modified it slightly (see code fragment below) and also delete the line in main.xml that contains the android:src=”@drawable/” as it could not be resolved.

Problem:

Image is not displayed although checks show that the node is connected to host PC roscore (rxgraph shows android node and shows that it subscribes to /camera/image/compressed for the correct message sensor_msgs/CompressedImage)

I have tried to call a similar subscriber node - code from ( http://www.ros.org/wiki/image_transpo... ) on my PC and I can retrieve a static image. I look through the code for this node and it required OpenCV to display the image through the bridge class.

For the Xoom, I guess I just miss one line of code that call the image to display on the Xoom. I look through the RosImageView class and I guess the line image.setMessageToBitmapCallable(new BitmapFromCompressedImage()); will serve a similar function.

However, no image is shown on the Xoom.

Could any one offer help on this please?

Please refer to the code fragment below and my configuration.

...   public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

//1. Initialise connection to host PC here    

try {

//2.1 First manually set the URI & port of MASTER node (the node that contains roscore)   

java.net.URI master_uri = new java.net.URI("http://129.31.193.253:11311");

   //2.2 Assign the configuration to the tablet with its own address so that roscore can talk back to

  nodeConfiguration = NodeConfiguration.newPublic("129.31.202.25",master_uri);

   //2.3 Add the master URI & port set up in 2.1 to the configuration

  nodeConfiguration.setMasterUri(master_uri);

} catch (Exception e) {

  throw new RuntimeException(e);

}

//retrieving the image from host

    image = (RosImageView<compressedimage>) findViewById(R.id.image_);

    image.setTopicName("/camera/image/compressed");

    image.setMessageType("sensor_msgs/CompressedImage");

    image.setMessageToBitmapCallable(new BitmapFromCompressedImage());

//    startActivityForResult(new Intent(this, MasterChooser.class), 0); // comment because causing forced close

    try{

     nodeRunner.run(image,nodeConfiguration);

    }

    catch(Exception e){

     throw new RuntimeException(e);

    }     

  }

My configuration is as follows:

Basic

  • Ubuntu 10.10 

  • ROSDiamondback

  • Porting into a Motorola Xoom (wifi) – android API level 11 (but I compile at level 9)

  • Have already successfully tested RosjavaPubSub tutorial

ROS

  • Host PC running roscore

  • Host PC running image_transport publisher that publishes a static image - exactly the same code as the tutorial at

http://www.ros.org/wiki/image_transpo...

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
3

answered 2011-08-05 05:04:41 -0600

Tuan gravatar image

Hi,

I actually have solved the problem by now. I think the solution was mentioned somewhere in ROSAnswer already so I would not take credit for it.

The solution is to set ROS_IP in the host PC to its IP address so that it can communicate.

This step is simple but can be easily overlooked. As I got the rosjava pub_sub tutorial to work, I ignored setting ROS_IP because I think I do not need to do so. However, a colleague aptly reminded me that the pub_sub tutorial only tested one way connection from the Android tablet to PC but not the other way round. For the other way to work (e.g sending images from host PC to the android device), you will need to set ROS_IP.

In order to set ROS_IP: $export ROS_IP=ip_adress

To check whether IP has been set: $echo $ROS_IP You should see your computer IP address.

Hopefully this will help someone else with the same problem as well.

edit flag offensive delete link more
0

answered 2018-10-15 05:15:19 -0600

bhattarairazu gravatar image

I had the same problem and I could not figure out how could I solve it.Can you please help me @Tuan

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2011-08-04 09:10:24 -0600

Seen: 2,062 times

Last updated: Oct 15 '18