Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Huge CPU Load for simulated tactile data #2

Closed
guihomework opened this issue Aug 22, 2022 · 5 comments · Fixed by #4
Closed

Huge CPU Load for simulated tactile data #2

guihomework opened this issue Aug 22, 2022 · 5 comments · Fixed by #4

Comments

@guihomework
Copy link

We noticed that gloveConsole has no rate limit when started with the -d option (random data output) which makes it publish at highest possible frame rate leading to huge and useless CPU load.

rosrun tactile_glove gloveConsole -r -d
rostopic hz /TactileGlove
subscribed to [/TactileGlove]
average rate: 48319.197

One can either implement a rate limit (using timestamps) in the Random Input Class as done in FileInput which is more generic, or add a rate limit only for ROS publishers.

Being able to set the rate would be extra, otherwise 1 kHz default setting would be sufficient (similar to our default gloves).

@rhaschke What do you think ?

@rhaschke
Copy link
Member

Sure. I welcome a PR. I suggest having a period member, defaulting to 1000µs, which can be changed via a setter method.
No need to set the period via cmdline for now.

@guihomework
Copy link
Author

Here are results of the PR #3

~/catkin_ws_noetic/devel$ rostopic hz /TactileGlove
subscribed to [/TactileGlove]
average rate: 917.975
	min: 0.000s max: 0.002s std dev: 0.00006s window: 917

even with a low-latency kernel, the basic time functions, (and also more recent std::chrono::high_resolution_clock) do not give good timing due to usleep (also tested nanosleep) not being ideal.

example this code

auto t1 = Clock::now();
usleep(1000.0);
auto t2 = Clock::now();
auto int_ms = std::chrono::duration_cast<std::chrono::microseconds>(t2 - t1);

produces

time us 1127
time us 1126
time us 1126
time us 1063
time us 1073
time us 1101
time us 1124
time us 1123
time us 1122

ROS rate is usually better but this would mean one should place the timing at the node side and out of the lib.

@rhaschke
Copy link
Member

In #4 I implemented Rate::sleep adapting ROS' Rate to std::chrono. This yields much better precision as well.
Looking into the code, I noticed that the GUI application shouldn't exhibit the high CPU load. Did you observe that in both apps, gloveConsole and GloveGUI?

@guihomework
Copy link
Author

Thanks a lot for providing a clean solution that I am not capable of doing (really). Even more I do not understand some choices, but maybe I make remarks in a review if you want me to do one (because I am currently assigned the PR not asked for review as last time)

Did you observe that in both apps, gloveConsole and GloveGUI?

did not try in GloveGUI, only gloveConsole was tried.

@rhaschke
Copy link
Member

@guihomework, I would very much appreciate your review. However, if you don't have time for it, don't worry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants