1. 配置环境
Ubuntu 16.04
ROS kinetic
ros python 2.7
2.问题
在使用ros开发过程中经常需要使用rqt_plot观察数据波形,但是当你运行rqt_plot的时候有可能会报错
/usr/lib/python2.7/dist-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
/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
3. 解决方案
1. 方法1
根据matplotlib官方网站信息,这有可能是因为该软件应景不再支持python2.7[ 参考IT-cute ]。
但是你可以使用命令[ 参考OverCome-和raiakash ]
rqt
启动程序,之后依次次点击“Plugins”>“Visualization”>“Plot”来启动MatPlot,如下图所示
但是如果你按照 IT-cute的方法 ,安装了pyqtgraph,在运行rqt时会报如下错误
段错误 (核心已转储)
在启动rqt_plot的时候有可能会报如下错误
RuntimeError: the PyQt4.QtCore and PyQt5.QtCore modules both wrap the QObject class
意思为:“PyQt4.QtCore和PyQt5.QtCore模块都包装了QObject类”,可以通过卸载pyqtgraph来解决[ ,运行如下指令[ 参考neumann-d ]
sudo apt remove python-pyqtgraph
千万不要卸载pyqt5,因为它跟很多ros库相依赖。
2. 方法2
还有人说可以通过重新安装matplotlib来解决[ 参考飞天地板流的评论 ],使用如下指令安装[ 参考官网安装方法 ]
python -m pip install -U pip
python -m pip install -U matplotlib
但该方法没有测试。
如果本博客帮到你,记得点赞…