I'm trying to write an app that can receive sensor_msgs/Image messages on an android device. I've modelled the code after android_tutorial_pubsub:
import org.ros.address.InetAddressFactory; import org.ros.android.BitmapFromImage; import org.ros.android.RosActivity; import org.ros.android.views.RosImageView; import org.ros.node.NodeConfiguration; import org.ros.node.NodeMainExecutor; import android.os.Bundle; public class MainActivity extends RosActivity { private RosImageView rosImageView; public MainActivity() { super("Android App", "Android App"); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); rosImageView = (RosImageView)findViewById(R.id.imageView1); rosImageView.setTopicName("/camera/rgb/image_color"); rosImageView.setMessageType("sensor_msgs/Image"); rosImageView.setMessageToBitmapCallable(new BitmapFromImage()); } @Override protected void init(NodeMainExecutor nodeMainExecutor) { NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic(InetAddressFactory.newNonLoopback().getHostName()); nodeConfiguration.setMasterUri(getMasterUri()); nodeMainExecutor.execute(rosImageView, nodeConfiguration.setNodeName("myapp/image_listener")); } @Override protected void onDestroy() { super.onDestroy(); } }
I am able to connect to the ROS master just fine:
~$ rosnode list /myapp/image_listener /rosout
It is properly subscribed:
~$ rostopic info /camera/rgb/image_color Type: sensor_msgs/Image Publishers: None Subscribers: * /myapp/image_listener (http://192.168.0.116:50285)
When I use rosbag play on a bag file, it shows the publisher:
~$ rostopic info /camera/rgb/image_color Type: sensor_msgs/Image Publishers: * /play_1333677784320867515 (http://192.168.0.119:44669/) Subscribers: * /myapp/image_listener (http://192.168.0.116:50285)
But that's the end of good behavior. The image does not appear in the image view. Here is my res/layout/main.xml:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <org.ros.android.views.RosImageView android:id="@+id/imageView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" /> </LinearLayout>
Before I start rosbag play, I am able to exit the app and re-enter no problem. Once the publishing starts, the app is pretty much frozen.
roswtf doesn't tell me anything interesting (I ran rosbag a second time, so the play node number is different).
~/ros_workspace/android_core/android_image_listener$ roswtf Loaded plugin tf.tfwtf No package or stack in context ================================================================================ Static checks summary: No errors or warnings ================================================================================ Beginning tests of your ROS graph. These may take awhile... analyzing graph... ... done analyzing graph running graph rules... ... done running graph rules Online checks summary: Found 2 warning(s). Warnings are things that may be just fine, but are sometimes at fault WARNING Node [/myapp/image_listener] is not connected to anything WARNING The following nodes are unexpectedly connected: * /play_1333678178991195080->/rosout (/rosout) * unknown (http://192.168.0.116:50933/)->/rosout (/rosout)
logcat gives me a bunch of (nonstop):
D/dalvikvm( 3678): GC_CONCURRENT freed 2048K, 25% free 34961K/46599K, paused 2ms+4ms D/dalvikvm( 3678): GC_CONCURRENT freed 2048K, 25% free 34961K/46599K, paused 2ms+4ms D/dalvikvm( 3678): GC_CONCURRENT freed 2048K, 25% free 34961K/46599K, paused 2ms+4ms D/dalvikvm( 3678): GC_CONCURRENT freed 2048K, 25% free 34961K/46599K, paused 2ms+4ms
and I can get in logcat (after running rosbag a few times):
E/dalvikvm-heap( 3678): Out of memory on a 4021256-byte allocation. I/dalvikvm( 3678): "New I/O client worker #1-1" prio=5 tid=16 RUNNABLE I/dalvikvm( 3678): | group="main" sCount=0 dsCount=0 obj=0x4090a190 self=0x1c1d18 I/dalvikvm( 3678): | sysTid=3717 nice=0 sched=0/0 cgrp=default handle=1856392 I/dalvikvm( 3678): | schedstat=( 8249665000 1452014000 9972 ) utm=810 stm=14 core=1 I/dalvikvm( 3678): at java.util.ArrayList.add(ArrayList.java:~118) I/dalvikvm( 3678): at org.ros.internal.message.ListField.deserialize(ListField.java:75) I/dalvikvm( 3678): at org.ros.internal.message.DefaultMessageDeserializer.deserialize(DefaultMessageDeserializer.java:47) I/dalvikvm( 3678): at org.ros.internal.transport.IncomingMessageQueue$Receiver.messageReceived(IncomingMessageQueue.java:57) I/dalvikvm( 3678): at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:100) I/dalvikvm( 3678): at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545) I/dalvikvm( 3678): at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754) I/dalvikvm( 3678): at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:302) I/dalvikvm( 3678): at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:317) I/dalvikvm( 3678): at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:299) I/dalvikvm( 3678): at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:214) I/dalvikvm( 3678): at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:80) I/dalvikvm( 3678): at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545) I/dalvikvm( 3678): at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754) I/dalvikvm( 3678): at org.jboss.netty.channel.SimpleChannelHandler.messageReceived(SimpleChannelHandler.java:154) I/dalvikvm( 3678): at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:100) I/dalvikvm( 3678): at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545) I/dalvikvm( 3678): at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754) I/dalvikvm( 3678): at org.jboss.netty.channel.SimpleChannelHandler.messageReceived(SimpleChannelHandler.java:154) I/dalvikvm( 3678): at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:100) I/dalvikvm( 3678): at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545) I/dalvikvm( 3678): at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:540) I/dalvikvm( 3678): at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274) I/dalvikvm( 3678): at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261) I/dalvikvm( 3678): at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:349) I/dalvikvm( 3678): at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:280) I/dalvikvm( 3678): at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:200) I/dalvikvm( 3678): at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) I/dalvikvm( 3678): at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:44) I/dalvikvm( 3678): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081) I/dalvikvm( 3678): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:574) I/dalvikvm( 3678): at java.lang.Thread.run(Thread.java:1020) I/dalvikvm( 3678): W/DefaultChannelPipeline( 3678): An exception was thrown by a user handler while handling an exception event ([id: 0x40a8e7f8, /192.168.0.116:46517 :> 192.168.0.119/192.168.0.119:58427] EXCEPTION: java.lang.OutOfMemoryError) W/DefaultChannelPipeline( 3678): org.ros.exception.RosRuntimeException: java.lang.OutOfMemoryError W/DefaultChannelPipeline( 3678): at org.ros.internal.transport.ConnectionTrackingHandler.exceptionCaught(ConnectionTrackingHandler.java:73) W/DefaultChannelPipeline( 3678): at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:432) W/DefaultChannelPipeline( 3678): at org.jboss.netty.channel.AbstractChannelSink.exceptionCaught(AbstractChannelSink.java:52) W/DefaultChannelPipeline( 3678): at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:302) W/DefaultChannelPipeline( 3678): at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:317) W/DefaultChannelPipeline( 3678): at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:299) W/DefaultChannelPipeline( 3678): at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:214) W/DefaultChannelPipeline( 3678): at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274) W/DefaultChannelPipeline( 3678): at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261) W/DefaultChannelPipeline( 3678): at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:349) W/DefaultChannelPipeline( 3678): at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:280) W/DefaultChannelPipeline( 3678): at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:200) W/DefaultChannelPipeline( 3678): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081) W/DefaultChannelPipeline( 3678): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:574) W/DefaultChannelPipeline( 3678): at java.lang.Thread.run(Thread.java:1020) W/DefaultChannelPipeline( 3678): Caused by: java.lang.OutOfMemoryError W/DefaultChannelPipeline( 3678): at java.util.ArrayList.add(ArrayList.java:118) W/DefaultChannelPipeline( 3678): at org.ros.internal.message.ListField.deserialize(ListField.java:75) W/DefaultChannelPipeline( 3678): at org.ros.internal.message.DefaultMessageDeserializer.deserialize(DefaultMessageDeserializer.java:47) W/DefaultChannelPipeline( 3678): at org.ros.internal.transport.IncomingMessageQueue$Receiver.messageReceived(IncomingMessageQueue.java:57) W/DefaultChannelPipeline( 3678): ... 12 more
So it looks like an ArrayList was filled until it could no longer be filled. What is doing that filling? Why aren't my images showing up?
Can you give me an idea on how to debug this?
Sorry that this was very long. Hopefully I provided all the relevant information.
Technical specs:
Ubuntu 10.04 running in VMWare
Target: android-12
Android SDK Tools r17
rosjava_core, android_core cloned today
EDIT: I edited the above text to say that I don't always get the exceptions. It takes multiple time of running rosbag. For the most part, I just see an endless stream of GC_CONCURRENT.
Originally posted by amigo on ROS Answers with karma: 93 on 2012-04-05
Post score: 1