roslibjs icon indicating copy to clipboard operation
roslibjs copied to clipboard

cbor compression makes an error : "Uncaught Cannot process BSON encoded message without BSON header."

Open HeekonKim opened this issue 6 years ago • 4 comments

I wrote a simple code like below and included it in an html file.

<script type="text/javascript" src="http://static.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>

<script type="text/javascript" src="http://static.robotwebtools.org/roslibjs/current/roslib.min.js"></script>

<script src="bower_components/cbor/cbor.js" type="text/javascript"></script>

<script>

var ros = new ROSLIB.Ros({ url : 'ws://localhost:9090' });

ros.on('connection', function() { console.log('Connected to websocket server.'); });

ros.on('error', function(error) { console.log('Error connecting to websocket server: ', error); });

ros.on('close', function() { console.log('Connection to websocket server closed.'); });

var listener = new ROSLIB.Topic({ ros : ros, name : '/os1_node/points', messageType : 'sensor_msgs/PointCloud2', compression : 'cbor', });

console.log(listener); listener.subscribe( function(message) { } );

</script>

I did 'roscore', 'roslaunch rosbridge_server rosbridge_websocket.launch', and played an appropriate rosbag file, which has a topic named '/os1_node/points'.

But the browser console makes an error "Uncaught Cannot process BSON encoded message without BSON header." at roslib.min.js:1.

The cbor-compressed message can't be decoded because the error comes out even before the function called in listener.subscribe() works.

Thank you.

HeekonKim avatar Jan 22 '19 07:01 HeekonKim

This is happening because the CDN version of roslibjs has not been updated with CBOR support. You can try building roslibjs from the develop branch and loading that instead, or wait for the next release which is currently in progress.

mvollrath avatar Jan 22 '19 15:01 mvollrath

will update cdn within this week.

jihoonl avatar Jan 23 '19 02:01 jihoonl

Thank you for answer. I built from the develop branch and did the same thing but same error occurs. Is there a code using cbor compression that I can refer to?

HeekonKim avatar Jan 23 '19 04:01 HeekonKim

roslib_bench has a docker example.

mvollrath avatar Jan 23 '19 05:01 mvollrath