rqt not updating text
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);
while(state_==RecordingState::RECORDING)
{
if (status_display_ != nullptr)
{
status_display_->updateTitle();
ROS_INFO("title updated"); // <<<<< IF REMOVED, SIZE IN RQT DESIGN IS NOT UPDATING
}
r.sleep();
}
}
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)
{
if(!is_directory(*it))
size+=boost::filesystem::file_size(*it);
}
std::string foldersize = " Folder Size: " + std::to_string((int)size);
// update title
const std::string title = foldersize;
parent_->setTitle(QString::fromStdString(title));
}
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