Skip to content

Commit 31c8d6f

Browse files
AIRO-1381 ROS2 Version Check (#128)
1 parent 02365c8 commit 31c8d6f

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

ros_tcp_endpoint/tcp_sender.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import socket
1717
import time
1818
import threading
19+
import json
1920

2021
from rclpy.node import Node
2122
from rclpy.serialization import deserialize_message
@@ -167,7 +168,12 @@ def start_sender(self, conn, halt_event):
167168
def sender_loop(self, conn, tid, halt_event):
168169
s = None
169170
local_queue = Queue()
170-
local_queue.put(b"\0\0\0\0\0\0\0\0") # send an empty message to confirm connection
171+
172+
# send a handshake message to confirm the connection and version number
173+
handshake_metadata = SysCommand_Handshake_Metadata()
174+
handshake = SysCommand_Handshake(handshake_metadata)
175+
local_queue.put(ClientThread.serialize_command("__handshake", handshake))
176+
171177
with self.queue_lock:
172178
self.queue = local_queue
173179

@@ -206,13 +212,27 @@ def parse_message_name(self, name):
206212

207213

208214
class SysCommand_Log:
209-
text = ""
215+
def __init__(self):
216+
text = ""
210217

211218

212219
class SysCommand_Service:
213-
srv_id = 0
220+
def __init__(self):
221+
srv_id = 0
214222

215223

216224
class SysCommand_TopicsResponse:
217-
topics = []
218-
types = []
225+
def __init__(self):
226+
topics = []
227+
types = []
228+
229+
230+
class SysCommand_Handshake:
231+
def __init__(self, metadata):
232+
self.version = "v0.7.0"
233+
self.metadata = json.dumps(metadata.__dict__)
234+
235+
236+
class SysCommand_Handshake_Metadata:
237+
def __init__(self):
238+
self.protocol = "ROS2"

0 commit comments

Comments
 (0)