From 127313aea06869045199b5cf8bf75399b3ca6c77 Mon Sep 17 00:00:00 2001 From: Benjamin Klaus Date: Wed, 1 Apr 2020 13:39:14 +0200 Subject: [PATCH] sleep 0.5s while waiting for controllers to connect in order to avoid high CPU usage --- src/keyboard_teleop.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/keyboard_teleop.cpp b/src/keyboard_teleop.cpp index b83d771..2e2b77b 100644 --- a/src/keyboard_teleop.cpp +++ b/src/keyboard_teleop.cpp @@ -118,8 +118,7 @@ int main(int argc, char **argv) { ros::Subscriber nameSub = n.subscribe("model_name", 100, controllerNameCallback); while (controllerCount == 0 || controllerCount < nameSub.getNumPublishers()) { ros::spinOnce(); - ros::spinOnce(); - ros::spinOnce(); + ros::Duration(0.5).sleep(); } ros::spinOnce();