前视声呐目标识别定位(一)-基础知识
前视声呐目标识别定位(二)-目标识别定位模块
前视声呐目标识别定位(三)-部署至机器人
以启动识别模块为例,其余关闭识别模块,启动和关闭声呐模块,启动和关闭离线数据播放同理。
1、client_test.py
python3 clien_test.py 1 1
if cmd == str(1):
print("sent the yolo start cmd...")
arrBuff = bytearray(b'\xee\xaa\xee\xaa\xee\xff\xee\xff')
在协议文件中,启动的协议为:
故模块将该数据包发送至auv_server。
2、auv_server.py
def test_cmd(self):
while True:
self.test_conn, self.test_addr = self.test_server.accept()
test_cmd_msg = self.test_conn.recv(1024)
if len(test_cmd_msg)>0:
self.conn.send(test_cmd_msg)
直接将指令转发至center_server
3、center_sever.py
# send the control_center cmd from auv to the control_center module on nx
def recv_control_center_msg(self):
while True:
cmd_msg = self.nx_client.recv(1024)
if len(cmd_msg) > 3:
# send the control_center cmd to the control_center module
if cmd_msg[-4:] == b'\xee\xff\xee\xff':
self.control_center_socket.send(cmd_msg)
# send the sonar parameters cmd to the sonar module
elif cmd_msg[-4:] == b'\xee\xaa\xee\xff':
self.sonar_param_socket.send(cmd_msg)
else:
print("cmd from auv error, no such cmd...")
根据‘\ee\ff\ee\ff‘判断为不带参数的指令,转control_center.py
4、control_center.py
def rcev_cmd(self):
...
# start yolov5_ros ros2 launch
if recvmsg[0:4] == self.start_yolo_msg[0:4]:
# yolo is running, continue
if self.yolo_running:
print("yolo is running...")
# callback the cmd
self.send_cmd(self.yolo_is_running)
# no yolo is running, start yolo
else:
print("start yolo...")
self.yolo_subprocess = subprocess.Popen(self.start_yolo_cmd, shell=True, executable="/bin/bash")
self.yolo_running = True
self.send_cmd(self.start_yolo_msg)
....
根据”\ee\aa\ee\aa”判断为启动识别程序。
如果识别程序没有运行,执行
self.start_yolo_cmd = 'cd ~/yolov5_humble_fls_tcp && source install/setup.bash && ros2 launch yolov5_humble_fls start.launch.py'
反馈信息至auv_server.py,self.cmd_callback_header + self.start_yolo_msg
即/ee/ff/ee/ff/ee/aa/ee/aa/ee/aa/ee/ff
5、auv_server.py
# cmd callback state msg
if pkg_head == b'\xee\xff\xee\xff':
print(self.cmd_callback_state[recv_msg[4:8]])
根据\ee\ff\ee\ff判断为反馈信息,根据\ee\aa\ee\aa判断为识别程序成功启动信息