Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when re-arranging widgets over plot. Kinetic, 16.04 #35

Closed
vmatos opened this issue Sep 20, 2016 · 18 comments
Closed

Error when re-arranging widgets over plot. Kinetic, 16.04 #35

vmatos opened this issue Sep 20, 2016 · 18 comments

Comments

@vmatos
Copy link

vmatos commented Sep 20, 2016

When I try to re-arrange widgets in rqt, whenever I pass with it over a plot widget, I get the error:

Traceback (most recent call last):
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/qt_gui/dock_widget.py", line 90, in _event
    new_parent = self._get_new_parent(widget)
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/qt_gui/dock_widget.py", line 139, in _get_new_parent
    widget = widget.parent()
TypeError: 'Canvas' object is not callable
@vmatos
Copy link
Author

vmatos commented Sep 20, 2016

If I don't got over the plot widget, and drop it in place, I get:

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 1756, in tight_layout
    self.subplots_adjust(**kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 1612, in subplots_adjust
    self.subplotpars.update(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 230, in update
    raise ValueError('bottom cannot be >= top')
ValueError: bottom cannot be >= top

@RYO0115
Copy link

RYO0115 commented Nov 24, 2016

I have the same problem running rqt_gui on Ubuntu 16.04.

Traceback (most recent call last):
File "/opt/ros/kinetic/lib/python2.7/dist-packages/qt_gui/dock_widget.py", line 90, in _event
new_parent = self._get_new_parent(widget)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/qt_gui/dock_widget.py", line 139, in _get_new_parent
widget = widget.parent()
TypeError: 'Canvas' object is not callable

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 1756, in tight_layout
self.subplots_adjust(**kwargs)
File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 1612, in subplots_adjust
self.subplotpars.update(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 230, in update
raise ValueError('bottom cannot be >= top')
ValueError: bottom cannot be >= top

I tried
sudo apt-get install ros-kinetic-rqt-gui
but, nothing changes.

@dirk-thomas
Copy link
Contributor

@vmatos @RYO0115 Can you please try the proposed fix from ros-visualization/qt_gui_core#76 and confirm if it fixes the problem for you.

If there are problems remaining can you please describe the exact steps how to reproduce it.

@vmatos
Copy link
Author

vmatos commented Dec 21, 2016

My procedure:

mkdir -p overlay_ws/src
cd overlay_ws/src
git clone https://github.com/ros-visualization/qt_gui_core.git -b fix_parent_logic
cd ..
catkin_make

Then I verified the error was reproducible:

  1. run: rqt
  2. Place 2 plot widgets.
  3. Hold widget and try moving it over plot area.
  4. Get error.

Then I tested the fix:

  1. overlaying workspace: source devel/setup.bash
  2. run: rqt
  3. Place 2 plot widgets.
  4. Hold widget and try moving it over plot area.
  5. No error!

@dirk-thomas My test indicates this PR fixes my first issue: TypeError: 'Canvas' object is not callable

@dirk-thomas
Copy link
Contributor

I was able to reproduce the first error easily. The PR fixes (also for you) which is good. But I never saw the second error. What are the steps to reproduce the second one?

@vmatos
Copy link
Author

vmatos commented Dec 21, 2016

To reproduce the 2nd error:

  1. run: rqt
  2. Place 2 plot widgets. they should appear side by side.
  3. Move one of the plot widgets over the other, so they are distributed vertically.
  4. Get error

@dirk-thomas
Copy link
Contributor

I can reproduce the second error with these steps. Unfortunately the error is within matplotlib and I am not sure if there is anything we can do in the rqt plugin itself. Btw it is also ticketed upstream: matplotlib/matplotlib#5456

stonier referenced this issue in yujinrobot/kobuki_desktop Mar 29, 2017
Refer to https://github.com/ros-visualization/rqt/issues/110

Basically its getting bad resize events when two matplotlib canvas
exist at the same time. So now every time a tab switch is changed
it destroys one if it existed and creates a new one if needed.
@dirk-thomas dirk-thomas transferred this issue from ros-visualization/rqt Aug 23, 2019
@EliteMasterEric
Copy link

It appears this issue is still existing.

Since that report was submitted, matplotlib has gone through several major version changes, of which they claim changes should have been pushed.

However, creating two rqt_plot windows and attempting to align one on top of the other still results in the following stack trace on Kinetic and Melodic:

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 1756, in tight_layout
    self.subplots_adjust(**kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 1612, in subplots_adjust
    self.subplotpars.update(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 230, in update
    raise ValueError('bottom cannot be >= top')
ValueError: bottom cannot be >= top

rqt still utilizes Python 2, and the newest version of matplotlib compatible is 3.0.3. Version 3.1.1 is also available for Python3.

The issue appears to still exist upstream, at least in Python2.

@EliteMasterEric
Copy link

It appears that my issue was the use of an old version of matplotlib, 1.5.1.

Completing the reproduction steps now produces the following stack trace:

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/local/lib/python2.7/dist-packages/matplotlib/figure.py", line 2307, in tight_layout
    pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
  File "/usr/local/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/local/lib/python2.7/dist-packages/matplotlib/tight_layout.py", line 117, in auto_adjust_subplotpars
    fig.transFigure.inverted())
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/transforms.py", line 1901, 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

Reproduction steps:

  1. Open an RQT window.
  2. Create two plots in that window.
  3. Attempt to stack one plot vertically below the other, as pictured below.
  4. RQT will crash with the above stack trace.

@dirk-thomas
Copy link
Contributor

rqt still utilizes Python 2, and the newest version of matplotlib compatible is 3.0.3. Version 3.1.1 is also available for Python3.

The issue appears to still exist upstream, at least in Python2.

If the problem has been resolved upstream in a Python 3-only release the easiest is probably to wait for ROS Noetic (May 2020) which will target Python 3.

If the problem is still present in the latest code (which is Python 3) it is probably best to report this problem upstream.

@EliteMasterEric
Copy link

@dirk-thomas, please see my newest comment.

The issue does not appear if you are using the latest Python2 version of matplotlib (2.2.4). Instead, a second issue, a LinAlgError, occurs.

@dirk-thomas
Copy link
Contributor

I read that comment. My feedback still applies to that different error message since I don't see what could be done in this repository.

@d4n1elchen
Copy link

So is there any workthrough for this issue for now?

@EliteMasterEric
Copy link

EliteMasterEric commented Feb 18, 2020 via email

@dirk-thomas dirk-thomas mentioned this issue Mar 26, 2020
@bergercookie
Copy link
Contributor

bergercookie commented Apr 2, 2020

Hi there,

I came across this error myself and I did a bit of digging.
It's not an issue with rqt_plot as such, but rather with the version of matplotlib installed.

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_qt5agg.py", line 77, in paintEvent
    self.resizeEvent(event)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rqt_plot/data_plot/mat_data_plot.py", line 110, in resizeEvent
    self.figure.tight_layout()
  File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 2031, in tight_layout
    self.subplots_adjust(**kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 1881, in subplots_adjust
    self.subplotpars.update(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 241, in update
    raise ValueError('bottom cannot be >= top')
ValueError: bottom cannot be >= top
[rqt-2] process has died [pid 14148, exit code -6, cmd /opt/ros/melodic/lib/rqt_gui/rqt_gui --perspective-file=/opt/ros/melodic/share/viz/rqt/a.perspective __name:=rqt __log:=/home/berger/.ros/log/faf34a34-74f0-11ea-89cc-0242ac190002/rqt-2.log].
log file: /home/berger/.ros/log/faf34a34-74f0-11ea-89cc-0242ac190002/rqt-2*.log

More specifically, i've encountered this issue with a particular rqt perspective configuration and matplotlib version 2.1.1. However after upgrading to matplotlib 2.2.5 I can confirm that the error goes away and instead I get a rather harmless warning:

/usr/local/lib/python2.7/dist-packages/matplotlib/tight_layout.py:182: UserWarning: The bottom and top margins cannot be made large enough to accommodate all axes decorations.
  warnings.warn('The bottom and top margins cannot be made large '

A quickfix to this issue would be something like the following on the rqt_plot side:

https://github.com/ros-visualization/rqt_plot/blob/master/src/rqt_plot/data_plot/mat_data_plot.py#L110

try:
    self.figure.tight_layout()
except ValueError:
    pass

@dirk-thomas
Copy link
Contributor

A quickfix to this issue would be something like the following on the rqt_plot side:

@bergercookie Please consider to create a pull request for the proposed workaround.

bergercookie added a commit to bergercookie/rqt_plot that referenced this issue Apr 3, 2020
Matplotlib emits errors like the following under specific canvas
layouts:

```console
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 1756, in tight_layout
    self.subplots_adjust(**kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 1612, in subplots_adjust
    self.subplotpars.update(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 230, in update
    raise ValueError('bottom cannot be >= top')
ValueError: bottom cannot be >= top
```

Current patch catches and suppresses that exception.

References:
- matplotlib/matplotlib#10915
- ros-visualization#35
bergercookie added a commit to bergercookie/rqt_plot that referenced this issue Apr 3, 2020
Matplotlib emits errors like the following under specific canvas
layouts:

```console
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 1756, in tight_layout
    self.subplots_adjust(**kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 1612, in subplots_adjust
    self.subplotpars.update(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 230, in update
    raise ValueError('bottom cannot be >= top')
ValueError: bottom cannot be >= top
```

Current patch catches and suppresses that exception.

References:
- matplotlib/matplotlib#10915
- ros-visualization#35
dirk-thomas added a commit that referenced this issue Apr 3, 2020
* Fix #35 - "bottom cannot be >= top" matplotlib error

Matplotlib emits errors like the following under specific canvas
layouts:

```console
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 1756, in tight_layout
    self.subplots_adjust(**kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 1612, in subplots_adjust
    self.subplotpars.update(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 230, in update
    raise ValueError('bottom cannot be >= top')
ValueError: bottom cannot be >= top
```

Current patch catches and suppresses that exception.

References:
- matplotlib/matplotlib#10915
- #35

* renamed to `safe_tight_layout`, inverted logic to avoid duplicating the call

Co-authored-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
@arjunskumar
Copy link

2.2.5

@bergercookie Yes, it was because of matplotlib version issues, I resolved by upgrading to 2.2.5. Thanks

@lucbettaieb
Copy link

To bump this further, I encountered this issue and fixed by upgrading matplotlib.

sudo pip install --upgrade matplotlib

rhaschke added a commit to rhaschke/rqt_plot that referenced this issue Feb 4, 2021
rhaschke added a commit to rhaschke/rqt_plot that referenced this issue Feb 4, 2021
@rhaschke rhaschke mentioned this issue Feb 4, 2021
rhaschke added a commit to rhaschke/rqt_plot that referenced this issue Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants