ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org

Sending a Byte Array Message

kinetic

#1

Hi

I’m looking to send a byte multi array message from rosjava.

I’m using this structure but the apps in Android stop automatically when execute nuevo.setdata(eee).

std_msgs.ByteMultiArray nuevo = pubremotecontrol.newMessage();
ChannelBuffer eee= ChannelBuffers.dynamicBuffer();
eee.writeInt(4);
eee.writeBytes(new byte[] {0x22,0x32,0x22,0x11});

                                                           //copiedBuffer(new byte[] {0x22,0x32,0x22,0x11});
                                                   nuevo.setData(eee);
                                                   pubremotecontrol.publish(nuevo);

#2

Hi Gabriel,
Can you paste the error message from logcat?
Also you can check this example to compare.


#3

08-30 16:28:00.651 16610-16610/? E/Zygote: MountEmulatedStorage()
08-30 16:28:00.651 16610-16610/? E/Zygote: v2
08-30 16:28:00.656 16610-16610/? E/SELinux: [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
08-30 16:28:04.626 16610-16697/com.baro.barosystem.barocar E/Resources: RunTimeException
android.content.res.Resources$NotFoundException: Resource ID #0x7f02005a
at android.content.res.Resources.getValue(Resources.java:2345)
at android.content.res.Resources.startRC(Resources.java:1059)
at android.app.ActivityThread$mRunnable.run(ActivityThread.java:2517)
at java.lang.Thread.run(Thread.java:818)
08-30 16:28:08.256 16610-16819/com.baro.barosystem.barocar E/AndroidRuntime: FATAL EXCEPTION: pool-2-thread-18
Process: com.baro.barosystem.barocar, PID: 16610
java.lang.IllegalArgumentException
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:76)
at org.ros.internal.message.field.ChannelBufferField.setValue(ChannelBufferField.java:55)
at org.ros.internal.message.MessageProxyInvocationHandler.invoke(MessageProxyInvocationHandler.java:46)
at java.lang.reflect.Proxy.invoke(Proxy.java:397)
at org.ros.internal.message.$Proxy2.setData(Unknown Source)
at com.baro.barosystem.barocar.RosAlive$1.loop(RosAlive.java:109)
at org.ros.concurrent.CancellableLoop.run(CancellableLoop.java:56)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)