Skip to content

Commit

Permalink
limited the count
Browse files Browse the repository at this point in the history
  • Loading branch information
VincidaB committed May 10, 2024
1 parent fae326e commit 26f9159
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/listen_package/listen_package/ecoute.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def listener_callback(self, msg):
for range_value, intensity_value in zip(msg.ranges, msg.intensities):
if min_distance < range_value < max_distance and intensity_value > 150:
# If an object is detected within the specified range and with intensity greater than 150, publish a message
self.runningCount += 1
self.runningCount = self.runningCount + 1 if self.runningCount < self.runningCountLimit else self.runningCountLimit
else:
self.runningCount = self.runningCount - 1 if self.runningCount > 0 else 0
self.runningCount = self.runningCount - 1 if self.runningCount > 0 else 0
if self.runningCount > 0:
self.get_logger().info("Object detected at distance: %f" % range_value)
self.publisher.publish(String(data='Object detected'))
Expand Down

0 comments on commit 26f9159

Please sign in to comment.