前视声呐目标识别定位(一)-基础知识
前视声呐目标识别定位(二)-目标识别定位模块
前视声呐目标识别定位(三)-部署至机器人
前视声呐目标识别定位(四)-代码解析之启动识别模块
前视声呐目标识别定位(五)-代码解析之修改声呐参数
前视声呐目标识别定位(六)-代码解析之目标截图并传输
前视声呐目标识别定位(七)-代码解析之录制数据包
结合结构图:
一、auv_server.py
1、作为center_cerver的服务器,通过端口8088与其通信
self.auv_ip = '192.168.1.111'
self.auv_port = 8088
...
# tcp server setting
self.auv_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.auv_server.bind((self.auv_ip, self.auv_port))
self.auv_server.listen(5)
self.conn, self.addr = self.auv_server.accept()
2、作为client_test的服务器,通过端口8089与其通信
self.cmd_test_port = 8089
...
self.test_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.test_server.bind((self.auv_ip, self.cmd_test_port))
self.test_server.listen(5)
二、center_server.py
1、与auv_server通信
self.auv_ip = '192.168.1.111' # the server ip
self.auv_port = 8088
...
# connect the auv
self.nx_client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.nx_client.connect((self.auv_ip,self.auv_port))
2、作为识别模块yolov5_humble_fls的服务器,通过端口8080与其通信
self.nx_ip = '192.168.1.110' # the board ip
self.data_port = 8080 # yolo pos info & object
...
# yolo server for the yolo module on the nx
self.yolo_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.yolo_server.bind((self.nx_ip, self.data_port)) # bind the data port
self.yolo_server.listen(5)
3、作为control_center的服务器,通过端口8081与其通信
self.control_center_port = 8081 # cmd and cmd callback of each module transfer port
# control_center server for the control_center module on the nx
self.control_center_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.control_center_server.bind((self.nx_ip, self.control_center_port)) # bind the control_center port
self.control_center_server.listen(5)
4、作为声呐驱动模块sonar_node的服务器,通过端口8082与其通信
self.sonar_param_port = 8082 # sonar parameters setting cmd tansfer port
...
# sonar parameters parameters setting server for the sonar module on the nx
self.sonar_param_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sonar_param_server.bind((self.nx_ip, self.sonar_param_port)) # bind the sonar port
self.sonar_param_server.listen(5)
三、yolov5_humble_fls模块(yolov5_sonar.py)
1、与center_server通信
# tcp parameters
self.declare_parameter('server_ip', '192.168.1.110')
self.server_host = self.get_parameter('server_ip').get_parameter_value().string_value
self.declare_parameter('server_port', 8080)
self.server_port = self.get_parameter('server_port').get_parameter_value().integer_value
...
# establish tcp link
try:
self.yolo_client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.yolo_client.connect((self.server_host, self.server_port))
except Exception as e:
tcp_error = "connection error... " + str(self.server_host) + " : " + str(self.server_port)
print("\033[31;1m %s %s\033[0m" %(tcp_error,e))
IP和端口均可在yolov5_humble_fls.yaml中设置。
四、control_center.py
1、与center_server通信
self.nx_ip = '192.168.1.110'
self.cmd_port = 8081
self.cmd_client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # create TCP/IP socket
self.cmd_client.connect((self.nx_ip, self.cmd_port))
五、声呐模块sonar node同理
代码整理后的ROS2的版本我进行测试时只在一台台式机上进行,所以各个IP都是相同的。