Problem publish std_msgs/String with roslibjs.

asked 2017-05-11 08:39:49 -0500

Pennywise_vigo gravatar image

updated 2017-05-11 09:11:24 -0500


i send a problem with I publish a std_msgs/String from jsvascript (roslibjs and websockets). I need send a protocol with first bytesis 0xAA.

in js I send:

     var header= "\xAA";

    //var header= Uint8Array.of(\xAA,\xAA);

    console.log("header vale:"+header);
    console.log("header length"+header.length);
    //header=String.fromCharCode.apply(null, header);
    //header=String.fromCharCode.apply(null, header);

    console.log("Header length "+header.length);
    console.log("Data length "+Data.length);

    var msg=new ROSLIB.Message({
        data: header

    pub.publish (msg);

The header length is 1 and the content is 0xAA

When I read a topic in c++ node receiver a 2 bytes: {0xc2,0xAA}

if i send 0xAAAA in c++ node i receiver {0xc2,0xAA}

Which may be due?


if I send \x10 -> Reception OK 1 byte => 0x10

I send \xC0 -> Reception NO OK 2 bytes => {0xc3 0x80}


edit retag flag offensive close merge delete