前视声呐目标识别定位(五)-代码解析之修改声呐参数

前视声呐目标识别定位(一)-基础知识

前视声呐目标识别定位(二)-目标识别定位模块

前视声呐目标识别定位(三)-部署至机器人

前视声呐目标识别定位(四)-代码解析之启动识别模块

前视声呐目标识别定位(五)-代码解析之修改声呐参数

前视声呐目标识别定位(六)-代码解析之目标截图并传输

前视声呐目标识别定位(七)-代码解析之录制数据包

前视声呐目标识别定位(八)-代码解析之各模块通信

前视声呐目标识别定位(九)-声呐驱动

修改声呐参数,以将声呐量程修改为10m为例,其余参数修改可参照协议文件。

1、client_test.py

python3 clien_test.py 13 10

python 复制代码
elif cmd == str(13):
    print("set sonar range: " + str(value))
    arrBuff = b'\xee\xbb\xee\x03'
    arrBuff += struct.pack('i', int(value))
    arrBuff += b'\xee\xaa\xee\xff'

在协议文件中,修改声呐量程的协议为:

故模块将该数据包发送至auv_server。

2、auv_server.py

python 复制代码
# cmd callback state msg
if pkg_head == b'\xee\xff\xee\xff':
    print(self.cmd_callback_state[recv_msg[4:8]])

直接将指令转发至center_server

3、center_sever.py

python 复制代码
# send the control_center cmd from auv to the control_center module on nx
def recv_control_center_msg(self):
    #self.sonar_param_socket, self.sonar_param_addr = self.sonar_param_server.accept()  
    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\aa\ee\ff'判断为带参数的指令,转sonar_node

4、sonar_node(此处以ros1版本中的驱动代码举例)

python 复制代码
# receive tcp cmd msg from center server, set the sonar parameter
def recv_tcp_cmd(self):
...
# set the sonar_range, 1~120
elif sonar_msg[0:4] == b'\xee\xbb\xee\x03':
    sonar_range = struct.unpack('i', sonar_msg[4:8])[0]
    sonar_range_cmd = 'rosrun dynamic_reconfigure dynparam set sonar_imager range_m ' + str(sonar_range)
    sonar_subprocess = subprocess.Popen(sonar_range_cmd, shell=True, executable="/bin/bash")

完成设置

数据包通过网口传输至声呐,声呐解码后进行参数调整。

相关推荐
stsdddd17 天前
YOLO系列目标检测数据集大全【第二十九期】
yolo·目标检测·目标跟踪
AI棒棒牛17 天前
第 03 讲《监督学习:数据、标签、Loss与训练循环》
人工智能·学习·yolo·目标检测·yolo26
stsdddd17 天前
YOLO系列目标检测数据集大全【第三十期】
yolo·目标检测·目标跟踪
YOLO数据集集合17 天前
无人机航拍地质灾害智能识别 山体滑坡实例分割数据集落地实战 | 泥石流监测 道路险情封堵 深度学习模型训练方案10296期
人工智能·深度学习·yolo·目标检测·无人机
音沐mu.17 天前
【73】墙壁建筑缺陷数据集(有v5/v8模型)/YOLO墙壁建筑缺陷检测
yolo·目标检测·目标检测数据集·墙壁建筑缺陷数据集·墙壁建筑缺陷检测
YOLO数据集集合17 天前
无人机风电设备智能巡检 风机叶片缺陷目标检测数据集实战 | 表面腐蚀漏油识别 工业视觉质检 深度学习模型训练落地10337期
人工智能·深度学习·目标检测·计算机视觉·无人机
装不满的克莱因瓶17 天前
【工业领域】掌握非极大值抑制(NMS)目标检测后处理方法——从重复框消除到工程落地核心技术
人工智能·python·深度学习·目标检测·机器学习·计算机视觉·目标跟踪
装不满的克莱因瓶17 天前
【工业领域】了解目标检测评估指标——从mAP到IoU的完整评价体系解析
人工智能·pytorch·python·深度学习·目标检测·计算机视觉·目标跟踪
动物园猫17 天前
直升机停机坪目标检测数据集分享(适用于YOLO系列深度学习分类检测任务)
深度学习·yolo·目标检测
YOLO数据集集合18 天前
无人机航拍RGBT双模态行人检测数据集 | 可见光红外对齐 低空小目标检测 多模态计算机视觉基准数据
人工智能·深度学习·目标检测·计算机视觉·无人机