Skip to content

Commit

Permalink
RobotModelDisplay: Poll robot_description at 1Hz until found
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaschke committed Aug 31, 2019
1 parent 6135ee2 commit d171d82
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/rviz/default_plugin/robot_model_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include <OgreSceneNode.h>
#include <OgreSceneManager.h>
#include <QTimer>

#include <urdf/model.h>

Expand Down Expand Up @@ -113,10 +114,7 @@ void RobotModelDisplay::updateAlpha()
void RobotModelDisplay::updateRobotDescription()
{
if( isEnabled() )
{
load();
context_->queueRender();
}
}

void RobotModelDisplay::updateVisualVisible()
Expand All @@ -140,6 +138,7 @@ void RobotModelDisplay::updateTfPrefix()
void RobotModelDisplay::load()
{
clearStatuses();
context_->queueRender();

std::string content;
if( !update_nh_.getParam( robot_description_property_->getStdString(), content ))
Expand All @@ -155,6 +154,8 @@ void RobotModelDisplay::load()
setStatus( StatusProperty::Error, "URDF",
"Parameter [" + robot_description_property_->getString()
+ "] does not exist, and was not found by searchParam()" );
// try again in a second
QTimer::singleShot(1000, this, SLOT(updateRobotDescription()));
return;
}
}
Expand Down

8 comments on commit d171d82

@efernandez
Copy link

@efernandez efernandez commented on d171d82 Sep 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhaschke IMHO this introduces a regression. If there's no robot_description param in the ROS param server all displays lose the focus after 1 second (the `QTimer frequency), so it's almost impossible to change the property values of any display to something that has more than one character (at least for me, since you first has to click with the mouse on the property value field and then type the new value or move with the arrows, ...).

Could this be reverted or implemented in a different way, please?

As a workaround I'm setting the robot_description param to an empty string. That works, but I had to git bisect rviz source code to figure out what the issue was.

@rhaschke
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reporting this issue. However, I cannot reproduce the behavior you are describing.
I guess when referring to "displays losing focus" you mean that the property editors in the display's property tree are losing focus. However, this doesn't happen for me.
Which Qt version you are using?
Could you provide an rviz config to reproduce the issue?

@efernandez
Copy link

@efernandez efernandez commented on d171d82 Sep 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure which version is actually used, but this is all I have installed in my Ubuntu 16.04.6 LTS machine:

~$ dpkg -l | grep libqt
ii  libqt4-dbus:amd64                                           4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 D-Bus module
ii  libqt4-declarative:amd64                                    4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 Declarative module
ii  libqt4-designer:amd64                                       4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 designer module
ii  libqt4-dev                                                  4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 development files
ii  libqt4-dev-bin                                              4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 development programs
ii  libqt4-help:amd64                                           4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 help module
ii  libqt4-network:amd64                                        4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 network module
ii  libqt4-opengl:amd64                                         4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 OpenGL module
ii  libqt4-opengl-dev                                           4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 OpenGL library development files
ii  libqt4-qt3support:amd64                                     4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 3 compatibility library for Qt 4
ii  libqt4-script:amd64                                         4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 script module
ii  libqt4-scripttools:amd64                                    4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 script tools module
ii  libqt4-sql:amd64                                            4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 SQL module
ii  libqt4-sql-sqlite:amd64                                     4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 SQLite 3 database driver
ii  libqt4-svg:amd64                                            4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 SVG module
ii  libqt4-test:amd64                                           4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 test module
ii  libqt4-xml:amd64                                            4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 XML module
ii  libqt4-xmlpatterns:amd64                                    4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 XML patterns module
ii  libqt5clucene5:amd64                                        5.5.1-3ubuntu0.1                                      amd64        Qt 5 CLucene module
ii  libqt5concurrent5:amd64                                     5.5.1+dfsg-16ubuntu7.6                                amd64        Qt 5 concurrent module
ii  libqt5core5a:amd64                                          5.5.1+dfsg-16ubuntu7.6                                amd64        Qt 5 core module
ii  libqt5dbus5:amd64                                           5.5.1+dfsg-16ubuntu7.6                                amd64        Qt 5 D-Bus module
ii  libqt5designer5:amd64                                       5.5.1-3ubuntu0.1                                      amd64        Qt 5 designer module
ii  libqt5designercomponents5:amd64                             5.5.1-3ubuntu0.1                                      amd64        Qt 5 Designer components module
ii  libqt5feedback5:amd64                                       5.0~git20130529-0ubuntu13                             amd64        Qt Feedback module
ii  libqt5gui5:amd64                                            5.5.1+dfsg-16ubuntu7.6                                amd64        Qt 5 GUI module
ii  libqt5help5:amd64                                           5.5.1-3ubuntu0.1                                      amd64        Qt 5 help module
ii  libqt5multimedia5:amd64                                     5.5.1-4ubuntu2                                        amd64        Qt 5 Multimedia module
ii  libqt5multimedia5-plugins:amd64                             5.5.1-4ubuntu2                                        amd64        Qt 5 Multimedia module plugins
ii  libqt5multimediaquick-p5:amd64                              5.5.1-4ubuntu2                                        amd64        Qt 5 Multimedia Quick module
ii  libqt5multimediawidgets5:amd64                              5.5.1-4ubuntu2                                        amd64        Qt 5 Multimedia Widgets module
ii  libqt5network5:amd64                                        5.5.1+dfsg-16ubuntu7.6                                amd64        Qt 5 network module
ii  libqt5opengl5:amd64                                         5.5.1+dfsg-16ubuntu7.6                                amd64        Qt 5 OpenGL module
ii  libqt5opengl5-dev:amd64                                     5.5.1+dfsg-16ubuntu7.6                                amd64        Qt 5 OpenGL library development files
ii  libqt5organizer5:amd64                                      5.0~git20140515~29475884-0ubuntu20                    amd64        Qt PIM module, Organizer library
ii  libqt5positioning5:amd64                                    5.5.1-3ubuntu1                                        amd64        Qt Positioning module
ii  libqt5printsupport5:amd64                                   5.5.1+dfsg-16ubuntu7.6                                amd64        Qt 5 print support module
ii  libqt5qml5:amd64                                            5.5.1-2ubuntu6                                        amd64        Qt 5 QML module
ii  libqt5quick5:amd64                                          5.5.1-2ubuntu6                                        amd64        Qt 5 Quick library
ii  libqt5quickparticles5:amd64                                 5.5.1-2ubuntu6                                        amd64        Qt 5 Quick particles module
ii  libqt5quicktest5:amd64                                      5.5.1-2ubuntu6                                        amd64        Qt 5 Quick Test library
ii  libqt5quickwidgets5:amd64                                   5.5.1-2ubuntu6                                        amd64        Qt 5 Quick Widgets library
ii  libqt5scintilla2-12v5                                       2.9.1+dfsg-4build1                                    amd64        Qt5 port of the Scintilla source code editing widget
ii  libqt5scintilla2-l10n                                       2.9.1+dfsg-4build1                                    all          Scintilla source code editing widget for Qt5, translation files
ii  libqt5script5:amd64                                         5.5.1+dfsg-2build1                                    amd64        Qt 5 script module
ii  libqt5scripttools5:amd64                                    5.5.1+dfsg-2build1                                    amd64        Qt 5 script tools module
ii  libqt5sql5:amd64                                            5.5.1+dfsg-16ubuntu7.6                                amd64        Qt 5 SQL module
ii  libqt5sql5-sqlite:amd64                                     5.5.1+dfsg-16ubuntu7.6                                amd64        Qt 5 SQLite 3 database driver
ii  libqt5svg5:amd64                                            5.5.1-2build1                                         amd64        Qt 5 SVG module
ii  libqt5svg5-dev:amd64                                        5.5.1-2build1                                         amd64        Qt 5 SVG module development files
ii  libqt5test5:amd64                                           5.5.1+dfsg-16ubuntu7.6                                amd64        Qt 5 test module
ii  libqt5waylandclient5:amd64                                  5.5.1-2build1                                         amd64        QtWayland client library
ii  libqt5webkit5:amd64                                         5.5.1+dfsg-2ubuntu1                                   amd64        Web content engine library for Qt
ii  libqt5webkit5-dev:amd64                                     5.5.1+dfsg-2ubuntu1                                   amd64        Web content engine library for Qt - development files
ii  libqt5websockets5:amd64                                     5.5.1-4build1                                         amd64        Qt 5 Web Sockets module
ii  libqt5websockets5-dev:amd64                                 5.5.1-4build1                                         amd64        Qt 5 Web Sockets module - development files
ii  libqt5widgets5:amd64                                        5.5.1+dfsg-16ubuntu7.6                                amd64        Qt 5 widgets module
ii  libqt5x11extras5:amd64                                      5.5.1-3build1                                         amd64        Qt 5 X11 extras
ii  libqt5x11extras5-dev:amd64                                  5.5.1-3build1                                         amd64        Qt 5 X11 extras development files
ii  libqt5xml5:amd64                                            5.5.1+dfsg-16ubuntu7.6                                amd64        Qt 5 XML module
ii  libqt5xmlpatterns5:amd64                                    5.5.1-2build1                                         amd64        Qt 5 XML patterns module
ii  libqt5xmlpatterns5-dev:amd64                                5.5.1-2build1                                         amd64        Qt 5 XML patterns development files
ii  libqtassistantclient4:amd64                                 4.6.3-7                                               amd64        Qt Assistant client library (runtime)
ii  libqtcore4:amd64                                            4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 core module
ii  libqtdbus4:amd64                                            4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 D-Bus module library
ii  libqtgui4:amd64                                             4:4.8.7+dfsg-5ubuntu2                                 amd64        Qt 4 GUI module
ii  libqtwebkit-dev                                             2.3.2-0ubuntu11                                       amd64        Web content engine library for Qt - development files
ii  libqtwebkit4:amd64                                          2.3.2-0ubuntu11                                       amd64        Web content engine library for Qt

@rhaschke What version do you have?
BTW, If there's a minium version requirement on Qt, shouldn't that be specified in the package.xml file for the libqt5* dependencies with a version_gte param? 😃 (I'm just wondering what version I could try that would work)

For the sake of clarity, this is the issue I'm describing (if you disable the Robot Model display the issue doesn't happen because I believe the display QTimer stops running):
rviz_robot_model_focus_issue

You only need an rviz layout with a Robot Model, and optionally any other display. This is the one I used in the example above (I changed the extension from .rviz to .txt so I can upload it here):

example.txt

@rhaschke
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify: Obviously you are using Ubuntu 16.04. Usually this is used with ROS Kinetic.
Hence, I assume that you have built rviz from source. Did you?
When running rviz, it prints the Qt version number on the console. Could you please provide this one?

Currently, I have no idea, why this regression happens to you. On my stock Ubuntu 18.04 with ROS Melodic (and Qt 5.9.5) it doesn't happen (and there is no reason for it: trying to load the robot model doesn't explicitly change focus). Hence, I'm asking for your Qt version to try to reproduce the issue.

@efernandez
Copy link

@efernandez efernandez commented on d171d82 Sep 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I built rviz from source when I was git bisecting it to find out the offending commit.

The Qt version number printed when I open rviz is:

[ INFO] [${node}] [1569344814.435099845]: rviz version 1.13.4
[ INFO] [${node}] [1569344814.435154291]: compiled against Qt version 5.5.1
[ INFO] [${node}] [1569344814.435168520]: compiled against OGRE version 1.9.0 (Ghadamon)
[ INFO] [/rviz_CPR01878L_25254_2762873608510844935] [1569344814.448940707]: Forcing OpenGl version 0.
[ INFO] [/rviz_CPR01878L_25254_2762873608510844935] [1569344814.931852518, 315.580000000]: Stereo is NOT SUPPORTED
[ INFO] [/rviz_CPR01878L_25254_2762873608510844935] [1569344814.931913716, 315.580000000]: OpenGl version: 4.6 (GLSL 4.6).

I'm running now rviz version 1.13.4 but with your commit reverted, which is what I have now in our fork: https://github.com/clearpathrobotics/rviz
That way we can upgrade to the latest rviz w/o getting impacted by this in our environment.

I think there was a latent issue that changes focus (or something similar) when the robot model is set. By adding a timer that happens constantly every time the timer is triggered (until the robot_description becomes available), and the issue becomes clearly noticeable.

Let me know what else do you need and how I can help find the actual root cause of the issue we're seeing.
I wonder how are you planning to test with my Qt version in your system 🤔
Maybe I can try the same upgrading to Qt 5.9.5.

@rhaschke
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can reproduce the issue with Qt 5.5.1 in a Xenial/Kinetic environment. Will try to debug asap.

@efernandez
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rhaschke . I highly appreciate.

Let me know if you need help testing anything.

@rhaschke
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indeed an issue of Qt: When the status messages of the display are removed in a call to Display::clearStatuses(), the QAbstractItemView calls focusNextPrevChild() in response to removed rows of the model (although the active editor is not affected by these deletions).
This behavior is obviously fixed in Qt 5.9.5. As this commit targets Melodic, which ships with Qt 5.9.5, I am tempted to leave it like this.
If you guys at Clearpath want to run the latest Melodic rviz on Kinetic, you should revert this commit as you already have done.

Please sign in to comment.