启动 ros master 后,启动 rqt_plot 报错如下:
~ rqt_plot
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: en
在 .zshrc (或者 .bashrc )中添加环境变量:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
source ~/.zshrc
使修改生效,然后重新启动 rqt_plot 报错如下:
~ rqt_plot
/usr/lib/python2.7/dist-packages/matplotlib/axis.py:1015: UserWarning: Unable to find pixel distance along axis for interval padding of ticks; assuming no interval padding needed.
warnings.warn("Unable to find pixel distance along axis "
/usr/lib/python2.7/dist-packages/matplotlib/axis.py:1025: UserWarning: Unable to find pixel distance along axis for interval padding of ticks; assuming no interval padding needed.
warnings.warn("Unable to find pixel distance along axis "
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rqt_plot/data_plot/mat_data_plot.py", line 107, in resizeEvent
self.figure.tight_layout()
File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 1754, in tight_layout
rect=rect)
File "/usr/lib/python2.7/dist-packages/matplotlib/tight_layout.py", line 349, in get_tight_layout_figure
pad=pad, h_pad=h_pad, w_pad=w_pad)
File "/usr/lib/python2.7/dist-packages/matplotlib/tight_layout.py", line 128, in auto_adjust_subplotpars
fig.transFigure.inverted())
File "/usr/lib/python2.7/dist-packages/matplotlib/transforms.py", line 1775, in inverted
self._inverted = Affine2D(inv(mtx), shorthand_name=shorthand_name)
File "/usr/lib/python2.7/dist-packages/numpy/linalg/linalg.py", line 526, in inv
ainv = _umath_linalg.inv(a, signature=signature, extobj=extobj)
File "/usr/lib/python2.7/dist-packages/numpy/linalg/linalg.py", line 90, in _raise_linalgerror_singular
raise LinAlgError("Singular matrix")
numpy.linalg.linalg.LinAlgError: Singular matrix
[1] 5364 segmentation fault (core dumped) rqt_plot
从第二个报错信息 numpy.linalg.linalg.LinAlgError: Singular matrix 上看,网上很多人都说是由于没有安装 Matplotlib 或者 Matplotlib 版本过低,需要重新安装,参见: ROS中rqt_plot报错
查询到系统已经安装 Matplotlib 1.5.1 ,这和仿真环境里的版本是一样的,而仿真环境中的 rqt_plot 可以正常使用。 因此,应该不是 Matplotlib 版本问题。
另外,也查询到一个解决方法,就是需要安装 pyqtgraph : sudo pip install pyqtgraph
,参见: numpy.linalg.linalg.LinAlgError: Singular matrix
然而,在安装 pyqtgraph 过程中报错:
~ sudo pip install pyqtgraph
[sudo] password for pi:
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in
sys.exit(main())
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 215, in main
locale.setlocale(locale.LC_ALL, '')
File "/usr/lib/python2.7/locale.py", line 581, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
这才发现 使用 pip 安装貌似都报这个错: locale.Error: unsupported locale setting ,而且 rqt_plot 一开始报的错也和 locale 有关 ( ValueError: unknown locale: en ) ,查询解决方法参见: pip install - locale.Error: unsupported locale setting
在 ~/.zshrc 中添加 export LC_ALL=C
使 ~/.zshrc 生效,并查看修改结果:
~ source ~/.zshrc
~ locale
LANG=en_US.UTF-8
LANGUAGE=en
en
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=C
至此,可以再 重新启动 rqt_plot 看看能否正常使用 ,如果还报错,再安装 pyqtgraph :
~ sudo pip install pyqtgraph