Ask Your Question
1

What am i doing wrong with ros::timer in rqt?

asked 2014-02-23 09:32:08 -0500

Blizzard gravatar image

updated 2016-10-24 09:01:26 -0500

ngrennan gravatar image

Hello,

i have some problems with making the ros::timer work. Usually if i need a timer within a class i add these three lines to the header:

  void timerCallback(const ros::TimerEvent& event);
  ros::Timer m_timer;
  ros::NodeHandle m_nh;

and in the cpp file i add this line for example to the constructor:

m_timer = m_nh.createTimer(ros::Duration(1), &MyClass::timerCallback, this);

Last but not least i add a callback function to the cpp:

void MyClass::timerCallback(const ros::TimerEvent& event)
{
  // something that has to be done frequently
  ROS_INFO("Beep");
}

Unfortunatly it does not work this way in an rqt plugin. For some reason the callback function is never thrown. Please help me with that. I'm using ROS Hydro on Kubuntu 12.04.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2014-02-27 09:34:38 -0500

Dirk Thomas gravatar image

Currently for the C++ plugins in rqt there is no spinning ROS thread therefore ROS timers do not work. Temporary you could work around it by using Qt timers instead.

I have created two pull requests which will add the functionality to rqt. If you want to give it a try checkout the branches of the following two pull request into your workspace: https://github.com/ros-visualization/... and https://github.com/ros-visualization/... Then your timer should fire as expected.

edit flag offensive delete link more

Comments

Thank you very much. Now it works like expected. Will these two branches be merged into future versions of rqt and qt_gui_core? I hope so.

Blizzard gravatar imageBlizzard ( 2014-02-27 14:12:48 -0500 )edit

All ROS distros are currently being released form the same branch for those repos. So yes, all will receive the change soon.

Dirk Thomas gravatar imageDirk Thomas ( 2014-02-27 14:30:59 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2014-02-23 09:32:08 -0500

Seen: 300 times

Last updated: Feb 27 '14