Skip to content

Commit

Permalink
Fix bug where microphone sensor would use 100% CPU while waiting for …
Browse files Browse the repository at this point in the history
…subscribers
  • Loading branch information
cmbrad committed Aug 13, 2017
1 parent 8de81d6 commit fc31040
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions naoqi_sensors_py/src/naoqi_sensors/naoqi_microphone.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,11 @@ def reconfigure( self, new_config, level ):
def run(self):
r=rospy.Rate(2)
while self.is_looping():
if self.pub_audio_.get_num_connections() == 0:
if self.isSubscribed:
rospy.loginfo('Unsubscribing from audio bridge as nobody listens to the topics.')
self.release()
continue
if self.pub_audio_.get_num_connections() == 0 and self.isSubscribed:
rospy.loginfo('Unsubscribing from audio bridge as nobody listens to the topics.')
self.release()

if not self.isSubscribed:
elif self.pub_audio_.get_num_connections() > 0 and not self.isSubscribed:
self.reconfigure(self.config, 0)

r.sleep()
Expand Down

0 comments on commit fc31040

Please sign in to comment.