ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

rosbag 'UnicodeDecodeError'

asked 2016-07-28 12:41:33 -0500

updated 2016-07-28 12:42:38 -0500

I have some rosbags. Most of them seem to be okay according to 'rosbag check <file>'. But a few of them cause the check to be aborted in the middle of the bag with the error below.

What is the best way to avoid this decoding error?

Traceback (most recent call last):
  File "/opt/ros/indigo/bin/rosbag", line 35, in <module>
    rosbag.rosbagmain()
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rosbag/rosbag_main.py", line 863, in rosbagmain
    cmds[cmd](argv[2:])
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rosbag/rosbag_main.py", line 452, in check_cmd
    migrations = checkbag(mm, args[0])
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rosbag/migration.py", line 76, in checkbag
    for topic, msg, t in bag.read_messages(raw=True):
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rosbag/bag.py", line 2331, in read_messages
    yield self.seek_and_read_message_data_record((entry.chunk_pos, entry.offset), raw)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rosbag/bag.py", line 2469, in seek_and_read_message_data_record
    msg_type = _get_message_type(connection_info)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rosbag/bag.py", line 1565, in _get_message_type
    message_type = genpy.dynamic.generate_dynamic(info.datatype, info.msg_def)[info.datatype]
  File "/opt/ros/indigo/lib/python2.7/dist-packages/genpy/dynamic.py", line 168, in generate_dynamic
    tmp_file.file.write(full_text.encode())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2788: ordinal not in range(128)
edit retag flag offensive close merge delete

Comments

Please sign the answer as correct if it was helpful.

tik0 gravatar image tik0  ( 2017-06-08 02:46:59 -0500 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2016-08-29 02:16:07 -0500

tik0 gravatar image

If you take a look at the error you'll see that it is raised by the message definition which rosbag tries to interpret. You possibly have personal message definitions with UTF-8 characters in it. While the tool is written in python, there always remains the pain with UTF-8 decoding what you can see in your last line:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2788: ordinal not in range(128)

Just check which of your message definitions are UTF-8 encoded by the command line tool file yourMessageDefinition.msg. If it tells you ASCII text the definition should be OK, if UTF-8 Unicode text it is not. Just open the file and substitute all special characters like µ or even in your comments. If you are unsure which character in your file is special, just open up a hex editor (like ghex), open the file and search for characters which occupy more than one byte. Then re-build the message definitions.

edit flag offensive delete link more

Comments

My defintion is ASCII Text and yet I got this error when running rqt_bag

Kansai gravatar image Kansai  ( 2021-04-22 04:11:30 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-07-28 12:41:33 -0500

Seen: 3,891 times

Last updated: Aug 29 '16