软件环境:Ubuntu 16.04
ROS kinetic
问题发现:
使用URDF创建机器人3D仿真模型
地址:http://www.linuxdiyf.com/linux/23990.html
在URDF文件中构建机器人模型,并通过*.launch文件启动RViz观察构建的URDF文件,能启动Rviz但发现有如下错误提示:
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/joint_state_publisher/joint_state_publisher", line 361, in <module>
jsp = JointStatePublisher()
File "/opt/ros/kinetic/lib/joint_state_publisher/joint_state_publisher", line 41, in __init__
robot = xml.dom.minidom.parseString(description).getElementsByTagName('robot')[0]
File "/usr/lib/python2.7/xml/dom/minidom.py", line 1928, in parseString
return expatbuilder.parseString(string)
File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 940, in parseString
return builder.parseString(string)
File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 223, in parseString
parser.Parse(string, True)
xml.parsers.expat.ExpatError: XML or text declaration not at start of entity: line 1, column 1
[joint_state_publisher-1] process has died [pid 9426, exit code 1, cmd /opt/ros/kinetic/lib/joint_state_publisher/
joint_state_publisher __name:=joint_state_publisher __log:=/home/mingde-yao/.ros/log/8db3b6bc-74da-11e6-9418-000c297f6d5a/
joint_state_publisher-1.log].
log file: /home/mingde-yao/.ros/log/8db3b6bc-74da-11e6-9418-000c297f6d5a/joint_state_publisher-1*.log
在Rviz中是这个样子:
使用下面指令:
check_urdf *.urdf
查看urdf文件没有问题。
尝试1:
搜索发现 hitgavin网友 也有类似的问题,但我进行如下操作后:
sudo apt-get install unicode
发现问题并没有得到解决。
尝试2:hitgavin网友提到了这篇文章(http://www.linuxdiyf.com/linux/23992.html)
根据回答如下:
Your example works fine for me, except it doesn't like extra spaces before the
<?xml version="1.0"?>
line, but I assume that's just formatting for this page.
遂检查自己的URDF文件,问题得到解决!
对于初学者来说,写东西的时候一定要注意格式!