Robotics StackExchange | Archived questions

mapping pkgs publishes a string in the last bit in the /map topic (map.data[])

Hello All,

This is actually my first question. I am having a trouble with all the mapping pkgs in ROS2 when I echo the topic /map, I always get a string in the last bit of the map.data[], here is what I expect image description

` header: stamp: sec: 5158 nanosec: 179000000 frameid: map info: mapload_time: sec: 0 nanosec: 0 resolution: 0.05000000074505806 width: 384 height: 384 origin: position: x: -10.0 y: -10.0 z: 0.0 orientation: x: 0.0 y: 0.0 z: 0.0 w: 1.0 data: - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1

- '...'

`

I want to subscribe on the /map topic from the the rosbridge_server pkg to build a map on a web page but I always encouter this error

[rosbridgewebsocket-1] [ERROR] [1646827887.002034763] [rosbridgewebsocket]: Exception calling subscribe callback: a bytes-like object is required, not 'str'**

Here is what I get: image description

I think it's because of the published string in the map.data[]. Have anybody encountered this error before?

Note: same setup works properly on ros1

Asked by youssef desouky on 2022-03-09 09:14:27 UTC

Comments

Can you add your callback code there too? Maybe there is some bug to fix, it will be easier to analyze

Asked by ljaniec on 2022-03-09 09:35:51 UTC

I run the rosbridge first, then I open the continuous.html which can be found at the following https://github.com/RobotWebTools/ros2djs/tree/develop/examples

Asked by youssef desouky on 2022-03-09 09:40:39 UTC

This seems to be related to this kind of problems: https://stackoverflow.com/questions/33054527/typeerror-a-bytes-like-object-is-required-not-str-when-writing-to-a-file-in (especially parts which mention differences between Python2 and Python3 - the latter is used in ROS2 now). Are you using correct version of each package (for ROS2)?

Asked by ljaniec on 2022-03-09 10:05:07 UTC

Yes, I'm using the latest version in each pkg.

Asked by youssef desouky on 2022-03-09 11:18:06 UTC

Answers