chore: add ros2 udp_teleop package and tools

This commit is contained in:
2026-05-27 02:17:35 +08:00
parent 13fdba5fff
commit 6f6577d983
13 changed files with 743 additions and 3 deletions

22
tools/udp_server.py Normal file
View File

@@ -0,0 +1,22 @@
import socket
# 创建 UDP socket
server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# 绑定地址和端口
HOST = "0.0.0.0"
PORT = 8888
server.bind((HOST, PORT))
print(f"UDP服务器正在监听 {HOST}:{PORT}")
while True:
# 接收数据
data, addr = server.recvfrom(1024)
print(f"收到来自 {addr} 的消息: {data.decode()}")
# 回复客户端
reply = "服务器已收到"
server.sendto(reply.encode(), addr)