From 791a1f554b92d1f0da9d64676bb2f620c59af01a Mon Sep 17 00:00:00 2001 From: walunt5 Date: Thu, 29 Oct 2026 21:41:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(minco=5Fws):=20reference=5Fpath=5Fpublisher?= =?UTF-8?q?=20=E9=BB=98=E8=AE=A4=E8=AE=A2=E9=98=85=20/body=5Fodom=EF=BC=8C?= =?UTF-8?q?=E6=AD=A4=E5=89=8D=E6=B0=B8=E8=BF=9C=E5=8D=A1=E4=BD=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 现象:ros2 run scan_planner reference_path_publisher.py --ros-args --params-file ... 打印 'Waiting to publish 5 reference-path points' 后无限挂起,不再有任何输出。 根因:脚本硬编码订阅 **body_pose**,而该名字只存在于 run_vehicle.launch.py 给 scan_planner_node 做的**内部 remap**;总线上真实话题是 /body_odom。 全仓仅 go2_kinematic_sim / open_loop_controller(仿真、开环调试)发布 body_pose, 实车链路没有 ⇒ first_odom_time 永远为 None,try_publish 每 50 ms 直接 return。 另有第二道门槛:initial_path 必须**有订阅者**,而 FSM 只在 navi_mode=3 (REFERENCE_PATH)时才订阅它;用默认 navi_mode=1 同样会卡——两道门表现相同, 原先无法区分。 改动: - 新增参数 odom_topic(默认 /body_odom)、path_topic(默认 initial_path) - 卡住时每 3 s 打印具体原因(缺里程计 / 无订阅者),把静默挂起变成可诊断 install(PROGRAMS) 在 --symlink-install 下是符号链接,改动即时生效无需重编。 正确用法:vehicle_bringup.launch.py navi_mode:=3 + 直接 ros2 run(不必再加 remap)。 --- .../scripts/reference_path_publisher.py | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/minco_ws/src/scan/plan_manage/scripts/reference_path_publisher.py b/minco_ws/src/scan/plan_manage/scripts/reference_path_publisher.py index 7f19568..68716d8 100755 --- a/minco_ws/src/scan/plan_manage/scripts/reference_path_publisher.py +++ b/minco_ws/src/scan/plan_manage/scripts/reference_path_publisher.py @@ -46,10 +46,17 @@ class ReferencePathPublisher(Node): self.declare_parameter("frame_id", "world") self.declare_parameter("waypoints", Parameter.Type.DOUBLE_ARRAY) self.declare_parameter("publish_delay_sec", 0.5) + # 实车链路上里程计的话题名是 /body_odom(body_odom 节点输出)。 + # "body_pose" 只是 run_vehicle.launch.py 里给 scan_planner_node 做的**内部 remap**, + # 总线上并不存在;本脚本单独 ros2 run 时拿不到那层 remap,用 body_pose 会永远等不到数据。 + self.declare_parameter("odom_topic", "/body_odom") + self.declare_parameter("path_topic", "initial_path") self.frame_id = self.get_parameter("frame_id").value self.waypoints = parse_waypoints(self.get_parameter("waypoints").value) self.publish_delay_sec = float(self.get_parameter("publish_delay_sec").value) + self.odom_topic = self.get_parameter("odom_topic").value + self.path_topic = self.get_parameter("path_topic").value if not self.frame_id: raise ValueError("frame_id must not be empty") if not math.isfinite(self.publish_delay_sec) or self.publish_delay_sec < 0.0: @@ -60,9 +67,9 @@ class ReferencePathPublisher(Node): reliability=ReliabilityPolicy.RELIABLE, durability=DurabilityPolicy.TRANSIENT_LOCAL, ) - self.path_publisher = self.create_publisher(Path, "initial_path", path_qos) + self.path_publisher = self.create_publisher(Path, self.path_topic, path_qos) self.odom_subscription = self.create_subscription( - Odometry, "body_pose", self.odom_callback, qos_profile_sensor_data + Odometry, self.odom_topic, self.odom_callback, qos_profile_sensor_data ) self.first_odom_time = None self.published = False @@ -76,9 +83,20 @@ class ReferencePathPublisher(Node): self.first_odom_time = self.get_clock().now() def try_publish(self): - if self.published or self.first_odom_time is None: + if self.published: + return + if self.first_odom_time is None: + self.get_logger().warn( + f"等待 {self.odom_topic} 的里程计……若该话题无发布者," + f"检查 body_odom 是否启动(实车应为 /body_odom,不是 body_pose)", + throttle_duration_sec=3.0, + ) return if self.path_publisher.get_subscription_count() == 0: + self.get_logger().warn( + f"{self.path_topic} 暂无订阅者——FSM 需以 navi_mode:=3 启动才会订阅参考路径", + throttle_duration_sec=3.0, + ) return elapsed = (self.get_clock().now() - self.first_odom_time).nanoseconds / 1e9 if elapsed < self.publish_delay_sec: