Input signal only noisy when loop_rate is used
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.
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.
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.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.
Thanks for your comments @gvdhoorn. I did mix up my paste, fixed that.
So, everything is fine with the loop rate, but without you get problems?
No, I updated my post, sorry for the confusion. With
loop_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.What do you use to delay your main loop if you don't use
ros::Rate
?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.