groove-x / mqtt_bridge

mqtt_bridge provides a functionality to bridge between ROS and MQTT in bidirectional
MIT License
159 stars 146 forks source link

Keep getting extra data in message #34

Closed cihankurt98 closed 3 years ago

cihankurt98 commented 4 years ago

Let's say im sending the following message:

rostopic pub /velocity std_msgs/String "hello"

I get the following in my MQTT client: ��data�hello

As you can see, I never said something about the unknown character and data part. Where is it coming from? From messagepack? How can I remove it?

cihankurt98 commented 4 years ago

I could remove the strange characters by switching from msgpack to json serialization. However, I don't want the "data" part. I can't do a string remove aswell, somehow it doesn't recognize it.

cihankurt98 commented 4 years ago

It seems like when I go from MQTT to ROS I always get a deserialization error. No matter what serialization package I use. I tried msgpack and cbor2. There is always more data expected then there actually is. It happens when the mqtt_msg is being converted to a ROS message.

msg_dict = self._deserialize(mqtt_msg.payload) The line above gives me the following errors:

msgpack: unpack(b) received extra data.

cbor2: premature end of stream (expected to read 2478212847434349172 bytes, got 4 instead)

mayershoc commented 4 years ago

Hi cihankurt98, are you using python 2 or 3? If you are using python3, this might be related to a deserialization issue I used to get. Feel free to give my fork a try.

ledmonster commented 3 years ago

Sorry for replying too late. This is a specification. ROS primitive data type like Bool or String has its message on data attribute.

So these would be serialized to like {"data": True}.