refactor(udp_teleop): derive camera stream URL from unified IP parameter

Replace hardcoded stream_url with camera_ip parameter in box_detection_grasp. The launch file passes udp_ip as camera_ip, so all ESP32 addresses (UDP control + camera stream) now come from a single udp_ip launch argument.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-06-19 10:07:52 +08:00
parent 4d552eca64
commit e3d997dafe
3 changed files with 6 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
box_detection_grasp:
ros__parameters:
# ESP32 相机流
stream_url: "http://192.168.4.1/stream"
# ESP32 相机流(由 camera_ip 拼接 http://<ip>/stream
camera_ip: "192.168.4.1"
# YOLO 模型路径
model_path: "/home/fallensigh/Dev/craic/ros2/src/udp_teleop/models/box_detection.pt"

View File

@@ -38,7 +38,7 @@ def generate_launch_description():
DeclareLaunchArgument('auto_grasp', default_value='false',
description='检测到方框后自动抓取'),
DeclareLaunchArgument('udp_ip', default_value='192.168.4.1',
description='ESP32 UDP IP 地址'),
description='ESP32 IPUDP 控制 + 相机流共用)'),
DeclareLaunchArgument('show_debug', default_value='false',
description='显示 YOLO 检测调试窗口'),
@@ -67,6 +67,7 @@ def generate_launch_description():
name='box_detection_grasp',
output='screen',
parameters=[detection_params, {
'camera_ip': udp_ip,
'auto_grasp': auto_grasp,
'show_debug_window': show_debug,
}],

View File

@@ -123,7 +123,7 @@ class BoxDetectionGraspNode(Node):
raise RuntimeError("需要 ultralytics。安装: pip install ultralytics")
# 声明参数
self.declare_parameter('stream_url', 'http://192.168.4.1/stream')
self.declare_parameter('camera_ip', '192.168.4.1')
self.declare_parameter('model_path', '/home/fallensigh/Dev/craic/tmp/best.pt')
self.declare_parameter('confidence', 0.35)
self.declare_parameter('imgsz', 768)
@@ -136,7 +136,7 @@ class BoxDetectionGraspNode(Node):
self.declare_parameter('auto_grasp', False) # 是否自动抓取
# 获取参数
self.stream_url = self.get_parameter('stream_url').value
self.stream_url = f"http://{self.get_parameter('camera_ip').value}/stream"
self.model_path = self.get_parameter('model_path').value
self.confidence = float(self.get_parameter('confidence').value)
self.imgsz = int(self.get_parameter('imgsz').value)