ubuntu 16.04如何运行rqt_plot

本文针对Ubuntu 16.04环境下ROS kinetic使用rqt_plot时出现的matplotlib错误进行了详细分析,提供了两种解决方案:一是通过调整rqt插件启动方式,二是重新安装matplotlib库,并附带警告避免卸载pyqt5。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

但该方法没有测试。

如果本博客帮到你,记得点赞

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值