ROS-TCP-Connector icon indicating copy to clipboard operation
ROS-TCP-Connector copied to clipboard

When I publish a jpeg image to unity this error appears in ROS terminal: struct.error: unpack requires a buffer of 5 bytes

Open emiyashirou1531 opened this issue 3 years ago • 0 comments

ROS tcp endpoint does not allow me to publish jpeg image from Unity to ROS I'm using ros tcp endpoint v0.6.0 my problem main problem is that i want to publish unity camera image(Imagemsg) to ROS from an android device but the delay when i view in rviz is very high like 15-20 seconds using 1920 x 1080 resolution, so I tried to use send jpeg image (CompressedImagemsg) since jpeg is a highly compressed image, after I publish jpeg image i get this error from ROS .

struct.error: unpack requires a buffer of 5 bytes raise genpy.DeserializationError(e) # most likely buffer underfill genpy.message.DeserializationError: unpack requires a buffer of 5 bytes

how do i fix this?

This is my code for converting to jpeg

void SendJPEGImage(Texture2D _image) { byte[] data = _image.EncodeToJPG();

string picString = Convert.ToBase64String(data);
Debug.Log ("data length: " + data.Length);

// set format
string format = "jpeg";

//CompressedImageMsg(HeaderMsg header, string format, byte[] data)
    byte[] array = Encoding.ASCII.GetBytes(picString);
    HeaderMsg header = new HeaderMsg();
    var compressedImageMsg = new CompressedImageMsg(headerMessage, format, array);

    ros.Publish(topicName, compressedImageMsg);

}

Environment (please complete the following information, where applicable):

  • Unity Version: [2020.3.34f1]
  • Unity machine OS + version: [Windows 10]
  • ROS machine OS + version: [Ubuntu 20.04, ROS Noetic]
  • ROS–Unity communication: [ros-tcp-connector]
  • Branch or version: [v0.6.0]

Additional context please help my i have to finish this problem quick so I can proceed to another part in my project i've been stuck on this for a week please help me

emiyashirou1531 avatar Jun 08 '22 01:06 emiyashirou1531