Input signal only noisy when loop_rate is used

asked 2015-06-12 02:44:51 -0600

niall gravatar image

updated 2015-06-15 06:44:54 -0600

Hi!

I'm having a problem interfacing a Novint Falcon with ROS. Simply put the input signal (position of the static Falcon, held down by gravity) has sporadic outliers when ros::rate loop_rate(1000) is in my code but without it, the input signal is perfectly constant.

Here some raw data without loop_rate(1000):

Position= 0.00464177 -0.0505329 0.0881456 count 878
...
Position= 0.00464177 -0.0505328 0.0881457 count 4800
...
Position= 0.00464177 -0.0505328 0.0881457 count 6176

Here some raw data with loop_rate(1000):

Position= 0.00433312 -0.0506089 0.0981003 count 2345
Position= 0.00433312 -0.0506089 0.0981003 count 2346
Position= 0.00433312 -0.0506089 0.0981003 count 2347
...
Position= 0.0377182 -0.0168843 0.125321 count 2352
Position= 0.037807 -0.0167192 0.125306 count 2353
...
Position= 0.0043431 -0.0504322 0.0981873 count 2359
...
Position= 0.037718 -0.016885 0.125321 count 2373
Position= 0.037718 -0.016885 0.125321 count 2374
Position= 0.00433312 -0.0506089 0.0981003 count 2375

I haven't been able to find any returning pattern or consistency in when it is happening. As can be seen from the pipe above, it happens at random moments in time (sometimes nog for a few seconds, sometimes twice a second). Is there something about loop_rate that i'm overseeing? Is there a better way to do something like this? Any ideas are welcome :).

I used the open source drivers (nilibfalcon) and the only rosfalcon package I could find online (cyphy_rosfalcon) to create my own node uses the funtion: Pos = m_falconDevice.getPosition() to get the falcon positions.

edit retag flag offensive close merge delete

Comments

I'm not sure exactly, but a 1000Hz is pretty close (or even beyond) what a typical (non RT or other high-res patch enabled) Linux kernel will be able to schedule properly. Depending on system load, I can imagine you'll see some jitter just from task activation alone.

gvdhoorn gravatar image gvdhoorn  ( 2015-06-12 08:30:13 -0600 )edit

Also: you say that without a ros::Rate, everything is fine, and with you get strange outliers. I may be misinterpreting your copy/pastes, but it looks like you have them mixed up.

gvdhoorn gravatar image gvdhoorn  ( 2015-06-12 08:31:38 -0600 )edit

I could run it lower but rather then maybe read positions and write forces at separate frequencies. I just find it weird that a standalone executable (no ROS at all but same linux kernel) will read positions and write forces at 1000 Hz fine but with ROS functions/headers it gets jittery.

niall gravatar image niall  ( 2015-06-15 06:53:16 -0600 )edit

Thanks for your comments @gvdhoorn. I did mix up my paste, fixed that.

niall gravatar image niall  ( 2015-06-15 06:53:19 -0600 )edit

So, everything is fine with the loop rate, but without you get problems?

dornhege gravatar image dornhege  ( 2015-06-15 07:12:25 -0600 )edit

No, I updated my post, sorry for the confusion. Withloop_rate in my code, I get sporadic values (which is not what they should be as the input should be constant when I'm not moving the joystick). Withoutloop_rate (obviously won't due for my simulation) the values are fine.

niall gravatar image niall  ( 2015-06-15 07:31:24 -0600 )edit

What do you use to delay your main loop if you don't use ros::Rate?

gvdhoorn gravatar image gvdhoorn  ( 2015-06-15 10:00:15 -0600 )edit

I don't delay my loop at all, it just runs as fast as it can. Basically I'm comparing running my node with and without ROS publishing at a certain rate (with loop_rate). My point is that without ROS the values are clean and with ROS functions, the input values are noisy.

niall gravatar image niall  ( 2015-06-17 05:13:52 -0600 )edit