Skip to content

Commit

Permalink
[ontopy] draft of compat layer
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthou committed Jan 12, 2024
1 parent 80f999b commit a2aeb8e
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions ontopy/ontologenius/compat/ros.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os

if os.environ["ROS_VERSION"] == "1":
import rospy

class ontoService :
def __init__(self, client):
self.client = client

def call(params):
pass

class ontoPublisher :
def __init__(self, pub):
self.pub = pub

def publish(self, msg):
self.pub.publish(msg)

class ontoSubscriber :
def __init__(self, sub):
self.sub = sub

class ontoros :
def createService(srv_name, srv_type, connected):
return ontoService(rospy.ServiceProxy(srv_name, srv_type, connected))

def createPublisher(pub_name, pub_type, queue_size):
return ontoPublisher(rospy.Publisher(pub_name, pub_type, queue_size=queue_size))

def createSubscriber(sub_name, sub_type, callback):
return ontoSubscriber(rospy.Subscriber(sub_name, sub_type, callback))

def getRosTime():
return rospy.get_rostime()

def isShutdown():
return rospy.is_shutdown()

print("v1")
elif os.environ["ROS_VERSION"] == "2":
import rclpy

print("v2")

0 comments on commit a2aeb8e

Please sign in to comment.