Skip to content

Commit

Permalink
[ontopy] compat spin_once method
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthou committed Jan 23, 2024
1 parent 1a553b6 commit 6950519
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ontopy/ontologenius/compat/ros.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import time
from ontologenius.msg import OntologeniusTimestamp

if os.environ["ROS_VERSION"] == "1":
Expand Down Expand Up @@ -72,6 +73,9 @@ def getRosTime():
def isShutdown():
return rospy.is_shutdown()

def spin_once():
time.sleep(0.01)

elif os.environ["ROS_VERSION"] == "2":

import rclpy
Expand Down Expand Up @@ -144,7 +148,7 @@ def publish(self, msg):
self.pub.publish(msg)

def getNumSubscribers(self):
self.pub.get_num_connections()
self.pub.get_subscription_count()


class OntoSubscriber:
Expand Down Expand Up @@ -184,3 +188,7 @@ def getRosTime() -> Time:
@staticmethod
def isShutdown() -> bool:
return not rclpy.ok()

@staticmethod
def spin_once():
rclpy.spin_once(Ontoros(), timeout_sec=0.01)

0 comments on commit 6950519

Please sign in to comment.