ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

rqt not updating text

asked 2016-04-13 12:00:20 -0600

fabha gravatar image

Hello, we wrote our own rqt plugin which extends the rosbag functionality to our needs. We are using an *.ui design in rqt to give the user the ability to easily interact with the rosbag functionality. One of the elements in the design is a (title) text showing the current folder size, giving the user the visual feedback how big the recording is and that it is still ongoing (size is growing over time).

For that we want to regularly check the size of the folder in a separate thread and update the text in rqt (GUI) accordingly. Our approach works very well, but only if we are calling the ROS_INFO, ROS_ERROR, ... functionality in every cycle of the thread worker. However we would like to get rid of the console output of course.

What we tried already, instead of the ROS outputs:

  • using std:: outputs (printf, cout, ...) -> no updating size in rqt
  • calling parent_->update() after setTitle() -> no updating size in rqt
  • calling parent_->repaint() after setTitle() -> rqt crashes
  • adding ros::Duration() or usleep() in each cycle -> no updating size in rqt

We are really unsure how to debug this problem, since its working fine only if we are calling the ROS output functions in each cycle of the thread worker.

Our implementation is like this:

Starting the thread:

title_update_thread_ = std::thread(&RosbagDirectory::updateTitleWorker, this);

Thread worker:

 void RosbagDirectory::updateTitleWorker(void)
  ros::Rate r(10);
    if (status_display_ != nullptr)
        ROS_INFO("title updated");        // <<<<< IF REMOVED, SIZE IN RQT DESIGN IS NOT UPDATING   

Updating the title:

void PluginStatusDisplay::updateTitle(void)
  // get file size
  size_t size=0;
  for(boost::filesystem::recursive_directory_iterator it(path_); it!=boost::filesystem::recursive_directory_iterator(); ++it)

   std::string foldersize = " Folder Size: " + std::to_string((int)size);

  // update title
  const std::string title = foldersize;

It would be awesome if you could give us a hint where to search for the problem and how we could debug this bug.

Kindest Regards

Fabian Hanke

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-04-13 12:21:26 -0600

Dirk Thomas gravatar image

In Qt you can not call the majority of the API from a different thread. Please see for more information. You will likely either need to post a custom event or use a signal / slot to perform the UI change.

edit flag offensive delete link more


thank you very much! I'm using a LineEdit element with a signal slot mechanism to update and it works fine. However I guess the problem was that I only tested the foldersize with recording rosout. This was super dumb. Shame on me.

fabha gravatar image fabha  ( 2016-04-26 11:23:23 -0600 )edit

Question Tools


Asked: 2016-04-13 12:00:20 -0600

Seen: 492 times

Last updated: Apr 13 '16