0
$\begingroup$

Rosanswers logo

I was getting a compilation error in a node that creates an OccupancyGrid message. The method setData in the OccupancyGrid class used to have a byte[] parameter, but the parameter is now a ChannelBuffer. So I changed the code from:

grid.setData(data);

to:

ChannelBuffer buffer = ChannelBuffers.copiedBuffer(data);
grid.setData(buffer);

But now i get this exception when i run the node:

Exception in thread "pool-1-thread-3" 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 org.ros.internal.message.$Proxy2.setData(Unknown Source)
    at org.lejos.ros.nodes.PublishOccupancyMap.onStart(PublishOccupancyMap.java:141)
    at org.ros.internal.node.DefaultNode$5.run(DefaultNode.java:506)
    at org.ros.internal.node.DefaultNode$5.run(DefaultNode.java:503)
    at org.ros.concurrent.EventDispatcher.loop(EventDispatcher.java:43)
    at org.ros.concurrent.CancellableLoop.run(CancellableLoop.java:56)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

What is wrong with my code?


Originally posted by camilla on ROS Answers with karma: 255 on 2012-11-02

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

See: http://code.google.com/p/rosjava/source/browse/rosjava_bootstrap/src/main/java/org/ros/internal/message/field/ChannelBufferField.java#55

You need to set the byte order of your ChannelBuffer to little endian. Be careful that you copy the data correctly as well.


Originally posted by damonkohler with karma: 3838 on 2012-11-12

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.