Ask Your Question
0

Occupancy grid ChannelBuffer

asked 2012-11-02 01:28:13 -0600

camilla gravatar image

updated 2014-01-28 17:14:08 -0600

ngrennan gravatar image

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-11-12 22:54:03 -0600

damonkohler gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-11-02 01:28:13 -0600

Seen: 420 times

Last updated: Nov 12 '12