ROS2D - Exception calling subscribe callback: a bytes-like object is required, not 'str"

Hi,

Does anyone experience the same with me?

I am trying to connect the web interface with my own real robot, but in section 9 which is about displaying a map, there was an error “[rosbridge_websocket-1] [ERROR] [1687341891.342873277] [rosbridge_websocket]: Exception calling subscribe callback: a bytes-like object is required, not 'str”

Which library or steps that I was missing?

I am running ROS2 Foxy with Cartographer for generating the map. There was no error on web console tho.

This is my rosbride console

Thank you for the help.

The error is pointing to your “subscribe callback”. Do you have a subscriber callback in your code somewhere? It looks like you didn’t use the right kind of message for it.

Thanks for feedback @bayodesegun
Hmm, yes I believe, I’m following the course code and the callback looks only like this

I’m not sure enough, but I think the error arise within the map part which is not using any message type(?) as seen on the picture above.

That error typically happens where you are trying to read/write to a file or another binary source. Are you reading/writing to a file somewhere? You need to identify the line of code where the error is occurring and convert the data accordingly.

As you are running the code on your local PC, we are not able to debug it for you since it’s out of our scope.

I see, how do one usually do debugging for these kind of error?
I will try to also debug the code, because those same code works in the course but not in my local computer.
Or is it might be also because the course using ROS1 but in my local ROS2 is used?

I would say you should try to use ROS1 first. Then, if you still have the problem, we can look at another reason, such as the differences between the platform and your local PC.

At some point in the future, we might look at how we might port the course to ros 2.