gazebo仿真报错:‘ascii‘ codec can‘t encode characters in position 493-502: ordinal not in range(128)

报错如下:

Traceback (most recent call last):
  File "/opt/ros/melodic/lib/gazebo_ros/spawn_model", line 239, in <module>
    exit_code = sm.run()
  File "/opt/ros/melodic/lib/gazebo_ros/spawn_model", line 149, in run
    xml_parsed = xml.etree.ElementTree.fromstring(model_xml)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1312, in XML
    parser.feed(text)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1658, in feed
    self._parser.Parse(data, 0)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 493-502: ordinal not in range(128)
[model-3] process has died [pid 26033, exit code 1, cmd /opt/ros/melodic/lib/gazebo_ros/spawn_model -urdf -model mycar -param robot_description __name:=model __log:=/home/tqf/.ros/log/cf3ab586-510a-11ee-8153-40b076a42ab1/model-3.log].
log file: /home/tqf/.ros/log/cf3ab586-510a-11ee-8153-40b076a42ab1/model-3*.log
[ INFO] [1694489200.729612426]: waitForService: Service [/gazebo/set_physics_properties] is now available.
[ INFO] [1694489200.762938832, 0.017000000]: Physics dynamic reconfigure ready.
^C[gazebo_gui-2] killing on exit
[gazebo-1] killing on exit
[gazebo_gui-2] escalating to SIGTERM
shutting down processing monitor...
... shutting down processing monitor complete

gazebo可以打开,但是模型不显示,提示以上内容

说明导入的urdf文件中有中文,所以最笨的方法去掉中文注释

但是:

最佳解决办法:

/usr/lib/python2.7/xml/etree/ElementTree.py文件

在主代码前,加入

reload(sys) 
sys.setdefaultencoding("utf-8")

参考链接: https://blog.csdn.net/nownow_/article/details/122061708

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值