前提
ubuntu20.04
python3.8を使用しています
現在、下記のサイトを参考に2次元地図からgazeboのモデルを作ろうとしています。
しかし、元々python2系のコードだったためか文字列の読み込みがうまくいってない状態で様々なサイトを参考に encoding='shift_jis'やencoding='windows-1252'に変えてみたのですがよくわかっていない状態です。
申し訳ございませんがご教示いただけないでしょうか。
よろしくお願いいたします。
https://qiita.com/BEIKE/items/825e62bbd8d92b6d347e#3-map2gazebo%E3%81%A7%E7%94%9F%E6%88%90%E3%81%97%E3%81%9Fmodel%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%83%8A%E3%83%93%E3%82%B2%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E3%81%97%E3%81%A6%E3%81%BF%E3%82%8B
発生している問題・エラーメッセージ
[ERROR] [1647850354.213820]: bad callback: <bound method MapConverter.map_callback of <__main__.MapConverter object at 0x7fdd9dbdb400>> Traceback (most recent call last): File "/opt/ros/noetic/lib/python3/dist-packages/rospy/topics.py", line 750, in _invoke_callback cb(msg) File "/practice_ws/src/map2gazebo/src/map2gazebo.py", line 43, in map_callback mesh.export(f, "stl") File "/.local/lib/python3.8/site-packages/trimesh/base.py", line 2712, in export return export_mesh(mesh=self, File "/.local/lib/python3.8/site-packages/trimesh/exchange/export.py", line 85, in export_mesh result = util.write_encoded(file_obj, export) File "/.local/lib/python3.8/site-packages/trimesh/util.py", line 2118, in write_encoded file_obj.write(stuff.decode(encoding)) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 86: invalid start byte
該当のソースコード
def write_encoded(file_obj, stuff, encoding='utf-8'): """ If a file is open in binary mode and a string is passed, encode and write. If a file is open in text mode and bytes are passed decode bytes to str and write. Parameters ----------- file_obj : file object With 'write' and 'mode' stuff : str or bytes Stuff to be written encoding : str Encoding of text """ binary_file = 'b' in file_obj.mode string_stuff = isinstance(stuff, basestring) binary_stuff = isinstance(stuff, bytes) if not PY3: file_obj.write(stuff) elif binary_file and string_stuff: file_obj.write(stuff.encode(encoding)) elif not binary_file and binary_stuff: #/.local/lib/python3.8/site-packages/trimesh/util.py", line 2118 file_obj.write(stuff.decode(encoding)) else: file_obj.write(stuff) file_obj.flush() return stuff

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。