Go to the documentation of this file.
49 pub = {
"op":
"publish",
"topic": topic,
"msg": obj}
52 def subscribe(self, topic, callback, throttle_rate=-1):
54 sub = {
"op":
"subscribe",
"topic": topic}
56 sub[
'throttle_rate'] = throttle_rate
61 keys_for_deletion = []
62 for key, values
in self.
callbacks.items():
68 keys_for_deletion.append(key)
70 for key
in keys_for_deletion:
75 unsub = {
"op":
"unsubscribe",
"topic": topic}
80 call = {
"op":
"call_service",
"id": id,
"service": serviceName}
94 while self.
resp is None:
107 traceback.print_exc()
111 return ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
for _
in range(chars))
133 obj = json.loads(message)
138 if option ==
"publish":
146 print(
"exception on callback", callback,
"from", topic)
147 traceback.print_exc()
149 elif option ==
"service_response":
152 values = obj[
"values"]
158 print(
"exception on callback ID:", id)
159 traceback.print_exc()
164 print(
"Recieved unknown option - it was: ", option)
168 print(
"exception in onMessageReceived")
169 print(
"message", message)
170 traceback.print_exc()
176 self.
ws = websocket.WebSocketApp(
187 print(
"### ROS bridge connected ###")
192 print(
"Error: not connected, could not send message")
195 self.
ws.send(message)
199 print(
"Error: %s" % error)
203 print(
"### ROS bridge closed ###")
206 self.
ws.run_forever()
def on_message(self, message)
def __init__(self, host, port)
def generate_id(self, chars=16)
def unsubscribe(self, topic)
def registerCallback(self, callback)
def addCallback(self, topic, callback)
def publish(self, topic, obj)
def unhook(self, callback)
def subscribe(self, topic, callback, throttle_rate=-1)
def on_error(self, error)
def __init__(self, host, port)
def callService(self, serviceName, callback=None, msg=None)
def addServiceCallback(self, id, callback)
def sendString(self, message)
def onMessageReceived(self, message)
mir_driver
Author(s): Martin Günther
autogenerated on Wed Nov 13 2024 03:34:54